InfoQ

News

Custom MSBuild Tasks

Posted by Hartmut Wilms on Feb 21, 2008 02:30 PM

Community
.NET
Topics
.NET Framework

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.

2 comments

Reply

Unit Tests ??? by Pawel Stasiak Posted Feb 22, 2008 9:00 AM
MSBuild as xm script by Alvaro Gareppe Posted Feb 22, 2008 9:45 AM
  1. Back to top

    Unit Tests ???

    Feb 22, 2008 9:00 AM by Pawel Stasiak

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

  2. Back to top

    MSBuild as xm script

    Feb 22, 2008 9:45 AM by Alvaro Gareppe

    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: http://allyoucaneatin30.blogspot.com/2008/02/msbuild-technology-i.html

Exclusive Content

Business Natural Languages Development in Ruby

Jay Fields presents his concept of Business Natural Languages - a type of Domain Specific Languages geared towards being readable by domain experts.

Distributed Version Control Systems: A Not-So-Quick Guide Through

Adoption and interest for Distributed Version Control Systems is constantly rising. We will introduce the concept of DVCS and have a look at 3 actors in the area: git, Mercurial and Bazaar.

Segundo Velasquez and Agile as Seen Through the Customer's Eyes

Deborah Hartmann interviewed Segundo Velasquez about his experience as customer with an Agile team during the initial phase of software design of a product.

Fine Grained Versioning with ClickOnce

David Cooksey shows how to fine grained versioning to a ClickOnce deployment using an HttpHandler written with ASP.NET, making partial rollouts to a test audience much easier.

Implementing Manual Activities in Windows Workflow

Windows workflow (WF) is an excellent framework for implementing business processes, but lacks support for human activities. This article describes a completely generic approach for changing this.

Markus Voelter about Software Architecture Documentation

In this interview taken during OOPSLA 2007, Markus Voelter talks about the importance of documenting the software architecture, and gives some good and also bad examples on how it could be done.

Voca, UK's largest payment processing engine running Spring

William Soo and Meeraj Kunnumpurath discuss the Voca transaction processing system, architectural challenges and requirements, Voca's Spring/J2EE architecture, and the future SEPA architecture.

Patterns for securing architectures

Security is about trade-offs. Only a few have the expertise to design good security. This talk focuses on Security Patterns, such as Role-based Access Control, Single Access Point, and Front Door.