Programing

Visual Studio에서 디버깅하지 않고 단일 프로젝트를 시작하는 방법은 무엇입니까?

lottogame 2020. 12. 2. 07:46
반응형

Visual Studio에서 디버깅하지 않고 단일 프로젝트를 시작하는 방법은 무엇입니까?


내 솔루션에는 시작할 수있는 여러 프로젝트가 포함되어 있습니다. 때때로 솔루션 시작 프로젝트 설정을 사용하지 않고 단일 프로젝트를 시작하고 싶습니다. 프로젝트를 마우스 오른쪽 버튼으로 클릭하면 Debug-> Start New Instance로 이동하여 디버거로 애플리케이션을 시작합니다.

하지만 디버거없이 새 인스턴스를 시작하고 싶습니다. 이것이 가능한가?


영구 솔루션에 관심이 있다면이 작업에 대한 작은 매크로를 작성했습니다. 다음과 같은 작업을 수행합니다.

  1. 현재 선택된 프로젝트를 가져옵니다 (여러 프로젝트를 선택한 경우 처음 선택한 프로젝트를 사용합니다.)
  2. 현재 시작 프로젝트를 저장합니다.
  3. 현재 선택된 프로젝트를 시작 프로젝트로 설정하고 "디버그없이 시작"모드에서 현재 선택된 프로젝트를 실행합니다.
  4. 초기 시작 프로젝트를 시작 프로젝트로 복원합니다.

아래는 내가 작성한 매크로와이를 수행하는 절차입니다.

매크로 작성 방법 : 먼저 Visual Studio 도구-> 매크로-> 매크로 탐색기로 이동해야합니다. MyMacros를 마우스 오른쪽 버튼으로 클릭하고 새 모듈을 만듭니다 (CollapseAll이라고 함).

이제 새 모듈을 편집 (두 번 클릭)하여 거기에있는 모든 것을 지우고 여기에 붙여 넣습니다.

Sub RunSelectedWithoutDebug()
            Dim Projs As Array
            Dim Proj As Project
            Projs = DTE.ActiveSolutionProjects()
            If (Projs.Length > 0) Then
                Proj = Projs.GetValue(0)
                Dim Prop As EnvDTE.Property
                Prop = DTE.Solution.Properties.Item("StartupProject")
                Dim PrevStartup As Object
                PrevStartup = Prop.Value
                Prop.Value = Proj.Name
                DTE.ExecuteCommand("Debug.StartWithoutDebugging")
                Prop.Value = PrevStartup
            End If
        End Sub

매크로를 키보드 바로 가기에 바인딩하는 방법 : 이렇게하려면 도구-> 옵션-> 환경-> 키보드로 이동해야합니다. 모든 기본 VS 항목이있는 listBox에서 매크로를 선택한 다음 (MyMacros.Module1.RunSelectedWithoutDebug와 같은 위치에 있음을 기억하십시오) 핫키 조합 또는 코드를 할당하고 저장하십시오.

참고 : 네 번째 단계는 문제를 만들고 다음과 같은 성가신 메시지 상자를 생성하는 것입니다. 솔루션 속성을 변경하려면 빌드를 중지해야합니다. 빌드를 중지 하시겠습니까? 확인 또는 취소. 나는 한동안 Ok를 누르 곤했다. 매크로가 현재 선택된 프로젝트를 시작 프로젝트로 설정하면 문제가 없다면 매크로의 마지막 줄에 '를 입력하여 줄의 시작 부분에 추가하여 주석을 달아주세요. 이제 메시지 상자가 오지 않습니다.

나는 그것을 조사하고 있으며 그것을 해결하면 업데이트 된 매크로를 게시 할 것입니다 (할 수 있다면 :))


VS 2015의 새로운 기능 일 수도 있지만 사용자 지정 매크로를 추가 할 필요가 없습니다. 추가 할 수있는 항목 목록에서 디버깅하지 않고 시작 메뉴 항목을 찾을 수 있습니다.

도구-> 사용자 정의로 이동하여 아래 이미지를 따르십시오.

추가 명령 누르기 여기에서 메뉴 항목을 찾을 수 있습니다.


