Created
May 4, 2017 20:42
-
-
Save GoEddie/7dcf10fb8d0ac2e72c35a25a195e3a7b to your computer and use it in GitHub Desktop.
If you have an SSDT project in visual studio and want to get the version of sql it is targetting because everything is internal :( do this!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string GetTargetSqlServerVersion(){ | |
var dte = (DTE)GetService(typeof(DTE)); | |
var project = dte.ActiveDocument.ProjectItem.ContainingProject; | |
return project.GetType().GetProperty("Globals").GetValue(project).GetType().GetProperty("Parent").GetValue(project.GetType().GetProperty("Globals").GetValue(project)).GetType().GetProperty("DatabaseSchemaProvider").GetValue(project.GetType().GetProperty("Globals").GetValue(project).GetType().GetProperty("Parent").GetValue(project.GetType().GetProperty("Globals").GetValue(project))).GetType().GetProperty("Platform").GetValue(project.GetType().GetProperty("Globals").GetValue(project).GetType().GetProperty("Parent").GetValue(project.GetType().GetProperty("Globals").GetValue(project)).GetType().GetProperty("DatabaseSchemaProvider").GetValue(project.GetType().GetProperty("Globals").GetValue(project).GetType().GetProperty("Parent").GetValue(project.GetType().GetProperty("Globals").GetValue(project)))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment