Visual Studio macro for selecting a startup project

In MSVC, several operations (for example, menu: assembly: assembly) are context sensitive for the currently selected solution project. However, this project often changes if you have navigated through solutions.

I would like to write a macro that finds the project specified as the “launch project” and selects it to make it active. I did not find the corresponding DTE calls, though.

+3
source share
2 answers

My main goal was to create a startup project on which I found a solution:

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 .

+4
source

, , , , .

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
+1

Source: https://habr.com/ru/post/1755801/


All Articles