如何在不进行Visual Studio调试的情况下启动单个项目? [英] How to start a single project without debugging in Visual Studio?

查看:283
本文介绍了如何在不进行Visual Studio调试的情况下启动单个项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的解决方案包含多个可以启动的项目.有时我想在不使用我的解决方案启动项目设置的情况下启动单个项目.在项目上单击鼠标右键时,可以导航到调试"->启动新实例",这将使用调试器启动应用程序.

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 right-click on the project, I can navigate to Debug->Start New Instance, which starts the application with debugger.

但是我想在没有调试器的情况下启动一个新实例.这可能吗?

But I would like to start a new instance without debugger. Is this possible?

推荐答案

如果您对永久解决方案感兴趣,那么我已经为该任务编写了一个小宏. 它确实有以下作用:

If you are interested in permanent solution then I have written a small macro for this task. It does following things :

  1. 获取当前选定的项目(如果您选择了多个项目,它将使用第一个选定的项目.)
  2. 保存当前的启动项目
  3. 将当前选定的项目设置为启动"项目,并以无调试启动"模式运行当前选定的项目.
  4. 将初始启动项目"恢复为启动项目".

下面是我编写的宏以及执行该操作的过程.

Below is the Macro that I have written and the procedure how to do it.

如何编写宏: 首先,您需要转到Visual Studio工具->宏->宏资源管理器.右键单击MyMacros并创建一个新模块(我称为CollapseAll).

How to write Macro : First thing you need to go to Visual Studio Tools --> Macros --> Macro Explorer. Once you got that right click on MyMacros and create a new module (I called it CollapseAll).

现在编辑新模块(双击它),擦除其中的所有内容并将其粘贴到其中.

Now edit the new module (double-click on it) erase whatever is in there and paste this stuff into it.

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素材的宏(请记住,它将像MyMacros.Module1.RunSelectedWithoutDebug一样存在),然后为其分配热键组合或和弦并保存.

How to bind macro to keyboard shortcut : To do this you need to go to Tools-->Options-->Environment-->Keyboard. Pick your macro from the listBox with all the default VS stuff (remember it will be there like MyMacros.Module1.RunSelectedWithoutDebug) and then assign a hotkey combination or chord to it and save.

注意::第四步是创建问题并产生一个令人讨厌的消息框,其中说: 必须停止构建才能更改解决方案属性.停止构建?确定或取消.我过去经常打Ok.如果宏将当前选定的项目设置为启动项目",则没有任何问题,请在宏的最后一行添加注释 Prop.Value = PrevStartup,方法是在行首添加'.现在,消息框将不再显示.

Note : 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. I used to hit Ok for the timebeing. If you dont have any problem if the macro sets up current selected project as Startup project than please comment last line of macro Prop.Value = PrevStartup by putting ' at the start of line.Now the messagebox will not come.

我正在研究它,一旦我解决了它,就会发布更新的宏(如果可以的话))

I am looking into it and will post the updated macro once i solve it ( if I can :) )

这篇关于如何在不进行Visual Studio调试的情况下启动单个项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