我的解决方案包含多个可以启动的项目.有时我想在不使用我的解决方案启动项目设置的情况下启动单个项目.当我右键单击项目时,我可以导航到Debug-> Start New Instance,它使用调试器启动应用程序.
但我想在没有调试器的情况下启动一个新实例.这可能吗?
MRG*_*MRG 17
如果您对永久解决方案感兴趣,那么我已经为此任务编写了一个小宏.它做了以下事情:
下面是我编写的宏以及如何执行的过程.
如何编写宏: 首先需要转到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
Run Code Online (Sandbox Code Playgroud)
如何将宏绑定到键盘快捷键: 要执行此操作,您需要转到工具 - >选项 - >环境 - >键盘.从listBox中选择带有所有默认VS东西的宏(记住它会像MyMacros.Module1.RunSelectedWithoutDebug那样),然后为它分配一个热键组合或和弦并保存.
注意:第四步是创建一个问题,并产生一个恼人的消息框说:必须停止构建才能更改解决方案属性.停止构建?好或取消.我以前常常打Ok.如果你没有任何问题,如果宏将当前选定的项目设置为启动项目,请通过将'放在行的开头处'来评论宏Prop.Value = PrevStartup的最后一行.现在消息框将不会出现.
我正在调查它,并将解决它后发布更新的宏(如果我可以:))
Sre*_*kel 16
也许这是VS 2015中的新功能,但不需要添加自定义宏 - 您可以在可添加的内容列表中找到"启动无调试"菜单项.
转到工具 - >自定义,然后按照下图显示.
我把这个宏放在一起..这是我在互联网周围发现的几个片段的组合.如果项目配置为运行默认项目输出,它将查找并运行该项目.如果它被配置为运行特定程序,它将运行该程序.此宏也不会编译您的应用程序,因此您需要确保在运行宏之前编译它.同时,这个宏不会受到上面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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21391 次 |
| 最近记录: |