调试前运行批处理脚本 [英] Run batch script before Debugging
问题描述
我想在每次启动调试程序之前都运行一个批处理脚本.
I want to run a batch script every time before starting program for debugging.
对于构建事件,此类功能是使用构建前事件,构建后事件来实现的.
For the build events, such functionality is realized using pre-build event, post-build event.
对于实际调试,我找不到任何调试前,调试后事件.
For actual debugging, I could not find any pre-Debug, post-Debug events.
如何实现这种情况?
我正在使用VS2008,.net Framework 3.5,C#应用程序.
I am using VS2008, .net framework 3.5, c# application.
我反对在应用程序中创建一些额外的代码行来启动外部批处理文件的想法.
I am opposed to idea of creating some extra lines of code within the application that would fire-up external batch file.
推荐答案
我意识到您希望避免使用其他代码,但是在您的Main
函数中,您可以使用
I realise you wished to avoid additional code, but in your Main
function you could use Debugger.IsAttached()
to kick off your work for you.
例如:
if (Debugger.IsAttached)
{
System.Diagnostics.Process.Start(@"C:\myBatchFile.bat");
}
这篇关于调试前运行批处理脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!