在Visual Studio中如何启动单个项目而不进行调试?(How to start a single project without debugging in Visual Studio?)

编程入门 行业动态 更新时间:2024-10-24 12:23:32
在Visual Studio中如何启动单个项目而不进行调试?(How to start a single project without debugging in Visual Studio?)

我的解决方案包含可以启动的多个项目。 有时我想启动一个项目,而不使用我的解决方案启动项目设置。 当我右键单击该项目时,我可以导航到Debug-> Start New Instance,它使用调试器启动应用程序。

但是我想启动一个没有调试器的新实例。 这可能吗?

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?

最满意答案

如果您对永久解决方案感兴趣,那么我已经为此任务编写了一个小宏。 它做以下事情:

获取当前选定的项目(如果您选择了多个项目,它将使用第一个选定的项目)。 保存当前的启动项目 将当前所选项目设置为启动项目,并在“启动无调试”模式下运行当前选定的项目。 将初始启动项目恢复为启动项目。

以下是我写的宏和程序如何做。

如何写宏:首先你需要去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的宏(记住它将像MyMacros.Module1.RunSelectedWithoutDebug那样),然后分配一个热键组合或和弦并保存。

注意:第四步是创建一个问题,并产生一个恼人的消息框,说:必须停止生成以更改解决方案属性。 停止构建? 确定或取消。 我曾经打过好时机。 如果您没有任何问题,如果宏将当前选定的项目设置为启动项目,请注意最后一行宏Prop.Value = PrevStartup,将“on the start of line.Now”消息框不会来。

我正在调查它,并将发布更新的宏一旦我解决它(如果我可以:))

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

Gets current selected project ( it will use first selected project, if you have selected multiple projects.) Saves the current Startup Project Sets the current selected project as Startup project and Runs the current selected project in "Start without Debug" Mode. Restores the Initial Startup Project as Startup Project.

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

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

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.

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 :) )

更多推荐

本文发布于:2023-07-24 20:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1250536.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不   项目   Studio   Visual   debugging

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!