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.

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

Educational Content

Bindings, Platforms, and Innovation

This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.

Orchestrating Long Running Activities with JBoss / JBPM

This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.

Neo4j - The Benefits of Graph Databases

This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.

Realistic about Risk: Software development with Real Options

This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.

Communication Flexibility Using Bindings

This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.

Writing DSLs in Groovy

After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.

Scaling Agile with C/ALM (Collaborative Application Lifecycle Management)

IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.

Concurrent Programming with Microsoft F#

Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.