How to start a single project without debugging in Visual Studio?

后端 未结 14 1138
盖世英雄少女心
盖世英雄少女心 2020-12-01 03:08

My solution contains multiple projects which can be started. SometimesI would like to start a single project without using my solution startup projects settings. When I righ

14条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 03:50

    Here is the the way to solve problem related to Mahin's macro

    Problem description: Fourth step is creating a problem and spawns an annoying messagebox saying : The build must be stopped to change the solution property. Stop the build? Ok or Cancel.

    Public Module Custom
        Private WithEvents t As Timers.Timer
    
        Private Prop As EnvDTE.Property
        Private PrevStartup As Object
    
        Private Sub StartTimer()
            t = New Timers.Timer
            t.Interval = 0.05
            t.Start()
        End Sub
    
        Sub t_Elapsed(ByVal ee As Object, ByVal dd As Timers.ElapsedEventArgs) Handles t.Elapsed
            If DTE.Solution.SolutionBuild.BuildState <> vsBuildState.vsBuildStateInProgress Then
                t.Stop()
                Prop.Value = PrevStartup
            End If
        End Sub
    
        Sub RunSelectedWithoutDebug()
            Dim Projs As Array
            Dim Proj As Project
            Projs = DTE.ActiveSolutionProjects()
            If (Projs.Length > 0) Then
                Proj = Projs.GetValue(0)
                Prop = DTE.Solution.Properties.Item("StartupProject")
    
                PrevStartup = Prop.Value
                Prop.Value = Proj.Name
                DTE.ExecuteCommand("Debug.StartWithoutDebugging")
                StartTimer()
            End If
        End Sub
    End Module
    

    Enjoy !

提交回复
热议问题