Reputation: 18610
In MSVC several operations (such as Menu: Build: Build ) are context sensitive to the currently selected Solution Project. However, that Project often changes if you've been navigating Solution Explorer.
I'd like to write a macro that find the project specified as the "startup project", and the selects it to make it active. I haven't found the appropriate DTE calls though.
Upvotes: 3
Views: 1892
Reputation: 18610
My primary goal was to build the startup project, which I have found a solution to:
Public Sub BuildStartupProject()
Dim sb As SolutionBuild = DTE.Solution.SolutionBuild
Dim projName As String = sb.StartupProjects(0)
DTE.ExecuteCommand("View.Output")
sb.BuildProject(sb.ActiveConfiguration.Name, projName, False)
End Sub
From the Chromium project wiki.
Upvotes: 4
Reputation: 6068
Here is somthing that should get you started, I have not verified if it will work when projects are nested inside a folder.
Sub SetStartupProjectasActive()
Dim solutionName As String = DTE.Solution.Properties.Item("Name").Value
Dim startupProject As String = DTE.Solution.Properties.Item("StartupProject").Value
Dim fullItemName As String = String.Format("{0}\{1}", solutionName, startupProject)
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
DTE.ActiveWindow.Object.GetItem(fullItemName).Select(vsUISelectionType.vsUISelectionTypeSelect)
End Sub
Upvotes: 1