Off lately, MSBuild Tasks are becoming more and more popular. One obvious reason is that things can be implemented real fast. For instance, if one needs to check the existence of a directory in a project in a solution, and then take some action based on its existence, there is no need to write a 100 line to first use the EnvDTE80 ‘s DTE2 interface to get the project and then find directory and take action. The same can be done using MSBuild Task quite easily.
Debugging MSBuild Tasks seems tricky. Here is how to debug a custom tasak:-
- Create a test project to debug your task in.
- Edit the *.csproj/*.vsproj to add in the necessary MSBuild XML to make use of the task.
- Close the test project.
- Open the custom task project.
- Right click on the project and select “Properties”.
- In the new window that opens, click on the “Debug” tab.
- Change the start action to “Start External Program” and put the full path to MSBuild as the name of the program.
- In the arguments text box, enter the full path to the test project (created above).
- Save and close the property window.
Now it is possible to put a breakpoint on the Execute() method of the custom task and debug.