blogs.conchango.com

welcome to the conchango blogging site
Welcome to blogs.conchango.com Sign in | Join | Help
in Search

Stuart Preston's Blog

Mostly about Visual Studio Team System, Team Foundation Server, Engineering Practices and Application Lifecycle Management.

Using MSBuild with the Visual Studio IDE and Source Control

There are a few things that slow down development of MSBuild-based solutions with Visual Studio.  Typically MSBuild files are named with .proj, .properties or .targets extensions - so when you drag one of these files into the Visual Studio IDE there is no Intellisense.

To get around this, go to Tools > Options > Text Editor > File Extension - and associate these extensions with the "XML Editor with Encoding".

Working with MSBuild and Source Control (for example Team Foundation Server or VSS) can also be bit problematic.  MSBuild doesn't have a project file like C# (.csproj) and VB.NET (.vbproj) projects do - so typically when you need to edit an MSBuild file you need to navigate into the Source Control Explorer, check out the files you want to work on, make your changes, and then check back in using the Pending Changes window.  This is a little tedious, so on a recent plane journey back to the UK from Houston I set about making a Project Template that will make this slightly easier. 

I started with a C# project and played around with the project file in both the IDE and a text editor until it could support the following:

  • Executing an MSBuild script when pressing F5. (typically a per-user setting).
  • Having "Build.proj" set as the default file with the correct namespace to get Intellisense support.
  • Detecting changes to files in the project and automatically checking out the relevant file so it is a Pending Change.
  • Showing all files in the project (typically a per-user setting).
  • Finally, for demo purpose, integrating an example "HelloWorld" Custom Task assembly to the default MSBuild file.

The initial feedback I got internally was that it was useful, so I've decided to release the project template. 

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

 

You can optionally add the file to the Source Control of your choice (e.g. Team Foundation Server):

Here's a screenshot of the default structure with all the new files ready to check-in:

   

When you are ready to debug changes to your MSBuild file, hit F5 to execute the MSBuild script.

I personally plan to use it for the purpose of speeding up the debugging of an MSBuild custom task (by adding a Class Library project, setting that project as a dependency to my MSBuild file and setting the output of the Class Library to go to the /bin folder of my Build project).  There are a bunch of other uses for it I'm sure... if you can dream up some improvements feel free to leave a comment - contributors to the template are welcome.

Published 29 July 2007 16:29 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

 

TrackBack said:

July 29, 2007 16:57
 

Team System News said:

Eugene Zakhareyev on Adding TFS-related commands in VSIP package. Jeffrey Palermo on Managing Projects...

August 6, 2007 13:26
 

Mauricio Rojas Blog said:

One of my purposes for this year was to start using more the MSBuild Saldly I'm still not as good...

November 9, 2007 15:52
 

ayman said:

Hi

I don't do see my MSBuild after I unzipped them under the template folder as listed

can someone tell me how should configure it plz

March 15, 2008 19:54
 

Stuart.Preston said:

As I said in the post, you don't unzip them.  You don't expand it.

March 15, 2008 21:49
 

Stuart Preston's Blog said:

Last year I created an MSBuild Project Template that lets you work with Source Control (e.g. Team Foundation

March 21, 2008 18:41

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server (Personal Edition), by Telligent Systems