Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Custom MSBuild Tasks

Custom MSBuild Tasks

This item in japanese


Since version 2.0 Microsoft has integrated MSBuild, a build system, into the .NET Framework that is fully compatible with Visual Studio projects. Bart de Smet shows how to extend MSBuild via custom tasks.

Although the set of built-in MSBuild tasks covers most of a developer's needs, some areas - especially deployment, integration of version control systems, configuration of servers and IIS web sites as well as ActiveDirectory tasks are left out. The MSBuild Community Tasks Project and the SDC Tasks Library, which are both freely available, provide many MSBuild tasks that address most of the issues in these areas. If something's still missing, you have to (and can) help yourself.

Bart de Smet shows how to create and debug custom MSBuild tasks. Whereas his first article serves as an introduction to creating custom tasks, his second article is written in a cookbook-style and focuses on debugging. According to Bart the development of a custom task is divided into 8 steps:

Step 1 - Create a Class Library project

Step 2 - Import references

Step 3 - Implement the task skeleton

Step 4 - Task parameterization

Step 5 - Implementing functionality

Step 6 - Setting up debugging

Step 7 - Set a breakpoint and run

Step 8 - Advanced debugging

Debugging is essentially configured in the custom MSBuild task's project properties: The project's start action must be set to the MSBuild executable (which should match the MSBuild assemblies referenced by the project) and the start options have to include the path to a test MSBuild project file.

The MSBuild Team blog provides further information and help, and the article "MSBuild - What It Does and What You Can Expect in the Future" by Dan Moseley and Xin Yan is a good summary of MSBuild's features, concepts, new file format features in .NET 3.5, and future directions.

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • Unit Tests ???

    by Pawel Stasiak,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Seems that somebody forgot to add appropriate steps for unit tests preparation and execution...

  • MSBuild as xm script

    by Alvaro Gareppe,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    The MSBuild Custom Tags are very useful not only to especial deployment needs... are also useful to develop complex scripts where each step could be a custom task defined by the developer i.e. I have developed task to verify table data in automatic tests.

    You could use msbuilds and custom tags to develop specific scripts, where each action is develop by yourself, and the script flow is defined by the msbuild xml.

    Some information about msbuild for Spanish-speaking:

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p