Welcome to EMC Consulting Blogs Sign in | Join | Help

Stuart Preston's Blog

Stuart was CTO for Application Consulting EMEA at EMC Consulting until October 2009, now blogging at http://stuartpreston.net

MSBuild Project Template v2.0

Last year I created an MSBuild Project Template that lets you work with Source Control (e.g. Team Foundation Server) and decent syntax highlighting by default when using MSBuild proj files.  It was fairly well received and I finally got time today to implement a couple of the suggestions that have come up in the intervening 8 months.

I've uploaded the resulting template to http://www.codeplex.com/MSBuildTemplate

The major changes are as follows:

  • The source code to a HelloWorld custom task is now included instead of the pre-built task.
  • I've changed the debugging parameters so that you can step through custom tasks by putting breakpoints in.
  • The template dynamically generates the reference to the task binary based on the ProjectName specified.

Usage is just as before, first of all download the project template from here http://www.codeplex.com/MSBuildTemplate, then drop the entire zip file into your Documents\Visual Studio 200x\Templates\ProjectTemplates folder (don't expand it!!!).  Restart Visual Studio and create a new project.  You should see the "MSBuild Project" template appear under My Templates.

image

Once you have created a new Project (and Solution if necessary), your solution will be structured like this:

 image 

Pressing F5 will compile the Custom Task and start the MSBuild.exe (v2.0) with the Build.proj as its parameter.  The custom task can be debugged directly from the IDE.  Set a breakpoint within the task and start debugging to see what I mean.

image

As before, please leave comments for improvements on this site or on the Codeplex site.

Published 21 March 2008 18:40 by Stuart.Preston

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Team System News said:

Todd Mancini on Process Guidance Center on MSDN. Stuart Preston on MSBuild Project Template v2.0. Dave...

March 25, 2008 14:23
 

Matthew said:

Hi Stuart,

is there a way to prevent the console from closing after the build is complete? As it is, it gets tedious to test build scripts for errors and I have to resort to calling a bat file from a command line to see the errors.

July 23, 2008 15:06
 

Dan Olsen said:

Excellent.  

I was looking for a template to help create a new MsBuild task... I hadn't even dreamed that I'd be able to DEBUG it too!   Thank you.

July 25, 2008 18:59
 

Steve Nuchia said:

Excellent work, sir.  Thank you very much.

October 10, 2008 13:32
 

Steve Nuchia said:

A tip:

If you change the debug command to c:\Windows\System32\cmd.exe

and move the original command to the arguments field and prefix it with /k, the console window will hang around until you close it.  I've not found a better way to see scan-time errors in the project file.

October 12, 2008 08:34

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

News

I have now left EMC Consulting and can be found at http://stuartpreston.net
Powered by Community Server (Personal Edition), by Telligent Systems