In Visual Studio, how do I debug a project without building it

后端 未结 6 1497
忘掉有多难
忘掉有多难 2021-02-05 02:51

This is for Visual Studio 2008.

I have Tools|Projects and Solutions|Build and Run|On Run, when projects are out of date set to Always build bec

6条回答
  •  星月不相逢
    2021-02-05 03:15

    I put the following function in my NuGet_profile.ps1:

    function debugnobuild() {
        # temporarily disable build (same as Properties -> Configuration -> ..)
        $buildProjects = @($DTE.Solution.SolutionBuild.ActiveConfiguration.SolutionContexts |
        where ShouldBuild | foreach {
            $_.ShouldBuild = $false
            $_.ProjectName
        })
        try {
            # start debugging
            $DTE.Solution.SolutionBuild.Debug()
        }
        finally {
            # undo changes
            $DTE.Solution.SolutionBuild.ActiveConfiguration.SolutionContexts |
            where { $buildProjects -contains $_.ProjectName } | foreach {
                $_.ShouldBuild = $true
            }
        }
    }
    

    Then just call debugnobuild (or any name you prefer) in the Package Manager Console.

提交回复
热议问题