Visual Studio에 VSCommands 확장을 추가 하고 프로젝트를 마우스 오른쪽 단추로 클릭-> 디버그-> 디버깅하지 않고 시작


이 매크로를 모아 놓았습니다.이 매크로는 인터 웹에서 찾은 여러 조각의 조합입니다. 프로젝트가 기본 프로젝트 출력을 실행하도록 구성된 경우이를 찾아서 실행합니다. 특정 프로그램을 실행하도록 구성된 경우 해당 프로그램이 실행됩니다. 이 매크로는 응용 프로그램도 컴파일하지 않으므로 매크로를 실행하기 전에 컴파일되었는지 확인해야합니다. 동시에,이 매크로는 위의 Mahin의 매크로에서 언급 한 문제를 겪지 않습니다.

Sub RunActiveProjectOutput()
    Dim Projs As Array
    Dim Proj As Project
    Projs = DTE.ActiveSolutionProjects()
    If (Projs.Length > 0) Then
        Proj = Projs.GetValue(0)

        Dim action = DirectCast(Proj.ConfigurationManager.ActiveConfiguration.Properties.Item("StartAction").Value, Integer)

        If (action = 1) Then
            Dim app = Proj.ConfigurationManager.ActiveConfiguration.Properties.Item("StartProgram").Value
            Dim args = Proj.ConfigurationManager.ActiveConfiguration.Properties.Item("StartArguments").Value
            System.Diagnostics.Process.Start(app, args)
        Else
            Dim fullPath = Proj.Properties.Item("FullPath").Value.ToString()
            Dim outputPath = Proj.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString()
            Dim outputDir = System.IO.Path.Combine(fullPath, outputPath)
            Dim outputFileName = Proj.Properties.Item("OutputFileName").Value.ToString()
            Dim assemblyPath = System.IO.Path.Combine(outputDir, outputFileName)
            System.Diagnostics.Process.Start(assemblyPath)
        End If
    End If
End Sub

Mahin의 매크로와 관련된 문제해결 하는 방법은 다음과 같습니다.

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 !


I've been trying to do the same thing. It seems like an oversight by the VS team that you can start with or without debug at the solution level, but only with debug at the project level.

One thing that I've noticed is that if you right-click on a toolbar and choose "Customize", in the popup window of actions, go to Category "Project". In there, there is a command for "Run" and "Run Selected". Interesting, I added both to my project context menu, and to the main button bar, and the items seem to always be disabled.

Also interesting, the project context menu's "Debug | Start New Instance" command is nowhere to be found in the list of customizable commands. I looked through almost every category and couldn't find it.

Hopefully someone comes up with a good way to do this... it would be really handy!


Right-Click on the project and Set it as Startup Project.

Hit Ctrl + F5


In short no.

What you could do is bind a key to the "Set as startup project" and then bind another key to start without debugging. Then you would have to push 2 keys to start this project without debugging, but at least it'd be quicker than using the mouse...


Use Start without debugging under Debug menu, or

Ctrl+F5

or you can modify the web.config file for the project:

<compilation debug="false"/>

This is pretty quick: Project | Set As StartUp Project | Current Selection. Then whichever project is selected is run under Debug | Start Without Debugging / Ctrl-f5. https://blogs.msdn.microsoft.com/saraford/2005/11/29/how-to-set-your-current-project-to-always-be-the-startup-project/


I usually start the executable directly. If i need one solution without debugging mode a lot i usually add them to a quick launch menu somewhere on my taskbar.


Someone has made an addon that does this. Currently doesn't really handle aspnetcore projects though:

https://marketplace.visualstudio.com/items?temName=vurdalak1.startwithoutdebugging


Right-click on the solution, select Properties. Select Multiple startup projects. A combobox for each project allows you decide which projects to start without debugging.


  1. 필요한 프로젝트를 시작 프로젝트로 설정하십시오 (모든 사람이 제안한대로).
  2. 솔루션 구성 관리자에서 다른 모든 프로젝트에 대해 '빌드'를 끕니다.
  3. 디버깅하지 않고 시작합니다.

참고 URL : https://stackoverflow.com/questions/1356565/how-to-start-a-single-project-without-debugging-in-visual-studio

반응형