当前位置: 动力学知识库 > 问答 > 编程问答 >

visual studio 2010 - How can you launch a debug session from a msbuild task?

问题描述:

The system i'm building has 4 separate applications that in production, are 4 distinct win32 services. During development I run them as 4 separate console applications. These programs need to be started in a specific order.

I do this from VS2010 by right clicking on each project and select debug > start a new instance. This works but is painfully slow.

I attempted to use run "Multiple startup projects", but they all start at the same time. Changing the start order does not help.

So, what i want to do is to use MSBuild to start each program from a build script. I attempted to use the Exec Task but the programs are not launched as debugged processes..

Since all of VS is based on msbuild, i know there must be a way to launch a project this way..

网友答案:

You can use a mix of Pre/Post build events for this. You can modify them in Project Properties -> Build Events for the last project.

Prebuild event

// Build is going to replace these files, they must not be in use  
taskkill /IM Foo.exe  
taskkill /IM Bar.exe

Postbuild event

// VsJITDebugger will ask for which debugger to attach, you can 
// choose currently active VS instance
VsJITDebugger.exe $(SolutionDir)\Foo\bin\Debug\Foo.exe  
VsJITDebugger.exe $(SolutionDir)\Bar\bin\Debug\Bar.exe

Launching debugger on each build may get bit annoying :) Better would be to use a batch script for the last project. You can do it in Project Properties -> Debug -> Start external program.

网友答案:

I did not find a solution.. I put a different hard-coded delay into each app and launched it with Debug "multiple start-up projects".. A bit of a hack but simple is better.

分享给朋友:
您可能感兴趣的文章:
随机阅读: