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

后端 未结 6 1498
忘掉有多难
忘掉有多难 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:12

    In VS2013 it is: right click solution -> Configuration Manager, and clear Build checkbox of your project(s).

    0 讨论(0)
  • 2021-02-05 03:12

    No, there isn't. You can't debug an historic version without running it, which implies building it. VS debugs against the current symbols and binary, which will be out sync with the source without building it, making debugging impossible.

    0 讨论(0)
  • 2021-02-05 03:15

    I found it convenient to create a new build configuration in order to do this. Right-click the solution in the Solution Explorer and choose Properties. From there, choose Configuration Properties / Configuration. Now choose Configuration Manager and create a new configuration as shown. You can create the build configuration as a copy of your Debug project:

    Then, press OK and turn off all of the project build flags:

    Visual Studio will have created a folder underneath the bin folder in the startup project with the name of the new configuration. Copy your pre-built files into there and run the new configuration.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-02-05 03:16

    What I do is: Set a System.Diagnostics.Debugger.Launch() line in the code, run the program seperately, attach the debugger in VS.

    0 讨论(0)
  • 2021-02-05 03:17

    Please right click solution name and go to Properties -> Configuration Properties -> Configuration, clear the Build checkbox of the project.

    0 讨论(0)
提交回复
热议问题