by DRohm
6. January 2006 07:07
If you ever need to debug your custom MSBuild tasks, I found a very cool way to do it:
- Create a test project that will use your custom MSBuild task.
- Add the appropriate code to the project file to consume the task:
<usingtask assemblyfile="D:\Development\MyTask.dll" taskname="MyCustomTask">
<target name="BeforeBuild">
<mycustomtask Foo="Bar">
</target>
- Close the test project.
- Open your custom MSBuild project.
- Right-click on the project and choose Properties.
- On the Debug tab, change the Start Action to "Start External Program" and then specify the path to the MSBuild.exe. Mine looks like this:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe
- Under Start Options, set the Working Directory to the full path of the root directory of your test project you setup in steps 1 & 2.
- Save and exit the Properties page.
To debug the task, set a breakpoint anywhere in your custom task and then start the Debugger in your custom MSBuild project. Once the debugger starts, the IDE will place you at the breakpoint where you can debug away! Very cool and very useful.