<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="http://www.codeplex.com/rss.xsl"?><rss version="2.0"><channel><title>msbuildshellex Wiki &amp; Documentation Rss Feed</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home</link><description>msbuildshellex Wiki Rss Description</description><item><title>Updated Wiki: Home</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;version=56</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Home&lt;/i&gt; &lt;img src="http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=Home"&gt;Screenshots&lt;/a&gt; &lt;img src="http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=Home"&gt;Manual&lt;/a&gt; &lt;img src="http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;amp;referringTitle=Home"&gt;MSBuild Tutorial&lt;/a&gt; &lt;img src="http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=Home"&gt;Donations&lt;/a&gt; &lt;img src="http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=Home"&gt;Search&lt;/a&gt; &lt;img src="http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=Home"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
Project Description
&lt;/h1&gt;MSBuildShellExtension lets you build .NET projects without ever opening Visual Studio or the command prompt. MSBuild targets can be executed from your favourite file system tool like Windows Explorer or Total Commander. The possibility to extend MSBuildShellExtension with your own targets and editors, makes it a very flexible and useful tool for all .NET developers.
&lt;br /&gt; &lt;br /&gt;&lt;img src="http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=11552" alt="msbuildshellex.gif" /&gt;&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
News
&lt;/h2&gt;&lt;b&gt;November 5, 2008&lt;/b&gt;&lt;br /&gt; &lt;br /&gt;Which new features would you like to see in MSBuildShellExtension? Comment this page or create a new discussion/issue. &lt;br /&gt; &lt;br /&gt;&lt;b&gt;May 9, 2008&lt;/b&gt;&lt;br /&gt;As you propably noticed, I haven't had a lot of time updating this site or the project recently. This is caused by:&lt;br /&gt; &lt;br /&gt;1. I use MSBuildShellExtension each day, and it works pretty good already.&lt;br /&gt;2. I'm working on a lot of other ideas.&lt;br /&gt;3. I do a lot of UI code at my job, so it isn't really that fun coding UI in my sparetime.&lt;br /&gt;4. The weather is GREAT in Denmark right now!&lt;br /&gt; &lt;br /&gt;So if any of you guys wan't to help extending MSBuildShellExtension in the future, please send me a mail.&lt;br /&gt; &lt;br /&gt;&lt;b&gt;March 1, 2008 - MSBuildShellExtension 1.1.2&lt;/b&gt;&lt;br /&gt;A new bugfix release has seen the light of day. Actually this small update contains more than meets the eye. Among other new features, .NET 3.5 is now supported!&lt;br /&gt; &lt;br /&gt;&lt;b&gt;November 25, 2007 - Msbuildshellextension 1.1.1&lt;/b&gt;&lt;br /&gt;The 1.1.1 release is out. This release contains some bugfixes on the 1.1.0 release as well as some minor changes.&lt;br /&gt; &lt;br /&gt;&lt;b&gt;November 14, 2007 - Msbuildshellextension 1.1.0&lt;/b&gt;&lt;br /&gt;The 1.1.0 is out of beta! Remember to uninstall your existing version of MSBuildShellExtension before installing, due to the change of installer technology. Happy building!&lt;br /&gt; &lt;br /&gt;&lt;b&gt;November 07, 2007 - Msbuildshellextension 1.1.0 Beta1&lt;/b&gt;&lt;br /&gt;The 1.1.0 release of MSBuildShellExtension will arrive shortly. Until then, download and try the beta! Please report any bugs at http://www.codeplex.com/msbuildshellex. Happy testing!&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Wed, 05 Nov 2008 07:10:46 GMT</pubDate><guid isPermaLink="false">Updated Wiki: Home 20081105071046A</guid></item><item><title>Updated Wiki: MSBuild Tutorial</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild Tutorial&amp;version=19</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Manual&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;i&gt;MSBuild Tutorial&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
MSBuild Tutorial
&lt;/h1&gt;This page gives a short introduction to the MSBuild tool. The tutorial is protected under copyright law and may not be published without permission from the MSBuildShellExtension coordinators at the CodePlex site.&lt;br /&gt; &lt;br /&gt;&lt;i&gt;Thanks to Joe Wass for correcting my bad english :o)&lt;/i&gt;&lt;br /&gt;&lt;h2&gt;
Table of Contents
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#MSBuild%20Basics"&gt;MSBuild Basics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Properties"&gt;Properties&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Items"&gt;Items&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Conditions"&gt;Conditions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Frequently%20Used%20Tasks"&gt;Frequently Used Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Custom%20MSBuild%20Tasks"&gt;Custom MSBuild Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Generic%20Targets"&gt;Generic Targets&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Links"&gt;Links&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;a name="MSBuild Basics"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
MSBuild Basics
&lt;/h2&gt;.NET 2.0 contains a new tool called MSBuild. MSBuild is primarily used to build .NET applications, but can be used for other types of applications as well. From Windows Vista, MSBuild is distributed with Windows itself, making it a strong platform for implementing scripted application on non-developer PCs as well.&lt;br /&gt; &lt;br /&gt;Before .NET 2.0, application were built by one or more of these strategies:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Using the build menu from inside Visual Studio&lt;/li&gt;&lt;li&gt;Using the devenv.exe process from the command line with some extra parameters&lt;/li&gt;&lt;li&gt;Using a third-party tool like NAnt (which MSBuild is based on)&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;The drawback with the first two strategies was that it was hard to script. The drawback with the third solution was that two build environments had to be held in sync and maintained. .NET 2.0 Visual Studio projects are now implemented in the MSBuild language, but MSBuild has no dependencies on Visual Studio itself. MSBuild can in theory be implemented in files with any extension but a number of formats seem to be the supported standard from Microsoft: csproj, vbproj, vcproj, vjsproj, proj, .targets. The first four are different types of project files for Visual Studio, while the last two are new extensions which are either written by hand or with a tool knowing the MSBuild syntax. A few tools exist for this purpose. My personal opinion is that building in xml editor in Visual Studio is quite good for this purpose. A repeating question among MSBuild developers is if you should extend the files generated by visual studio with new stuff or whether you should write your own containing your home-made MSBuild scripts. My personal opinion is to let Visual Studio generate its own projects (example: csproj files) and create your home-made scripts in a .proj file with the same name as the project. I usually start the .proj file by implementing the three targets: Clean, Build and Rebuild, which basically just calls the similar targets in the .csproj file. This way you avoid updating an auto-generated file which you don't have control over.&lt;br /&gt; &lt;br /&gt;An MSBuild file is implemented in XML. The root element of an MSBuild XML file will always be a project containing target elements. It is possible to run multiple targets in a MSBuild file. When the MSBuild script is started from the command line, it takes a build file as parameter as well as the names of the targets, which should be executed.&lt;br /&gt; &lt;br /&gt;A target is implemented as a sequential list of tasks. The tasks are executed in the order in which they are specified beneath the target element. Both targets and tasks can be dependant on each other.&lt;br /&gt; &lt;br /&gt;This is an example of a very simple build file to build a .NET project:&lt;br /&gt; &lt;br /&gt;&lt;div style="color:#000000;background-color:#FFFFFF;"&gt;&lt;pre&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#A31515;"&gt;xml&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;version&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;encoding&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;?&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;xmlns&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Message&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Text&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Building msbuildintro&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MSBuild&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Projects&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;msbuildintro.csproj&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Targets&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt; &lt;br /&gt;The example defines a project with the MSBuild namespace. Using the namespace helps you develop the build file in Visual Studio using Intellisense. The build file contains a single target named Build. This target contains two tasks: Message and MSBuild. Message outputs a message to the console and is used primarily for debug purposes. MSBuild runs a configurable number of targets on another build file. Because the .csproj file is also implemented in MSBuild we are able to call targets in the build file from the example build file. In this case we call the target Build in the .csproj file. All projects generated by Visual Studio automatically implements the Clean, Build and Rebuild  targets. These targets are actually executed when you select the similar commands in the Build menu from within Visual Studio.&lt;br /&gt;&lt;a name="Properties"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Properties
&lt;/h2&gt;To be able to parameterise a build script, MSBuild has implemented properties. A property is a simple key/value type, which can be used from multiple locations in the scripts. Let's look at an example using properties:&lt;br /&gt; &lt;br /&gt;&lt;div style="color:#000000;background-color:#FFFFFF;"&gt;&lt;pre&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#A31515;"&gt;xml&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;version&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;encoding&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;?&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;xmlns&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MyReleaseOutput&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;.\release&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MyReleaseOutput&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Message&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Text&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Building msbuildintro&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MSBuild&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Projects&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;msbuildintro.csproj&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Targets&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Release&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;DependsOnTargets&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MakeDir&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Directories&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;$(MyReleaseOutput)&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Copy&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;SourceFiles&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;.\bin\debug\msbuildintro.exe&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;DestinationFolder&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;$(MyReleaseOutput)&amp;quot;&lt;/span&gt;  &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt; &lt;br /&gt;The example defines a property defined in a property group. Properties can be defined both outside and inside scope of a target. When a property is defined like in this example, the value of the property is assigned before executing the actual targets. In the example I define a property called MyReleaseOutput and add the value .\release. In this example I have added two targets as well: Build and Release. The Build target is similar to the one specified in the previous example, while the Release target is new. The Release target introduces a new attribute called DependsOnTargets, which is the way to define dependencies between targets in MSBuild. In this case we tell MSBuild to run the Build target before running the Release targets. If you run the Build target manually before running the Release target, the Build target is run only once.&lt;br /&gt; &lt;br /&gt;The release target introduces two new tasks as well: MakeDir which (well you guessed it) creates a new directory and Copy, which copies on or more files from A to B. MakeDir contains a single attribute, defining the path of the new directory.&lt;br /&gt;In this example that path is the value of the MyReleaseOutput property. Notice the use of the $(propertyname) syntax here. $() is used to reference properties in MSBuild. The copy task in our example points out a single file and the destination folder where this file should be copied to, when executing the Release target. The $(MyReleaseOutput) used is again replaced by the value of this property.&lt;br /&gt;&lt;a name="Items"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Items
&lt;/h2&gt;The example above copied a single file from one directory to another. This can certainly be useful in many situations but sometimes this is simply not flexible enough. This is were items comes in. An item gives the possibility of creating dynamic lists of, for instance, file names. Let's start by looking at an example:&lt;br /&gt; &lt;br /&gt;&lt;div style="color:#000000;background-color:#FFFFFF;"&gt;&lt;pre&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#A31515;"&gt;xml&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;version&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;encoding&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;?&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;xmlns&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MyReleaseOutput&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;.\release&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MyReleaseOutput&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;ItemGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MyReleaseFiles&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Include&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;.\bin\debug\*.*&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;ItemGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Message&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Text&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Building msbuildintro&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MSBuild&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Projects&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;msbuildintro.csproj&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Targets&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Release&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;DependsOnTargets&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MakeDir&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Directories&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;$(MyReleaseOutput)&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Copy&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;SourceFiles&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;@(MyReleaseFiles)&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;DestinationFolder&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;$(MyReleaseOutput)&amp;quot;&lt;/span&gt;  &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt; &lt;br /&gt;We start by defining an ItemGroup outer scope of a target. This means that the content is calculated before actually running any targets. In this example I define an ItemGroup containing a single item called MyReleaseFiles. The item contains a single attribute called Include, which acts as a filter for the generated file list: in this case, all files beneath the bin\debug directory. I use this item in the copy task beneath the Release target to indicate which files should be copied when doing a release.&lt;br /&gt; &lt;br /&gt;The Include filter decides which file to include. We also have the possibility to specify an Exclude filter. The following example shows how:&lt;br /&gt; &lt;br /&gt;&lt;div style="color:#000000;background-color:#FFFFFF;"&gt;&lt;pre&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#A31515;"&gt;xml&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;version&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;encoding&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;?&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;xmlns&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MyReleaseOutput&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;.\release&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MyReleaseOutput&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;ItemGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MyReleaseFiles&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Include&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;.\bin\debug\*.*&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Exclude&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;.\bin\debug\*vshost.exe&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;ItemGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Message&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Text&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Building msbuildintro&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MSBuild&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Projects&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;msbuildintro.csproj&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Targets&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Release&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;DependsOnTargets&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MakeDir&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Directories&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;$(MyReleaseOutput)&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Copy&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;SourceFiles&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;@(MyReleaseFiles)&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;DestinationFolder&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;$(MyReleaseOutput)&amp;quot;&lt;/span&gt;  &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt; &lt;br /&gt;I added an Exlude attribute to my MyReleaseFiles item. The exclude in this examples excludes all files beneath the bin\debug directory which end in vshost.exe. An item containing both Include and Exclude will be generated by taking all the files specified in the Include and subtracting the files specified in the Exlude.&lt;br /&gt; &lt;br /&gt;The last two examples of using items are actually not that useful because the content for the MyReleaseFiles item is generated before running the actual targets. On a new checkout or after a clean, no files exist in the bin\debug directory meaning that the generated file list will therefore be completely empty. Bummer! Let us fix the example. We define a new item inside the scope of a target instead:&lt;br /&gt; &lt;br /&gt;&lt;div style="color:#000000;background-color:#FFFFFF;"&gt;&lt;pre&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#A31515;"&gt;xml&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;version&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;encoding&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;?&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;xmlns&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MyReleaseOutput&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;.\release&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MyReleaseOutput&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Message&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Text&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Building msbuildintro&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MSBuild&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Projects&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;msbuildintro.csproj&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Targets&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Release&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;DependsOnTargets&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MakeDir&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Directories&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;$(MyReleaseOutput)&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;CreateItem&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Include&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;.\bin\debug\*.*&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Exclude&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;.\bin\debug\*vshost.exe&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
      &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Output&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;TaskParameter&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Include&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;ItemName&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;MyReleaseFiles&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;CreateItem&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Copy&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;SourceFiles&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;@(MyReleaseFiles)&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;DestinationFolder&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;$(MyReleaseOutput)&amp;quot;&lt;/span&gt;  &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt; &lt;br /&gt;I moved the MyReleaseOutput item inside the Release target. This is done using the CreateItem task. The CreateItem task creates a new item on the fly which means that the content is generated at the point in time when the CreateItem task is executed. Notice that the CreateItem task contains an Output element. The Output element is used in a lot of different places in MSBuild where a target is able to output some data. In this case is use the ItemName attribute to define the name from the previous example.&lt;br /&gt; &lt;br /&gt;Anyone still reading? If you have read this far, you derserve a little prize:&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20133" alt="dilbert2002444471010.gif" /&gt;&lt;br /&gt;&lt;a name="Conditions"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Conditions
&lt;/h2&gt;Besides the CreateItem task in a previous example, our build scripts have been very static until now. This can be sufficient for a lot of projects but sometimes you need slightly more flexible build scripts. A feature for fulfilling this in MSBuild is called Conditions. A condition in MSBuild is not that different to a condition in other software languages. It is a possibile, for instance, to make more flexible structures to avoid running targets and/or tasks when certain conditions are met. You can define conditions on all targets and almost all tasks. Lets check out another example:&lt;br /&gt; &lt;br /&gt;&lt;div style="color:#000000;background-color:#FFFFFF;"&gt;&lt;pre&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#A31515;"&gt;xml&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;version&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;encoding&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;?&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;xmlns&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MyReleaseOutput&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;.\release&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MyReleaseOutput&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Configuration&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Condition&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot; '$(Configuration)' == '' &amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;Debug&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Configuration&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Message&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Text&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Building msbuildintro $(Configuration)&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MSBuild&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Projects&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;msbuildintro.csproj&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Targets&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Release&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;DependsOnTargets&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Build&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Condition&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;$(Configuration) == 'Release'&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MakeDir&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Directories&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;$(MyReleaseOutput)&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;CreateItem&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Include&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;.\bin\$(Configuration)\*.*&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Exclude&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;.\bin\$(Configuration)\*vshost.exe&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
      &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Output&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;TaskParameter&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Include&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;ItemName&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;MyReleaseFiles&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;CreateItem&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Copy&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;SourceFiles&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;@(MyReleaseFiles)&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;DestinationFolder&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;$(MyReleaseOutput)&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt; &lt;br /&gt;I added a lot of new stuff here. But of course you are already quite an MSBuild expert, so I think you will manage. First of all, I have added a new property named Configuration. This property contains a condition attribute, which determines the value of the property at runtime. If the Configuration property has not been set upfront, the value of the attribute is set to Debug. Properties can be set upfront by using a special syntax on the command line:&lt;br /&gt; &lt;br /&gt;&lt;span class="codeInline"&gt; Msbuild.exe build.proj /p:Configuration=Debug /t:release &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;More new stuff. I changed all references to the debug, with the value of the new Configuration property. This means that I am now able to run the script in both Debug and Release mode.&lt;br /&gt; &lt;br /&gt;The last new addition is the condition attribute on the release target. This condition examines if the value of the Configuration property is Release and only allows execution of the Release target if this condition is true.&lt;br /&gt;&lt;a name="Frequently Used Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Frequently Used Tasks
&lt;/h2&gt;CallTarget – Executes another target inside the current build file. Used where a target needs to call another target at a specific place inside the target itself. If the target were just dependant on the other target being executed, we would use the DependsOnTargets attribute instead.&lt;br /&gt; &lt;br /&gt;Copy – We already saw this task in action. Copies one or more files from A to B.&lt;br /&gt; &lt;br /&gt;CreateItem – Create dynamic items.&lt;br /&gt; &lt;br /&gt;CreateProperty – Create dynamic properties.&lt;br /&gt; &lt;br /&gt;Delete – Deletes on or more files.&lt;br /&gt; &lt;br /&gt;Exec – Executes an external process. This is typically used to executed external tools, which did not implement MSBuild targets themself.&lt;br /&gt; &lt;br /&gt;MakeDir – Creates one or more directories.&lt;br /&gt; &lt;br /&gt;Message – Outputs a message to the console.&lt;br /&gt; &lt;br /&gt;MSBuild – Executes one or more targets in an external MSBuild file.&lt;br /&gt; &lt;br /&gt;RemoveDir – Removes one or more directories.&lt;br /&gt; &lt;br /&gt;And there are a lot more.&lt;br /&gt;&lt;a name="Custom MSBuild Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Custom MSBuild Tasks
&lt;/h2&gt;It is possible to write your own MSBuild tasks. This can be extremely useful if you want to integrate some of your own tools with MSBuild or if you need to do stuff which is not yet supported by MSBuild. The following example shows how to write a simple addition task:&lt;br /&gt; &lt;br /&gt;&lt;div style="color:#000000;background-color:#FFFFFF;"&gt;&lt;pre&gt;
&lt;span style="color:#0000FF;"&gt;using&lt;/span&gt; System;
&lt;span style="color:#0000FF;"&gt;using&lt;/span&gt; Microsoft.Build.Utilities;
&lt;span style="color:#0000FF;"&gt;using&lt;/span&gt; Microsoft.Build.Framework;
&lt;span style="color:#0000FF;"&gt;namespace&lt;/span&gt; MyTasks
{
  &lt;span style="color:#0000FF;"&gt;public&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;class&lt;/span&gt; AddTask : Task
  {
    &lt;span style="color:#0000FF;"&gt;private&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;int&lt;/span&gt; number1;
    [Required]
    &lt;span style="color:#0000FF;"&gt;public&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;int&lt;/span&gt; Number1
    {
      get { &lt;span style="color:#0000FF;"&gt;return&lt;/span&gt; number1; }
      set { number1 = value; }
    }
    &lt;span style="color:#0000FF;"&gt;private&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;int&lt;/span&gt; number2;
    [Required]
    &lt;span style="color:#0000FF;"&gt;public&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;int&lt;/span&gt; Number2
    {
      get { &lt;span style="color:#0000FF;"&gt;return&lt;/span&gt; number2; }
      set { number2 = value; }
    }
    &lt;span style="color:#0000FF;"&gt;private&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;int&lt;/span&gt; sum;
    [Output]
    &lt;span style="color:#0000FF;"&gt;public&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;int&lt;/span&gt; Sum
    {
      get { &lt;span style="color:#0000FF;"&gt;return&lt;/span&gt; sum; }
      set { sum = value; }
    }
    &lt;span style="color:#0000FF;"&gt;public&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;override&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;bool&lt;/span&gt; Execute()
    {
      &lt;span style="color:#0000FF;"&gt;try&lt;/span&gt;
      {
        sum = number1 + number2;
      }
      &lt;span style="color:#0000FF;"&gt;catch&lt;/span&gt; (ArithmeticException e)
      {
        Console.WriteLine(&lt;span style="color:#A31515;"&gt;&amp;quot;Error occured during addition: {0}&amp;quot;&lt;/span&gt;, e.Message);
        &lt;span style="color:#0000FF;"&gt;return&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;false&lt;/span&gt;;
      }
      &lt;span style="color:#0000FF;"&gt;return&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;true&lt;/span&gt;;
    }
  }
}
&lt;/pre&gt;&lt;/div&gt; &lt;br /&gt;I start by defining the AddTask class which extends the Task class from the MSBuild API. By extending this task, I don't need to worry about implementing conditions etc.&lt;br /&gt;I defined two properties which act as input variables to the addition task: Number1 and Number2. Both properties are marked with the Required attribute which tells the script to fail if they are not specified. An output property is added as well. The value of this property will be available  within the build script. Let's see how to use this new and fancy task:&lt;br /&gt; &lt;br /&gt;&lt;div style="color:#000000;background-color:#FFFFFF;"&gt;&lt;pre&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#A31515;"&gt;xml&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;version&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;encoding&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;?&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;xmlns&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;UsingTask&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;TaskName&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;MyTasks.AddTask&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;AssemblyFile&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;.\AddTask.dll&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Addition&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;AddTask&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Number1&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;10&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Number2&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;12&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
      &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Output&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;TaskParameter&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Sum&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;PropertyName&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;CalculatedSum&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;AddTask&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Message&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Text&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;10 + 12 = $(CalculatedSum)&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt; &lt;br /&gt;Because my AddTask in an external task not built into the MSBuild framework, I use the UsingTask element to reference it. The name of the task as well as the assembly name is specified.&lt;br /&gt; &lt;br /&gt;The Addition target uses the AddTask with the two Number properties as attributes. The Output element copies the result of the task to a property called CalculatedSum. This property is accessible in the Message task for output on the console.&lt;br /&gt; &lt;br /&gt;You just implemented your first custom MSBuild task. Pretty easy, right?&lt;br /&gt;&lt;a name="Generic Targets"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Generic Targets
&lt;/h2&gt;Once in a while a question pops up in different forums: How do I parameterize a common part of my script, making it possible to use it from different targets? This is a great question. We don't want to have the same lines of code  spread around our build script, making it longer than necessary and complex to maintain. MSBuild provides the CallTarget task, which executes another target inside the current build file. Unfortunately there is no way to  parameterize the CallTarget task, making it unusable for anything other than simple situations where needed tasks are 100% identical.&lt;br /&gt; &lt;br /&gt;Let's look at and example where we have two targets with some identical tasks:&lt;br /&gt; &lt;br /&gt;&lt;div style="color:#000000;background-color:#FFFFFF;"&gt;&lt;pre&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#A31515;"&gt;xml&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;version&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;encoding&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;?&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;xmlns&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Target1&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Message&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Text&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Hello World from Target1&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Target2&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Message&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Text&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Hello World from Target2&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt; &lt;br /&gt;In the example we define two targets: Target1 and Target2. You will probably notice that the targets look very similar. The only difference is the text inside the Message task. This is a simple example of the problem and of course changing the text in both message tasks would be fairly simple. But you probably understand the problem here: It would be nice to refactor the targets (let's call it &amp;quot;Extract Target&amp;quot;), so that the Hello World text will only be specified once. First of all we need to move the common tasks to a new target:&lt;br /&gt; &lt;br /&gt;&lt;div style="color:#000000;background-color:#FFFFFF;"&gt;&lt;pre&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;PrintMessage&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Message&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Text&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Hello World from X&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt; &lt;br /&gt;Note that the replaced part of the Text with the X. Now we need to call this target, making sure that X will be replaced with the correct string. For this purpose we use another task called MSBuild. The MSBuild task was originally produced to be able to call targets inside other MSBuild scripts. The great thing about the MSBuild task is that it has the capability to receive properties. In order to call our PrintMessage target and print the correct string, we parameterize the target like this:&lt;br /&gt; &lt;br /&gt;&lt;div style="color:#000000;background-color:#FFFFFF;"&gt;&lt;pre&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#A31515;"&gt;xml&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;version&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;encoding&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;?&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;xmlns&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Target1&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MSBuild&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Projects&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;$(MSBuildProjectFile)&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Targets&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;PrintMessage&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Properties&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Caller=Target1&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Target2&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;MSBuild&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Projects&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;$(MSBuildProjectFile)&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Targets&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;PrintMessage&amp;quot;&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Properties&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Caller=Target2&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Name&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;PrintMessage&amp;quot;&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:#0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Message&lt;/span&gt; &lt;span style="color:#FF0000;"&gt;Text&lt;/span&gt;=&lt;span style="color:#0000FF;"&gt;&amp;quot;Hello World from $(Caller)&amp;quot;&lt;/span&gt; &lt;span style="color:#0000FF;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color:#0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000FF;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt; &lt;br /&gt;We use the MSBuild tasks in both Target1 and Target2. The $(MSBuildProjectFile) is a built-in property in MSBuild, which returns the filename of the current build file. What we do here is that we call the PrintMessage task on this. The properties attribute specify a single property named Caller. Multiple properties can be specified inside this attribute by separating them with a semicolon. In the PrintMessage task we simply print the message with the Caller property specified inside the Text attribute.&lt;br /&gt;&lt;a name="Links"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Links
&lt;/h2&gt;The MSBuild documentation is actually quite good and a must for all serious MSBuild developers: &lt;a href="http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx" class="externalLink"&gt;http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;A lot of different tools for handling MSBuild files exist. I haven't been able to find a tool that makes it possible to run build scripts from within Visual Studio. You could start by installing the MSBuildShellExtension tool from: &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;MSBuildShellExtension&lt;/a&gt;.&lt;br /&gt; &lt;br /&gt;Besides the build in tasks in MSBuild, there is a great community project, implementing a lot of nice tasks not implemented by Microsoft. Targets for search and replace, zipping, sending out mails, modifying subversion etc., can be found here: &lt;a href="http://msbuildtasks.tigris.org/" class="externalLink"&gt;http://msbuildtasks.tigris.org/&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Fri, 03 Oct 2008 10:19:22 GMT</pubDate><guid isPermaLink="false">Updated Wiki: MSBuild Tutorial 20081003101922A</guid></item><item><title>Updated Wiki: MSBuild Tutorial</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild Tutorial&amp;version=18</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Manual&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;i&gt;MSBuild Tutorial&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
MSBuild Tutorial
&lt;/h1&gt;This page gives a short introduction to the MSBuild tool. The tutorial is protected under copyright law and may not be published without permission from the MSBuildShellExtension coordinators at the CodePlex site.&lt;br /&gt; &lt;br /&gt;&lt;i&gt;Thanks to Joe Wass for correcting my bad english :o)&lt;/i&gt;&lt;br /&gt;&lt;h2&gt;
Table of Contents
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#MSBuild%20Basics"&gt;MSBuild Basics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Properties"&gt;Properties&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Items"&gt;Items&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Conditions"&gt;Conditions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Frequently%20Used%20Tasks"&gt;Frequently Used Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Custom%20MSBuild%20Tasks"&gt;Custom MSBuild Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Generic%20Targets"&gt;Generic Targets&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Links"&gt;Links&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;a name="MSBuild Basics"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
MSBuild Basics
&lt;/h2&gt;.NET 2.0 contains a new tool called MSBuild. MSBuild is primarily used to build .NET applications, but can be used for other types of applications as well. From Windows Vista, MSBuild is distributed with Windows itself, making it a strong platform for implementing scripted application on non-developer PCs as well.&lt;br /&gt; &lt;br /&gt;Before .NET 2.0, application were built by one or more of these strategies:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Using the build menu from inside Visual Studio&lt;/li&gt;&lt;li&gt;Using the devenv.exe process from the command line with some extra parameters&lt;/li&gt;&lt;li&gt;Using a third-party tool like NAnt (which MSBuild is based on)&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;The drawback with the first two strategies was that it was hard to script. The drawback with the third solution was that two build environments had to be held in sync and maintained. .NET 2.0 Visual Studio projects are now implemented in the MSBuild language, but MSBuild has no dependencies on Visual Studio itself. MSBuild can in theory be implemented in files with any extension but a number of formats seem to be the supported standard from Microsoft: csproj, vbproj, vcproj, vjsproj, proj, .targets. The first four are different types of project files for Visual Studio, while the last two are new extensions which are either written by hand or with a tool knowing the MSBuild syntax. A few tools exist for this purpose. My personal opinion is that building in xml editor in Visual Studio is quite good for this purpose. A repeating question among MSBuild developers is if you should extend the files generated by visual studio with new stuff or whether you should write your own containing your home-made MSBuild scripts. My personal opinion is to let Visual Studio generate its own projects (example: csproj files) and create your home-made scripts in a .proj file with the same name as the project. I usually start the .proj file by implementing the three targets: Clean, Build and Rebuild, which basically just calls the similar targets in the .csproj file. This way you avoid updating an auto-generated file which you don't have control over.&lt;br /&gt; &lt;br /&gt;An MSBuild file is implemented in XML. The root element of an MSBuild XML file will always be a project containing target elements. It is possible to run multiple targets in a MSBuild file. When the MSBuild script is started from the command line, it takes a build file as parameter as well as the names of the targets, which should be executed.&lt;br /&gt; &lt;br /&gt;A target is implemented as a sequential list of tasks. The tasks are executed in the order in which they are specified beneath the target element. Both targets and tasks can be dependant on each other.&lt;br /&gt; &lt;br /&gt;This is an example of a very simple build file to build a .NET project:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;The example defines a project with the MSBuild namespace. Using the namespace helps you develop the build file in Visual Studio using Intellisense. The build file contains a single target named Build. This target contains two tasks: Message and MSBuild. Message outputs a message to the console and is used primarily for debug purposes. MSBuild runs a configurable number of targets on another build file. Because the .csproj file is also implemented in MSBuild we are able to call targets in the build file from the example build file. In this case we call the target Build in the .csproj file. All projects generated by Visual Studio automatically implements the Clean, Build and Rebuild  targets. These targets are actually executed when you select the similar commands in the Build menu from within Visual Studio.&lt;br /&gt;&lt;a name="Properties"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Properties
&lt;/h2&gt;To be able to parameterise a build script, MSBuild has implemented properties. A property is a simple key/value type, which can be used from multiple locations in the scripts. Let's look at an example using properties:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;.\bin\debug\msbuildintro.exe&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;The example defines a property defined in a property group. Properties can be defined both outside and inside scope of a target. When a property is defined like in this example, the value of the property is assigned before executing the actual targets. In the example I define a property called MyReleaseOutput and add the value .\release. In this example I have added two targets as well: Build and Release. The Build target is similar to the one specified in the previous example, while the Release target is new. The Release target introduces a new attribute called DependsOnTargets, which is the way to define dependencies between targets in MSBuild. In this case we tell MSBuild to run the Build target before running the Release targets. If you run the Build target manually before running the Release target, the Build target is run only once.&lt;br /&gt; &lt;br /&gt;The release target introduces two new tasks as well: MakeDir which (well you guessed it) creates a new directory and Copy, which copies on or more files from A to B. MakeDir contains a single attribute, defining the path of the new directory.&lt;br /&gt;In this example that path is the value of the MyReleaseOutput property. Notice the use of the $(propertyname) syntax here. $() is used to reference properties in MSBuild. The copy task in our example points out a single file and the destination folder where this file should be copied to, when executing the Release target. The $(MyReleaseOutput) used is again replaced by the value of this property.&lt;br /&gt;&lt;a name="Items"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Items
&lt;/h2&gt;The example above copied a single file from one directory to another. This can certainly be useful in many situations but sometimes this is simply not flexible enough. This is were items comes in. An item gives the possibility of creating dynamic lists of, for instance, file names. Let's start by looking at an example:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;MyReleaseFiles Include=&amp;quot;.\bin\debug\*.*&amp;quot; /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;We start by defining an ItemGroup outer scope of a target. This means that the content is calculated before actually running any targets. In this example I define an ItemGroup containing a single item called MyReleaseFiles. The item contains a single attribute called Include, which acts as a filter for the generated file list: in this case, all files beneath the bin\debug directory. I use this item in the copy task beneath the Release target to indicate which files should be copied when doing a release.&lt;br /&gt; &lt;br /&gt;The Include filter decides which file to include. We also have the possibility to specify an Exclude filter. The following example shows how:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;MyReleaseFiles Include=&amp;quot;.\bin\debug\*.*&amp;quot; Exclude=&amp;quot;.\bin\debug\*vshost.exe&amp;quot; /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;I added an Exlude attribute to my MyReleaseFiles item. The exclude in this examples excludes all files beneath the bin\debug directory which end in vshost.exe. An item containing both Include and Exclude will be generated by taking all the files specified in the Include and subtracting the files specified in the Exlude.&lt;br /&gt; &lt;br /&gt;The last two examples of using items are actually not that useful because the content for the MyReleaseFiles item is generated before running the actual targets. On a new checkout or after a clean, no files exist in the bin\debug directory meaning that the generated file list will therefore be completely empty. Bummer! Let us fix the example. We define a new item inside the scope of a target instead:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;CreateItem Include=&amp;quot;.\bin\debug\*.*&amp;quot; Exclude=&amp;quot;.\bin\debug\*vshost.exe&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Include&amp;quot; ItemName=&amp;quot;MyReleaseFiles&amp;quot;/&amp;gt;
    &amp;lt;/CreateItem&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;I moved the MyReleaseOutput item inside the Release target. This is done using the CreateItem task. The CreateItem task creates a new item on the fly which means that the content is generated at the point in time when the CreateItem task is executed. Notice that the CreateItem task contains an Output element. The Output element is used in a lot of different places in MSBuild where a target is able to output some data. In this case is use the ItemName attribute to define the name from the previous example.&lt;br /&gt; &lt;br /&gt;Anyone still reading? If you have read this far, you derserve a little prize:&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20133" alt="dilbert2002444471010.gif" /&gt;&lt;br /&gt;&lt;a name="Conditions"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Conditions
&lt;/h2&gt;Besides the CreateItem task in a previous example, our build scripts have been very static until now. This can be sufficient for a lot of projects but sometimes you need slightly more flexible build scripts. A feature for fulfilling this in MSBuild is called Conditions. A condition in MSBuild is not that different to a condition in other software languages. It is a possibile, for instance, to make more flexible structures to avoid running targets and/or tasks when certain conditions are met. You can define conditions on all targets and almost all tasks. Lets check out another example:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
    &amp;lt;Configuration Condition=&amp;quot; '$(Configuration)' == '' &amp;quot;&amp;gt;Debug&amp;lt;/Configuration&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro $(Configuration)&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot; Condition=&amp;quot;$(Configuration) == 'Release'&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;CreateItem Include=&amp;quot;.\bin\$(Configuration)\*.*&amp;quot; Exclude=&amp;quot;.\bin\$(Configuration)\*vshost.exe&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Include&amp;quot; ItemName=&amp;quot;MyReleaseFiles&amp;quot; /&amp;gt;
    &amp;lt;/CreateItem&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;I added a lot of new stuff here. But of course you are already quite an MSBuild expert, so I think you will manage. First of all, I have added a new property named Configuration. This property contains a condition attribute, which determines the value of the property at runtime. If the Configuration property has not been set upfront, the value of the attribute is set to Debug. Properties can be set upfront by using a special syntax on the command line:&lt;br /&gt; &lt;br /&gt;&lt;span class="codeInline"&gt; Msbuild.exe build.proj /p:Configuration=Debug /t:release &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;More new stuff. I changed all references to the debug, with the value of the new Configuration property. This means that I am now able to run the script in both Debug and Release mode.&lt;br /&gt; &lt;br /&gt;The last new addition is the condition attribute on the release target. This condition examines if the value of the Configuration property is Release and only allows execution of the Release target if this condition is true.&lt;br /&gt;&lt;a name="Frequently Used Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Frequently Used Tasks
&lt;/h2&gt;CallTarget – Executes another target inside the current build file. Used where a target needs to call another target at a specific place inside the target itself. If the target were just dependant on the other target being executed, we would use the DependsOnTargets attribute instead.&lt;br /&gt; &lt;br /&gt;Copy – We already saw this task in action. Copies one or more files from A to B.&lt;br /&gt; &lt;br /&gt;CreateItem – Create dynamic items.&lt;br /&gt; &lt;br /&gt;CreateProperty – Create dynamic properties.&lt;br /&gt; &lt;br /&gt;Delete – Deletes on or more files.&lt;br /&gt; &lt;br /&gt;Exec – Executes an external process. This is typically used to executed external tools, which did not implement MSBuild targets themself.&lt;br /&gt; &lt;br /&gt;MakeDir – Creates one or more directories.&lt;br /&gt; &lt;br /&gt;Message – Outputs a message to the console.&lt;br /&gt; &lt;br /&gt;MSBuild – Executes one or more targets in an external MSBuild file.&lt;br /&gt; &lt;br /&gt;RemoveDir – Removes one or more directories.&lt;br /&gt; &lt;br /&gt;And there are a lot more.&lt;br /&gt;&lt;a name="Custom MSBuild Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Custom MSBuild Tasks
&lt;/h2&gt;It is possible to write your own MSBuild tasks. This can be extremely useful if you want to integrate some of your own tools with MSBuild or if you need to do stuff which is not yet supported by MSBuild. The following example shows how to write a simple addition task:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
using System;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
namespace MyTasks
{
  public class AddTask : Task
  {
    private int number1;
    [Required]
    public int Number1
    {
      get { return number1; }
      set { number1 = value; }
    }
    private int number2;
    [Required]
    public int Number2
    {
      get { return number2; }
      set { number2 = value; }
    }
    private int sum;
    [Output]
    public int Sum
    {
      get { return sum; }
      set { sum = value; }
    }
    public override bool Execute()
    {
      try
      {
        sum = number1 + number2;
      }
      catch (ArithmeticException e)
      {
        Console.WriteLine(&amp;quot;Error occured during addition: {0}&amp;quot;, e.Message);
        return false;
      }
      return true;
    }
  }
}
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;I start by defining the AddTask class which extends the Task class from the MSBuild API. By extending this task, I don't need to worry about implementing conditions etc.&lt;br /&gt;I defined two properties which act as input variables to the addition task: Number1 and Number2. Both properties are marked with the Required attribute which tells the script to fail if they are not specified. An output property is added as well. The value of this property will be available  within the build script. Let's see how to use this new and fancy task:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;UsingTask TaskName=&amp;quot;MyTasks.AddTask&amp;quot; AssemblyFile=&amp;quot;.\AddTask.dll&amp;quot;/&amp;gt;
  &amp;lt;Target Name=&amp;quot;Addition&amp;quot;&amp;gt;
    &amp;lt;AddTask Number1=&amp;quot;10&amp;quot; Number2=&amp;quot;12&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Sum&amp;quot; PropertyName=&amp;quot;CalculatedSum&amp;quot; /&amp;gt;
    &amp;lt;/AddTask&amp;gt;
    &amp;lt;Message Text=&amp;quot;10 + 12 = $(CalculatedSum)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;Because my AddTask in an external task not built into the MSBuild framework, I use the UsingTask element to reference it. The name of the task as well as the assembly name is specified.&lt;br /&gt; &lt;br /&gt;The Addition target uses the AddTask with the two Number properties as attributes. The Output element copies the result of the task to a property called CalculatedSum. This property is accessible in the Message task for output on the console.&lt;br /&gt; &lt;br /&gt;You just implemented your first custom MSBuild task. Pretty easy, right?&lt;br /&gt;&lt;a name="Generic Targets"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Generic Targets
&lt;/h2&gt;Once in a while a question pops up in different forums: How do I parameterize a common part of my script, making it possible to use it from different targets? This is a great question. We don't want to have the same lines of code  spread around our build script, making it longer than necessary and complex to maintain. MSBuild provides the CallTarget task, which executes another target inside the current build file. Unfortunately there is no way to  parameterize the CallTarget task, making it unusable for anything other than simple situations where needed tasks are 100% identical.&lt;br /&gt; &lt;br /&gt;Let's look at and example where we have two targets with some identical tasks:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target1&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from Target1&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target2&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from Target2&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;In the example we define two targets: Target1 and Target2. You will probably notice that the targets look very similar. The only difference is the text inside the Message task. This is a simple example of the problem and of course changing the text in both message tasks would be fairly simple. But you probably understand the problem here: It would be nice to refactor the targets (let's call it &amp;quot;Extract Target&amp;quot;), so that the Hello World text will only be specified once. First of all we need to move the common tasks to a new target:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;Target Name=&amp;quot;PrintMessage&amp;quot;&amp;gt;
  &amp;lt;Message Text=&amp;quot;Hello World from X&amp;quot; /&amp;gt;
&amp;lt;/Target&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;Note that the replaced part of the Text with the X. Now we need to call this target, making sure that X will be replaced with the correct string. For this purpose we use another task called MSBuild. The MSBuild task was originally produced to be able to call targets inside other MSBuild scripts. The great thing about the MSBuild task is that it has the capability to receive properties. In order to call our PrintMessage target and print the correct string, we parameterize the target like this:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target1&amp;quot;&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;$(MSBuildProjectFile)&amp;quot; Targets=&amp;quot;PrintMessage&amp;quot; Properties=&amp;quot;Caller=Target1&amp;quot;/&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target2&amp;quot;&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;$(MSBuildProjectFile)&amp;quot; Targets=&amp;quot;PrintMessage&amp;quot; Properties=&amp;quot;Caller=Target2&amp;quot;/&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;PrintMessage&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from $(Caller)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;We use the MSBuild tasks in both Target1 and Target2. The $(MSBuildProjectFile) is a built-in property in MSBuild, which returns the filename of the current build file. What we do here is that we call the PrintMessage task on this. The properties attribute specify a single property named Caller. Multiple properties can be specified inside this attribute by separating them with a semicolon. In the PrintMessage task we simply print the message with the Caller property specified inside the Text attribute.&lt;br /&gt;&lt;a name="Links"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Links
&lt;/h2&gt;The MSBuild documentation is actually quite good and a must for all serious MSBuild developers: &lt;a href="http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx" class="externalLink"&gt;http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;A lot of different tools for handling MSBuild files exist. I haven't been able to find a tool that makes it possible to run build scripts from within Visual Studio. You could start by installing the MSBuildShellExtension tool from: &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;MSBuildShellExtension&lt;/a&gt;.&lt;br /&gt; &lt;br /&gt;Besides the build in tasks in MSBuild, there is a great community project, implementing a lot of nice tasks not implemented by Microsoft. Targets for search and replace, zipping, sending out mails, modifying subversion etc., can be found here: &lt;a href="http://msbuildtasks.tigris.org/" class="externalLink"&gt;http://msbuildtasks.tigris.org/&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Wed, 23 Jul 2008 11:59:52 GMT</pubDate><guid isPermaLink="false">Updated Wiki: MSBuild Tutorial 20080723115952A</guid></item><item><title>Updated Wiki: MSBuild Tutorial</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild Tutorial&amp;version=17</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Manual&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;i&gt;MSBuild Tutorial&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
MSBuild Tutorial
&lt;/h1&gt;This page gives a short introduction to the MSBuild tool. The tutorial is protected under copyright law and may not be published without permission from the MSBuildShellExtension coordinators at the CodePlex site.&lt;br /&gt;Thanks to Joe Wass for correcting my bad english :o)&lt;br /&gt;&lt;h2&gt;
Table of Contents
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#MSBuild%20Basics"&gt;MSBuild Basics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Properties"&gt;Properties&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Items"&gt;Items&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Conditions"&gt;Conditions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Frequently%20Used%20Tasks"&gt;Frequently Used Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Custom%20MSBuild%20Tasks"&gt;Custom MSBuild Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Generic%20Targets"&gt;Generic Targets&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Links"&gt;Links&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;a name="MSBuild Basics"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
MSBuild Basics
&lt;/h2&gt;.NET 2.0 contains a new tool called MSBuild. MSBuild is primarily used to build .NET applications, but can be used for other types of applications as well. From Windows Vista, MSBuild is distributed with Windows itself, making it a strong platform for implementing scripted application on non-developer PCs as well.&lt;br /&gt; &lt;br /&gt;Before .NET 2.0, application were built by one or more of these strategies:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Using the build menu from inside Visual Studio&lt;/li&gt;&lt;li&gt;Using the devenv.exe process from the command line with some extra parameters&lt;/li&gt;&lt;li&gt;Using a third-party tool like NAnt (which MSBuild is based on)&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;The drawback with the first two strategies was that it was hard to script. The drawback with the third solution was that two build environments had to be held in sync and maintained. .NET 2.0 Visual Studio projects are now implemented in the MSBuild language, but MSBuild has no dependencies on Visual Studio itself. MSBuild can in theory be implemented in files with any extension but a number of formats seem to be the supported standard from Microsoft: csproj, vbproj, vcproj, vjsproj, proj, .targets. The first four are different types of project files for Visual Studio, while the last two are new extensions which are either written by hand or with a tool knowing the MSBuild syntax. A few tools exist for this purpose. My personal opinion is that building in xml editor in Visual Studio is quite good for this purpose. A repeating question among MSBuild developers is if you should extend the files generated by visual studio with new stuff or whether you should write your own containing your home-made MSBuild scripts. My personal opinion is to let Visual Studio generate its own projects (example: csproj files) and create your home-made scripts in a .proj file with the same name as the project. I usually start the .proj file by implementing the three targets: Clean, Build and Rebuild, which basically just calls the similar targets in the .csproj file. This way you avoid updating an auto-generated file which you don't have control over.&lt;br /&gt; &lt;br /&gt;An MSBuild file is implemented in XML. The root element of an MSBuild XML file will always be a project containing target elements. It is possible to run multiple targets in a MSBuild file. When the MSBuild script is started from the command line, it takes a build file as parameter as well as the names of the targets, which should be executed.&lt;br /&gt; &lt;br /&gt;A target is implemented as a sequential list of tasks. The tasks are executed in the order in which they are specified beneath the target element. Both targets and tasks can be dependant on each other.&lt;br /&gt; &lt;br /&gt;This is an example of a very simple build file to build a .NET project:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;The example defines a project with the MSBuild namespace. Using the namespace helps you develop the build file in Visual Studio using Intellisense. The build file contains a single target named Build. This target contains two tasks: Message and MSBuild. Message outputs a message to the console and is used primarily for debug purposes. MSBuild runs a configurable number of targets on another build file. Because the .csproj file is also implemented in MSBuild we are able to call targets in the build file from the example build file. In this case we call the target Build in the .csproj file. All projects generated by Visual Studio automatically implements the Clean, Build and Rebuild  targets. These targets are actually executed when you select the similar commands in the Build menu from within Visual Studio.&lt;br /&gt;&lt;a name="Properties"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Properties
&lt;/h2&gt;To be able to parameterise a build script, MSBuild has implemented properties. A property is a simple key/value type, which can be used from multiple locations in the scripts. Let's look at an example using properties:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;.\bin\debug\msbuildintro.exe&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;The example defines a property defined in a property group. Properties can be defined both outside and inside scope of a target. When a property is defined like in this example, the value of the property is assigned before executing the actual targets. In the example I define a property called MyReleaseOutput and add the value .\release. In this example I have added two targets as well: Build and Release. The Build target is similar to the one specified in the previous example, while the Release target is new. The Release target introduces a new attribute called DependsOnTargets, which is the way to define dependencies between targets in MSBuild. In this case we tell MSBuild to run the Build target before running the Release targets. If you run the Build target manually before running the Release target, the Build target is run only once.&lt;br /&gt; &lt;br /&gt;The release target introduces two new tasks as well: MakeDir which (well you guessed it) creates a new directory and Copy, which copies on or more files from A to B. MakeDir contains a single attribute, defining the path of the new directory.&lt;br /&gt;In this example that path is the value of the MyReleaseOutput property. Notice the use of the $(propertyname) syntax here. $() is used to reference properties in MSBuild. The copy task in our example points out a single file and the destination folder where this file should be copied to, when executing the Release target. The $(MyReleaseOutput) used is again replaced by the value of this property.&lt;br /&gt;&lt;a name="Items"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Items
&lt;/h2&gt;The example above copied a single file from one directory to another. This can certainly be useful in many situations but sometimes this is simply not flexible enough. This is were items comes in. An item gives the possibility of creating dynamic lists of, for instance, file names. Let's start by looking at an example:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;MyReleaseFiles Include=&amp;quot;.\bin\debug\*.*&amp;quot; /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;We start by defining an ItemGroup outer scope of a target. This means that the content is calculated before actually running any targets. In this example I define an ItemGroup containing a single item called MyReleaseFiles. The item contains a single attribute called Include, which acts as a filter for the generated file list: in this case, all files beneath the bin\debug directory. I use this item in the copy task beneath the Release target to indicate which files should be copied when doing a release.&lt;br /&gt; &lt;br /&gt;The Include filter decides which file to include. We also have the possibility to specify an Exclude filter. The following example shows how:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;MyReleaseFiles Include=&amp;quot;.\bin\debug\*.*&amp;quot; Exclude=&amp;quot;.\bin\debug\*vshost.exe&amp;quot; /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;I added an Exlude attribute to my MyReleaseFiles item. The exclude in this examples excludes all files beneath the bin\debug directory which end in vshost.exe. An item containing both Include and Exclude will be generated by taking all the files specified in the Include and subtracting the files specified in the Exlude.&lt;br /&gt; &lt;br /&gt;The last two examples of using items are actually not that useful because the content for the MyReleaseFiles item is generated before running the actual targets. On a new checkout or after a clean, no files exist in the bin\debug directory meaning that the generated file list will therefore be completely empty. Bummer! Let us fix the example. We define a new item inside the scope of a target instead:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;CreateItem Include=&amp;quot;.\bin\debug\*.*&amp;quot; Exclude=&amp;quot;.\bin\debug\*vshost.exe&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Include&amp;quot; ItemName=&amp;quot;MyReleaseFiles&amp;quot;/&amp;gt;
    &amp;lt;/CreateItem&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;I moved the MyReleaseOutput item inside the Release target. This is done using the CreateItem task. The CreateItem task creates a new item on the fly which means that the content is generated at the point in time when the CreateItem task is executed. Notice that the CreateItem task contains an Output element. The Output element is used in a lot of different places in MSBuild where a target is able to output some data. In this case is use the ItemName attribute to define the name from the previous example.&lt;br /&gt; &lt;br /&gt;Anyone still reading? If you have read this far, you derserve a little prize:&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20133" alt="dilbert2002444471010.gif" /&gt;&lt;br /&gt;&lt;a name="Conditions"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Conditions
&lt;/h2&gt;Besides the CreateItem task in a previous example, our build scripts have been very static until now. This can be sufficient for a lot of projects but sometimes you need slightly more flexible build scripts. A feature for fulfilling this in MSBuild is called Conditions. A condition in MSBuild is not that different to a condition in other software languages. It is a possibile, for instance, to make more flexible structures to avoid running targets and/or tasks when certain conditions are met. You can define conditions on all targets and almost all tasks. Lets check out another example:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
    &amp;lt;Configuration Condition=&amp;quot; '$(Configuration)' == '' &amp;quot;&amp;gt;Debug&amp;lt;/Configuration&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro $(Configuration)&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot; Condition=&amp;quot;$(Configuration) == 'Release'&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;CreateItem Include=&amp;quot;.\bin\$(Configuration)\*.*&amp;quot; Exclude=&amp;quot;.\bin\$(Configuration)\*vshost.exe&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Include&amp;quot; ItemName=&amp;quot;MyReleaseFiles&amp;quot; /&amp;gt;
    &amp;lt;/CreateItem&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;I added a lot of new stuff here. But of course you are already quite an MSBuild expert, so I think you will manage. First of all, I have added a new property named Configuration. This property contains a condition attribute, which determines the value of the property at runtime. If the Configuration property has not been set upfront, the value of the attribute is set to Debug. Properties can be set upfront by using a special syntax on the command line:&lt;br /&gt; &lt;br /&gt;&lt;span class="codeInline"&gt; Msbuild.exe build.proj /p:Configuration=Debug /t:release &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;More new stuff. I changed all references to the debug, with the value of the new Configuration property. This means that I am now able to run the script in both Debug and Release mode.&lt;br /&gt; &lt;br /&gt;The last new addition is the condition attribute on the release target. This condition examines if the value of the Configuration property is Release and only allows execution of the Release target if this condition is true.&lt;br /&gt;&lt;a name="Frequently Used Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Frequently Used Tasks
&lt;/h2&gt;CallTarget – Executes another target inside the current build file. Used where a target needs to call another target at a specific place inside the target itself. If the target were just dependant on the other target being executed, we would use the DependsOnTargets attribute instead.&lt;br /&gt; &lt;br /&gt;Copy – We already saw this task in action. Copies one or more files from A to B.&lt;br /&gt; &lt;br /&gt;CreateItem – Create dynamic items.&lt;br /&gt; &lt;br /&gt;CreateProperty – Create dynamic properties.&lt;br /&gt; &lt;br /&gt;Delete – Deletes on or more files.&lt;br /&gt; &lt;br /&gt;Exec – Executes an external process. This is typically used to executed external tools, which did not implement MSBuild targets themself.&lt;br /&gt; &lt;br /&gt;MakeDir – Creates one or more directories.&lt;br /&gt; &lt;br /&gt;Message – Outputs a message to the console.&lt;br /&gt; &lt;br /&gt;MSBuild – Executes one or more targets in an external MSBuild file.&lt;br /&gt; &lt;br /&gt;RemoveDir – Removes one or more directories.&lt;br /&gt; &lt;br /&gt;And there are a lot more.&lt;br /&gt;&lt;a name="Custom MSBuild Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Custom MSBuild Tasks
&lt;/h2&gt;It is possible to write your own MSBuild tasks. This can be extremely useful if you want to integrate some of your own tools with MSBuild or if you need to do stuff which is not yet supported by MSBuild. The following example shows how to write a simple addition task:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
using System;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
namespace MyTasks
{
  public class AddTask : Task
  {
    private int number1;
    [Required]
    public int Number1
    {
      get { return number1; }
      set { number1 = value; }
    }
    private int number2;
    [Required]
    public int Number2
    {
      get { return number2; }
      set { number2 = value; }
    }
    private int sum;
    [Output]
    public int Sum
    {
      get { return sum; }
      set { sum = value; }
    }
    public override bool Execute()
    {
      try
      {
        sum = number1 + number2;
      }
      catch (ArithmeticException e)
      {
        Console.WriteLine(&amp;quot;Error occured during addition: {0}&amp;quot;, e.Message);
        return false;
      }
      return true;
    }
  }
}
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;I start by defining the AddTask class which extends the Task class from the MSBuild API. By extending this task, I don't need to worry about implementing conditions etc.&lt;br /&gt;I defined two properties which act as input variables to the addition task: Number1 and Number2. Both properties are marked with the Required attribute which tells the script to fail if they are not specified. An output property is added as well. The value of this property will be available  within the build script. Let's see how to use this new and fancy task:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;UsingTask TaskName=&amp;quot;MyTasks.AddTask&amp;quot; AssemblyFile=&amp;quot;.\AddTask.dll&amp;quot;/&amp;gt;
  &amp;lt;Target Name=&amp;quot;Addition&amp;quot;&amp;gt;
    &amp;lt;AddTask Number1=&amp;quot;10&amp;quot; Number2=&amp;quot;12&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Sum&amp;quot; PropertyName=&amp;quot;CalculatedSum&amp;quot; /&amp;gt;
    &amp;lt;/AddTask&amp;gt;
    &amp;lt;Message Text=&amp;quot;10 + 12 = $(CalculatedSum)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;Because my AddTask in an external task not built into the MSBuild framework, I use the UsingTask element to reference it. The name of the task as well as the assembly name is specified.&lt;br /&gt; &lt;br /&gt;The Addition target uses the AddTask with the two Number properties as attributes. The Output element copies the result of the task to a property called CalculatedSum. This property is accessible in the Message task for output on the console.&lt;br /&gt; &lt;br /&gt;You just implemented your first custom MSBuild task. Pretty easy, right?&lt;br /&gt;&lt;a name="Generic Targets"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Generic Targets
&lt;/h2&gt;Once in a while a question pops up in different forums: How do I parameterize a common part of my script, making it possible to use it from different targets? This is a great question. We don't want to have the same lines of code  spread around our build script, making it longer than necessary and complex to maintain. MSBuild provides the CallTarget task, which executes another target inside the current build file. Unfortunately there is no way to  parameterize the CallTarget task, making it unusable for anything other than simple situations where needed tasks are 100% identical.&lt;br /&gt; &lt;br /&gt;Let's look at and example where we have two targets with some identical tasks:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target1&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from Target1&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target2&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from Target2&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;In the example we define two targets: Target1 and Target2. You will probably notice that the targets look very similar. The only difference is the text inside the Message task. This is a simple example of the problem and of course changing the text in both message tasks would be fairly simple. But you probably understand the problem here: It would be nice to refactor the targets (let's call it &amp;quot;Extract Target&amp;quot;), so that the Hello World text will only be specified once. First of all we need to move the common tasks to a new target:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;Target Name=&amp;quot;PrintMessage&amp;quot;&amp;gt;
  &amp;lt;Message Text=&amp;quot;Hello World from X&amp;quot; /&amp;gt;
&amp;lt;/Target&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;Note that the replaced part of the Text with the X. Now we need to call this target, making sure that X will be replaced with the correct string. For this purpose we use another task called MSBuild. The MSBuild task was originally produced to be able to call targets inside other MSBuild scripts. The great thing about the MSBuild task is that it has the capability to receive properties. In order to call our PrintMessage target and print the correct string, we parameterize the target like this:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target1&amp;quot;&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;$(MSBuildProjectFile)&amp;quot; Targets=&amp;quot;PrintMessage&amp;quot; Properties=&amp;quot;Caller=Target1&amp;quot;/&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target2&amp;quot;&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;$(MSBuildProjectFile)&amp;quot; Targets=&amp;quot;PrintMessage&amp;quot; Properties=&amp;quot;Caller=Target2&amp;quot;/&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;PrintMessage&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from $(Caller)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;We use the MSBuild tasks in both Target1 and Target2. The $(MSBuildProjectFile) is a built-in property in MSBuild, which returns the filename of the current build file. What we do here is that we call the PrintMessage task on this. The properties attribute specify a single property named Caller. Multiple properties can be specified inside this attribute by separating them with a semicolon. In the PrintMessage task we simply print the message with the Caller property specified inside the Text attribute.&lt;br /&gt;&lt;a name="Links"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Links
&lt;/h2&gt;The MSBuild documentation is actually quite good and a must for all serious MSBuild developers: &lt;a href="http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx" class="externalLink"&gt;http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;A lot of different tools for handling MSBuild files exist. I haven't been able to find a tool that makes it possible to run build scripts from within Visual Studio. You could start by installing the MSBuildShellExtension tool from: &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;MSBuildShellExtension&lt;/a&gt;.&lt;br /&gt; &lt;br /&gt;Besides the build in tasks in MSBuild, there is a great community project, implementing a lot of nice tasks not implemented by Microsoft. Targets for search and replace, zipping, sending out mails, modifying subversion etc., can be found here: &lt;a href="http://msbuildtasks.tigris.org/" class="externalLink"&gt;http://msbuildtasks.tigris.org/&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Wed, 23 Jul 2008 11:59:25 GMT</pubDate><guid isPermaLink="false">Updated Wiki: MSBuild Tutorial 20080723115925A</guid></item><item><title>Updated Wiki: MSBuild Tutorial</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild Tutorial&amp;version=16</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Manual&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;i&gt;MSBuild Tutorial&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
MSBuild Tutorial
&lt;/h1&gt;This page gives a short introduction to the MSBuild tool. The tutorial is protected under copyright law and may not be published without permission from the MSBuildShellExtension coordinators at the CodePlex site.&lt;br /&gt;&lt;h2&gt;
Table of Contents
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#MSBuild%20Basics"&gt;MSBuild Basics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Properties"&gt;Properties&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Items"&gt;Items&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Conditions"&gt;Conditions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Frequently%20Used%20Tasks"&gt;Frequently Used Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Custom%20MSBuild%20Tasks"&gt;Custom MSBuild Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Generic%20Targets"&gt;Generic Targets&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Links"&gt;Links&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;a name="MSBuild Basics"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
MSBuild Basics
&lt;/h2&gt;.NET 2.0 contains a new tool called MSBuild. MSBuild is primarily used to build .NET applications, but can be used for other types of applications as well. From Windows Vista, MSBuild is distributed with Windows itself, making it a strong platform for implementing scripted application on non-developer PCs as well.&lt;br /&gt; &lt;br /&gt;Before .NET 2.0, application were built by one or more of these strategies:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Using the build menu from inside Visual Studio&lt;/li&gt;&lt;li&gt;Using the devenv.exe process from the command line with some extra parameters&lt;/li&gt;&lt;li&gt;Using a third-party tool like NAnt (which MSBuild is based on)&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;The drawback with the first two strategies was that it was hard to script. The drawback with the third solution was that two build environments had to be held in sync and maintained. .NET 2.0 Visual Studio projects are now implemented in the MSBuild language, but MSBuild has no dependencies on Visual Studio itself. MSBuild can in theory be implemented in files with any extension but a number of formats seem to be the supported standard from Microsoft: csproj, vbproj, vcproj, vjsproj, proj, .targets. The first four are different types of project files for Visual Studio, while the last two are new extensions which are either written by hand or with a tool knowing the MSBuild syntax. A few tools exist for this purpose. My personal opinion is that building in xml editor in Visual Studio is quite good for this purpose. A repeating question among MSBuild developers is if you should extend the files generated by visual studio with new stuff or whether you should write your own containing your home-made MSBuild scripts. My personal opinion is to let Visual Studio generate its own projects (example: csproj files) and create your home-made scripts in a .proj file with the same name as the project. I usually start the .proj file by implementing the three targets: Clean, Build and Rebuild, which basically just calls the similar targets in the .csproj file. This way you avoid updating an auto-generated file which you don't have control over.&lt;br /&gt; &lt;br /&gt;An MSBuild file is implemented in XML. The root element of an MSBuild XML file will always be a project containing target elements. It is possible to run multiple targets in a MSBuild file. When the MSBuild script is started from the command line, it takes a build file as parameter as well as the names of the targets, which should be executed.&lt;br /&gt; &lt;br /&gt;A target is implemented as a sequential list of tasks. The tasks are executed in the order in which they are specified beneath the target element. Both targets and tasks can be dependant on each other.&lt;br /&gt; &lt;br /&gt;This is an example of a very simple build file to build a .NET project:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;The example defines a project with the MSBuild namespace. Using the namespace helps you develop the build file in Visual Studio using Intellisense. The build file contains a single target named Build. This target contains two tasks: Message and MSBuild. Message outputs a message to the console and is used primarily for debug purposes. MSBuild runs a configurable number of targets on another build file. Because the .csproj file is also implemented in MSBuild we are able to call targets in the build file from the example build file. In this case we call the target Build in the .csproj file. All projects generated by Visual Studio automatically implements the Clean, Build and Rebuild  targets. These targets are actually executed when you select the similar commands in the Build menu from within Visual Studio.&lt;br /&gt;&lt;a name="Properties"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Properties
&lt;/h2&gt;To be able to parameterise a build script, MSBuild has implemented properties. A property is a simple key/value type, which can be used from multiple locations in the scripts. Let's look at an example using properties:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;.\bin\debug\msbuildintro.exe&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;The example defines a property defined in a property group. Properties can be defined both outside and inside scope of a target. When a property is defined like in this example, the value of the property is assigned before executing the actual targets. In the example I define a property called MyReleaseOutput and add the value .\release. In this example I have added two targets as well: Build and Release. The Build target is similar to the one specified in the previous example, while the Release target is new. The Release target introduces a new attribute called DependsOnTargets, which is the way to define dependencies between targets in MSBuild. In this case we tell MSBuild to run the Build target before running the Release targets. If you run the Build target manually before running the Release target, the Build target is run only once.&lt;br /&gt; &lt;br /&gt;The release target introduces two new tasks as well: MakeDir which (well you guessed it) creates a new directory and Copy, which copies on or more files from A to B. MakeDir contains a single attribute, defining the path of the new directory.&lt;br /&gt;In this example that path is the value of the MyReleaseOutput property. Notice the use of the $(propertyname) syntax here. $() is used to reference properties in MSBuild. The copy task in our example points out a single file and the destination folder where this file should be copied to, when executing the Release target. The $(MyReleaseOutput) used is again replaced by the value of this property.&lt;br /&gt;&lt;a name="Items"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Items
&lt;/h2&gt;The example above copied a single file from one directory to another. This can certainly be useful in many situations but sometimes this is simply not flexible enough. This is were items comes in. An item gives the possibility of creating dynamic lists of, for instance, file names. Let's start by looking at an example:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;MyReleaseFiles Include=&amp;quot;.\bin\debug\*.*&amp;quot; /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;We start by defining an ItemGroup outer scope of a target. This means that the content is calculated before actually running any targets. In this example I define an ItemGroup containing a single item called MyReleaseFiles. The item contains a single attribute called Include, which acts as a filter for the generated file list: in this case, all files beneath the bin\debug directory. I use this item in the copy task beneath the Release target to indicate which files should be copied when doing a release.&lt;br /&gt; &lt;br /&gt;The Include filter decides which file to include. We also have the possibility to specify an Exclude filter. The following example shows how:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;MyReleaseFiles Include=&amp;quot;.\bin\debug\*.*&amp;quot; Exclude=&amp;quot;.\bin\debug\*vshost.exe&amp;quot; /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;I added an Exlude attribute to my MyReleaseFiles item. The exclude in this examples excludes all files beneath the bin\debug directory which end in vshost.exe. An item containing both Include and Exclude will be generated by taking all the files specified in the Include and subtracting the files specified in the Exlude.&lt;br /&gt; &lt;br /&gt;The last two examples of using items are actually not that useful because the content for the MyReleaseFiles item is generated before running the actual targets. On a new checkout or after a clean, no files exist in the bin\debug directory meaning that the generated file list will therefore be completely empty. Bummer! Let us fix the example. We define a new item inside the scope of a target instead:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;CreateItem Include=&amp;quot;.\bin\debug\*.*&amp;quot; Exclude=&amp;quot;.\bin\debug\*vshost.exe&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Include&amp;quot; ItemName=&amp;quot;MyReleaseFiles&amp;quot;/&amp;gt;
    &amp;lt;/CreateItem&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;I moved the MyReleaseOutput item inside the Release target. This is done using the CreateItem task. The CreateItem task creates a new item on the fly which means that the content is generated at the point in time when the CreateItem task is executed. Notice that the CreateItem task contains an Output element. The Output element is used in a lot of different places in MSBuild where a target is able to output some data. In this case is use the ItemName attribute to define the name from the previous example.&lt;br /&gt; &lt;br /&gt;Anyone still reading? If you have read this far, you derserve a little prize:&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20133" alt="dilbert2002444471010.gif" /&gt;&lt;br /&gt;&lt;a name="Conditions"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Conditions
&lt;/h2&gt;Besides the CreateItem task in a previous example, our build scripts have been very static until now. This can be sufficient for a lot of projects but sometimes you need slightly more flexible build scripts. A feature for fulfilling this in MSBuild is called Conditions. A condition in MSBuild is not that different to a condition in other software languages. It is a possibile, for instance, to make more flexible structures to avoid running targets and/or tasks when certain conditions are met. You can define conditions on all targets and almost all tasks. Lets check out another example:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
    &amp;lt;Configuration Condition=&amp;quot; '$(Configuration)' == '' &amp;quot;&amp;gt;Debug&amp;lt;/Configuration&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro $(Configuration)&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot; Condition=&amp;quot;$(Configuration) == 'Release'&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;CreateItem Include=&amp;quot;.\bin\$(Configuration)\*.*&amp;quot; Exclude=&amp;quot;.\bin\$(Configuration)\*vshost.exe&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Include&amp;quot; ItemName=&amp;quot;MyReleaseFiles&amp;quot; /&amp;gt;
    &amp;lt;/CreateItem&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;I added a lot of new stuff here. But of course you are already quite an MSBuild expert, so I think you will manage. First of all, I have added a new property named Configuration. This property contains a condition attribute, which determines the value of the property at runtime. If the Configuration property has not been set upfront, the value of the attribute is set to Debug. Properties can be set upfront by using a special syntax on the command line:&lt;br /&gt; &lt;br /&gt;&lt;span class="codeInline"&gt; Msbuild.exe build.proj /p:Configuration=Debug /t:release &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;More new stuff. I changed all references to the debug, with the value of the new Configuration property. This means that I am now able to run the script in both Debug and Release mode.&lt;br /&gt; &lt;br /&gt;The last new addition is the condition attribute on the release target. This condition examines if the value of the Configuration property is Release and only allows execution of the Release target if this condition is true.&lt;br /&gt;&lt;a name="Frequently Used Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Frequently Used Tasks
&lt;/h2&gt;CallTarget – Executes another target inside the current build file. Used where a target needs to call another target at a specific place inside the target itself. If the target were just dependant on the other target being executed, we would use the DependsOnTargets attribute instead.&lt;br /&gt; &lt;br /&gt;Copy – We already saw this task in action. Copies one or more files from A to B.&lt;br /&gt; &lt;br /&gt;CreateItem – Create dynamic items.&lt;br /&gt; &lt;br /&gt;CreateProperty – Create dynamic properties.&lt;br /&gt; &lt;br /&gt;Delete – Deletes on or more files.&lt;br /&gt; &lt;br /&gt;Exec – Executes an external process. This is typically used to executed external tools, which did not implement MSBuild targets themself.&lt;br /&gt; &lt;br /&gt;MakeDir – Creates one or more directories.&lt;br /&gt; &lt;br /&gt;Message – Outputs a message to the console.&lt;br /&gt; &lt;br /&gt;MSBuild – Executes one or more targets in an external MSBuild file.&lt;br /&gt; &lt;br /&gt;RemoveDir – Removes one or more directories.&lt;br /&gt; &lt;br /&gt;And there are a lot more.&lt;br /&gt;&lt;a name="Custom MSBuild Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Custom MSBuild Tasks
&lt;/h2&gt;It is possible to write your own MSBuild tasks. This can be extremely useful if you want to integrate some of your own tools with MSBuild or if you need to do stuff which is not yet supported by MSBuild. The following example shows how to write a simple addition task:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
using System;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
namespace MyTasks
{
  public class AddTask : Task
  {
    private int number1;
    [Required]
    public int Number1
    {
      get { return number1; }
      set { number1 = value; }
    }
    private int number2;
    [Required]
    public int Number2
    {
      get { return number2; }
      set { number2 = value; }
    }
    private int sum;
    [Output]
    public int Sum
    {
      get { return sum; }
      set { sum = value; }
    }
    public override bool Execute()
    {
      try
      {
        sum = number1 + number2;
      }
      catch (ArithmeticException e)
      {
        Console.WriteLine(&amp;quot;Error occured during addition: {0}&amp;quot;, e.Message);
        return false;
      }
      return true;
    }
  }
}
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;I start by defining the AddTask class which extends the Task class from the MSBuild API. By extending this task, I don't need to worry about implementing conditions etc.&lt;br /&gt;I defined two properties which act as input variables to the addition task: Number1 and Number2. Both properties are marked with the Required attribute which tells the script to fail if they are not specified. An output property is added as well. The value of this property will be available  within the build script. Let's see how to use this new and fancy task:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;UsingTask TaskName=&amp;quot;MyTasks.AddTask&amp;quot; AssemblyFile=&amp;quot;.\AddTask.dll&amp;quot;/&amp;gt;
  &amp;lt;Target Name=&amp;quot;Addition&amp;quot;&amp;gt;
    &amp;lt;AddTask Number1=&amp;quot;10&amp;quot; Number2=&amp;quot;12&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Sum&amp;quot; PropertyName=&amp;quot;CalculatedSum&amp;quot; /&amp;gt;
    &amp;lt;/AddTask&amp;gt;
    &amp;lt;Message Text=&amp;quot;10 + 12 = $(CalculatedSum)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;Because my AddTask in an external task not built into the MSBuild framework, I use the UsingTask element to reference it. The name of the task as well as the assembly name is specified.&lt;br /&gt; &lt;br /&gt;The Addition target uses the AddTask with the two Number properties as attributes. The Output element copies the result of the task to a property called CalculatedSum. This property is accessible in the Message task for output on the console.&lt;br /&gt; &lt;br /&gt;You just implemented your first custom MSBuild task. Pretty easy, right?&lt;br /&gt;&lt;a name="Generic Targets"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Generic Targets
&lt;/h2&gt;Once in a while a question pops up in different forums: How do I parameterize a common part of my script, making it possible to use it from different targets? This is a great question. We don't want to have the same lines of code  spread around our build script, making it longer than necessary and complex to maintain. MSBuild provides the CallTarget task, which executes another target inside the current build file. Unfortunately there is no way to  parameterize the CallTarget task, making it unusable for anything other than simple situations where needed tasks are 100% identical.&lt;br /&gt; &lt;br /&gt;Let's look at and example where we have two targets with some identical tasks:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target1&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from Target1&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target2&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from Target2&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;In the example we define two targets: Target1 and Target2. You will probably notice that the targets look very similar. The only difference is the text inside the Message task. This is a simple example of the problem and of course changing the text in both message tasks would be fairly simple. But you probably understand the problem here: It would be nice to refactor the targets (let's call it &amp;quot;Extract Target&amp;quot;), so that the Hello World text will only be specified once. First of all we need to move the common tasks to a new target:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;Target Name=&amp;quot;PrintMessage&amp;quot;&amp;gt;
  &amp;lt;Message Text=&amp;quot;Hello World from X&amp;quot; /&amp;gt;
&amp;lt;/Target&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;Note that the replaced part of the Text with the X. Now we need to call this target, making sure that X will be replaced with the correct string. For this purpose we use another task called MSBuild. The MSBuild task was originally produced to be able to call targets inside other MSBuild scripts. The great thing about the MSBuild task is that it has the capability to receive properties. In order to call our PrintMessage target and print the correct string, we parameterize the target like this:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target1&amp;quot;&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;$(MSBuildProjectFile)&amp;quot; Targets=&amp;quot;PrintMessage&amp;quot; Properties=&amp;quot;Caller=Target1&amp;quot;/&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target2&amp;quot;&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;$(MSBuildProjectFile)&amp;quot; Targets=&amp;quot;PrintMessage&amp;quot; Properties=&amp;quot;Caller=Target2&amp;quot;/&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;PrintMessage&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from $(Caller)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;We use the MSBuild tasks in both Target1 and Target2. The $(MSBuildProjectFile) is a built-in property in MSBuild, which returns the filename of the current build file. What we do here is that we call the PrintMessage task on this. The properties attribute specify a single property named Caller. Multiple properties can be specified inside this attribute by separating them with a semicolon. In the PrintMessage task we simply print the message with the Caller property specified inside the Text attribute.&lt;br /&gt;&lt;a name="Links"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Links
&lt;/h2&gt;The MSBuild documentation is actually quite good and a must for all serious MSBuild developers: &lt;a href="http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx" class="externalLink"&gt;http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;A lot of different tools for handling MSBuild files exist. I haven't been able to find a tool that makes it possible to run build scripts from within Visual Studio. You could start by installing the MSBuildShellExtension tool from: &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;MSBuildShellExtension&lt;/a&gt;.&lt;br /&gt; &lt;br /&gt;Besides the build in tasks in MSBuild, there is a great community project, implementing a lot of nice tasks not implemented by Microsoft. Targets for search and replace, zipping, sending out mails, modifying subversion etc., can be found here: &lt;a href="http://msbuildtasks.tigris.org/" class="externalLink"&gt;http://msbuildtasks.tigris.org/&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Wed, 23 Jul 2008 11:56:19 GMT</pubDate><guid isPermaLink="false">Updated Wiki: MSBuild Tutorial 20080723115619A</guid></item><item><title>UPDATED WIKI: Home</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;version=55</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Home&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=Home"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=Home"&gt;Manual&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;amp;referringTitle=Home"&gt;MSBuild Tutorial&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=Home"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=Home"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=Home"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
Project Description
&lt;/h1&gt;MSBuildShellExtension lets you build .NET projects without ever opening Visual Studio or the command prompt. MSBuild targets can be executed from your favourite file system tool like Windows Explorer or Total Commander. The possibility to extend MSBuildShellExtension with your own targets and editors, makes it a very flexible and useful tool for all .NET developers.
&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=11552" alt="msbuildshellex.gif" /&gt;&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
News
&lt;/h2&gt;&lt;b&gt;May 9, 2008&lt;/b&gt;&lt;br /&gt;As you propably noticed, I haven't had a lot of time updating this site or the project recently. This is caused by:&lt;br /&gt; &lt;br /&gt;1. I use MSBuildShellExtension each day, and it works pretty good already.&lt;br /&gt;2. I'm working on a lot of other ideas.&lt;br /&gt;3. I do a lot of UI code at my job, so it isn't really that fun coding UI in my sparetime.&lt;br /&gt;4. The weather is GREAT in Denmark right now!&lt;br /&gt; &lt;br /&gt;So if any of you guys wan't to help extending MSBuildShellExtension in the future, please send me a mail.&lt;br /&gt; &lt;br /&gt;&lt;b&gt;March 1, 2008 - MSBuildShellExtension 1.1.2&lt;/b&gt;&lt;br /&gt;A new bugfix release has seen the light of day. Actually this small update contains more than meets the eye. Among other new features, .NET 3.5 is now supported!&lt;br /&gt; &lt;br /&gt;&lt;b&gt;November 25, 2007 - Msbuildshellextension 1.1.1&lt;/b&gt;&lt;br /&gt;The 1.1.1 release is out. This release contains some bugfixes on the 1.1.0 release as well as some minor changes.&lt;br /&gt; &lt;br /&gt;&lt;b&gt;November 14, 2007 - Msbuildshellextension 1.1.0&lt;/b&gt;&lt;br /&gt;The 1.1.0 is out of beta! Remember to uninstall your existing version of MSBuildShellExtension before installing, due to the change of installer technology. Happy building!&lt;br /&gt; &lt;br /&gt;&lt;b&gt;November 07, 2007 - Msbuildshellextension 1.1.0 Beta1&lt;/b&gt;&lt;br /&gt;The 1.1.0 release of MSBuildShellExtension will arrive shortly. Until then, download and try the beta! Please report any bugs at http://www.codeplex.com/msbuildshellex. Happy testing!&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Fri, 09 May 2008 18:05:33 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Home 20080509060533P</guid></item><item><title>UPDATED WIKI: Home</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;version=54</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Home&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=Home"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=Home"&gt;Manual&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;amp;referringTitle=Home"&gt;MSBuild Tutorial&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=Home"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=Home"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=Home"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
Project Description
&lt;/h1&gt;MSBuildShellExtension lets you build .NET projects without ever opening Visual Studio or the command prompt. MSBuild targets can be executed from your favourite file system tool like Windows Explorer or Total Commander. The possibility to extend MSBuildShellExtension with your own targets and editors, makes it a very flexible and useful tool for all .NET developers.
&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=11552" alt="msbuildshellex.gif" /&gt;&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
News
&lt;/h2&gt;&lt;b&gt;March 1, 2008 - MSBuildShellExtension 1.1.2&lt;/b&gt;&lt;br /&gt;A new bugfix release has seen the light of day. Actually this small update contains more than meets the eye. Among other new features, .NET 3.5 is now supported!&lt;br /&gt; &lt;br /&gt;&lt;b&gt;November 25, 2007 - Msbuildshellextension 1.1.1&lt;/b&gt;&lt;br /&gt;The 1.1.1 release is out. This release contains some bugfixes on the 1.1.0 release as well as some minor changes.&lt;br /&gt; &lt;br /&gt;&lt;b&gt;November 14, 2007 - Msbuildshellextension 1.1.0&lt;/b&gt;&lt;br /&gt;The 1.1.0 is out of beta! Remember to uninstall your existing version of MSBuildShellExtension before installing, due to the change of installer technology. Happy building!&lt;br /&gt; &lt;br /&gt;&lt;b&gt;November 07, 2007 - Msbuildshellextension 1.1.0 Beta1&lt;/b&gt;&lt;br /&gt;The 1.1.0 release of MSBuildShellExtension will arrive shortly. Until then, download and try the beta! Please report any bugs at http://www.codeplex.com/msbuildshellex. Happy testing!&lt;br /&gt; &lt;br /&gt;&lt;b&gt;October 19, 2007 - Msbuild Profiler&lt;/b&gt;&lt;br /&gt;Remember to checkout my new project MSBuild Profiler. MSBuild Profiler is a performance measurement and optimizer tool for MSBuild scripts. MSBuild Profiler&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Thu, 06 Mar 2008 19:20:29 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Home 20080306072029P</guid></item><item><title>UPDATED WIKI: Home</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;version=53</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Home&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=Home"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=Home"&gt;Manual&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;amp;referringTitle=Home"&gt;MSBuild Tutorial&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=Home"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=Home"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=Home"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
Project Description
&lt;/h1&gt;MSBuildShellExtension lets you build .NET projects without ever opening Visual Studio or the command prompt. MSBuild targets can be executed from your favourite file system tool like Windows Explorer or Total Commander. The possibility to extend MSBuildShellExtension with your own targets and editors, makes it a very flexible and useful tool for all .NET developers.
&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=11552" alt="msbuildshellex.gif" /&gt;&lt;br /&gt; &lt;br /&gt;&lt;b&gt;News&lt;/b&gt;&lt;br /&gt;&lt;i&gt;March 1, 2008 - MSBuildShellExtension 1.1.2&lt;/i&gt;&lt;br /&gt;A new bugfix release has seen the light of day. Actually this small update contains more than meets the eye. Among other new features, .NET 3.5 is now supported!&lt;br /&gt; &lt;br /&gt;&lt;i&gt;November 25, 2007 - Msbuildshellextension 1.1.1&lt;/i&gt;&lt;br /&gt;The 1.1.1 release is out. This release contains some bugfixes on the 1.1.0 release as well as some minor changes.&lt;br /&gt; &lt;br /&gt;&lt;i&gt;November 14, 2007 - Msbuildshellextension 1.1.0&lt;/i&gt;&lt;br /&gt;The 1.1.0 is out of beta! Remember to uninstall your existing version of MSBuildShellExtension before installing, due to the change of installer technology. Happy building!&lt;br /&gt; &lt;br /&gt;&lt;i&gt;November 07, 2007 - Msbuildshellextension 1.1.0 Beta1&lt;/i&gt;&lt;br /&gt;The 1.1.0 release of MSBuildShellExtension will arrive shortly. Until then, download and try the beta! Please report any bugs at http://www.codeplex.com/msbuildshellex. Happy testing!&lt;br /&gt; &lt;br /&gt;&lt;i&gt;October 19, 2007 - Msbuild Profiler&lt;/i&gt;&lt;br /&gt;Remember to checkout my new project MSBuild Profiler. MSBuild Profiler is a performance measurement and optimizer tool for MSBuild scripts. MSBuild Profiler&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Thu, 06 Mar 2008 19:19:01 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Home 20080306071901P</guid></item><item><title>UPDATED WIKI: Home</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;version=52</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Home&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=Home"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=Home"&gt;Manual&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;amp;referringTitle=Home"&gt;MSBuild Tutorial&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=Home"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=Home"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=Home"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
Project Description
&lt;/h1&gt;MSBuildShellExtension lets you build .NET projects without ever opening Visual Studio or the command prompt. MSBuild targets can be executed from your favourite file system tool like Windows Explorer or Total Commander. The possibility to extend MSBuildShellExtension with your own targets and editors, makes it a very flexible and useful tool for all .NET developers.
&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=11552" alt="msbuildshellex.gif" /&gt;&lt;br /&gt; &lt;br /&gt;&lt;b&gt;News&lt;/b&gt;&lt;br /&gt;March 1, 2008 - MSBuildShellExtension 1.1.2&lt;br /&gt;A new bugfix release has seen the light of day. Actually this small update contains more than meets the eye. Among other new features, .NET 3.5 is now supported!&lt;br /&gt; &lt;br /&gt;November 25, 2007 - Msbuildshellextension 1.1.1&lt;br /&gt;The 1.1.1 release is out. This release contains some bugfixes on the 1.1.0 release as well as some minor changes.&lt;br /&gt; &lt;br /&gt;November 14, 2007 - Msbuildshellextension 1.1.0&lt;br /&gt;The 1.1.0 is out of beta! Remember to uninstall your existing version of MSBuildShellExtension before installing, due to the change of installer technology. Happy building!&lt;br /&gt; &lt;br /&gt;November 07, 2007 - Msbuildshellextension 1.1.0 Beta1&lt;br /&gt;The 1.1.0 release of MSBuildShellExtension will arrive shortly. Until then, download and try the beta! Please report any bugs at http://www.codeplex.com/msbuildshellex. Happy testing!&lt;br /&gt; &lt;br /&gt;October 19, 2007 - Msbuild Profiler&lt;br /&gt;Remember to checkout my new project MSBuild Profiler. MSBuild Profiler is a performance measurement and optimizer tool for MSBuild scripts. MSBuild Profiler&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Thu, 06 Mar 2008 19:18:11 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Home 20080306071811P</guid></item><item><title>UPDATED WIKI: Home</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;version=51</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Home&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=Home"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=Home"&gt;Manual&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;amp;referringTitle=Home"&gt;MSBuild Tutorial&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=Home"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=Home"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20149" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=Home"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
Project Description
&lt;/h1&gt;MSBuildShellExtension lets you build .NET projects without ever opening Visual Studio or the command prompt. MSBuild targets can be executed from your favourite file system tool like Windows Explorer or Total Commander. The possibility to extend MSBuildShellExtension with your own targets and editors, makes it a very flexible and useful tool for all .NET developers.
&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=11552" alt="msbuildshellex.gif" /&gt;&lt;br /&gt; &lt;br /&gt;&lt;b&gt;News&lt;/b&gt;&lt;br /&gt;November 25, 2007 - Msbuildshellextension 1.1.1&lt;br /&gt;The 1.1.1 release is out. This release contains some bugfixes on the 1.1.0 release as well as some minor changes.&lt;br /&gt; &lt;br /&gt;November 14, 2007 - Msbuildshellextension 1.1.0&lt;br /&gt;The 1.1.0 is out of beta! Remember to uninstall your existing version of MSBuildShellExtension before installing, due to the change of installer technology. Happy building!&lt;br /&gt; &lt;br /&gt;November 07, 2007 - Msbuildshellextension 1.1.0 Beta1&lt;br /&gt;The 1.1.0 release of MSBuildShellExtension will arrive shortly. Until then, download and try the beta! Please report any bugs at http://www.codeplex.com/msbuildshellex. Happy testing!&lt;br /&gt; &lt;br /&gt;October 19, 2007 - Msbuild Profiler&lt;br /&gt;Remember to checkout my new project MSBuild Profiler. MSBuild Profiler is a performance measurement and optimizer tool for MSBuild scripts. MSBuild Profiler&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Thu, 06 Mar 2008 19:14:18 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Home 20080306071418P</guid></item><item><title>UPDATED WIKI: Manual</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;version=9</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=Manual"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=Manual"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;i&gt;Manual&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;amp;referringTitle=Manual"&gt;MSBuild Tutorial&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=Manual"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=Manual"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=Manual"&gt;RSS&lt;/a&gt;&lt;br /&gt;&lt;h1&gt;
Manual
&lt;/h1&gt;This short manual tries to explain the basic concepts in MSBuildShellExtension.&lt;br /&gt;&lt;h2&gt;
Editor
&lt;/h2&gt;When double clicking on a file with warning/error in the MSBuildShellExtension error list window, an editor of your choices opens. MSBuildShellExtension comes with two pre-installed templates for Visual Studio 2005 and Notepad. It is possible to extend the tool with more templates. This is done through the MSBuild Shell Extension Configurator:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;/li&gt;&lt;li&gt;Select the Editor icon.&lt;/li&gt;&lt;li&gt;Select the New button.&lt;/li&gt;&lt;li&gt;Type a name for the external tool in the Title textbox.&lt;/li&gt;&lt;li&gt;Select the Default checkbox, if this tool should be used as the external tool for opening source files from within the error list window.&lt;/li&gt;&lt;li&gt;Add the path to the external tool in the Target and arguments textbox. The external tool should as a minimum support a command line parameter for specifying the file containing error/warning. You can use the Variables button to insert different types of variables in the Target and arguments textbox.&lt;/li&gt;&lt;li&gt;Select the Add button.&lt;/li&gt;&lt;li&gt;Select the Save button.&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21550" alt="editor.png" /&gt;&lt;br /&gt;&lt;h2&gt;
Targets
&lt;/h2&gt;MSBuildShellExtension comes with three types of targets (Build, Clean and Rebuild) for each of the default file types. Theese targets can be modified or removed and new targets can be added. This is done through the Targets section in the MSBuild Shell Extension Configurator. New targets are added like this:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;/li&gt;&lt;li&gt;Select the Targets icon.&lt;/li&gt;&lt;li&gt;Select the New button.&lt;/li&gt;&lt;li&gt;Type a name for the target in the Title textbox.&lt;/li&gt;&lt;li&gt;Type the name of the target. This is the target name as specified in the MSBuild file.&lt;/li&gt;&lt;li&gt;Select a verbosity for the target in the Verbosity combobox.&lt;/li&gt;&lt;li&gt;Select the configuration for the target in the Configuration combobox.&lt;/li&gt;&lt;li&gt;Unselect the Show error list checkbox, if you don't want to show the error list window when executing builds through MSBuild Shell Extension.&lt;/li&gt;&lt;li&gt;Select the Add button.&lt;/li&gt;&lt;li&gt;Select the Save button.&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21551" alt="target.png" /&gt;&lt;br /&gt;&lt;h2&gt;
Extensions
&lt;/h2&gt;Last, but not least, you are able to extend the shell extension to file extensions of your choise. As default a number of MSBuild extensions are added, but you can add your own file extension like this:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;/li&gt;&lt;li&gt;Select the Extensions icon.&lt;/li&gt;&lt;li&gt;Select the New button.&lt;/li&gt;&lt;li&gt;Type in the file extension in the File extension textbox. The file extension should not contain a '.' before the extension name.&lt;/li&gt;&lt;li&gt;Select the MSBuild version for this extension.&lt;/li&gt;&lt;li&gt;Select the Targets which should be enabled for the new file extension. Each target selected, results in an additional menuitem at the context menu of the specified file extension.&lt;/li&gt;&lt;li&gt;Select the Add button.&lt;/li&gt;&lt;li&gt;Select the Save button.&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=28838" alt="extension.png" /&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Sat, 01 Mar 2008 09:09:46 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Manual 20080301090946A</guid></item><item><title>UPDATED WIKI: Manual</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;version=8</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=Manual"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=Manual"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;i&gt;Manual&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;amp;referringTitle=Manual"&gt;MSBuild Tutorial&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=Manual"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=Manual"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=Manual"&gt;RSS&lt;/a&gt;&lt;br /&gt;&lt;h1&gt;
Manual
&lt;/h1&gt;This short manual tries to explain the basic concepts in MSBuildShellExtension.&lt;br /&gt;&lt;h2&gt;
Editor
&lt;/h2&gt;When double clicking on a file with warning/error in the MSBuildShellExtension error list window, an editor of your choices opens. MSBuildShellExtension comes with two pre-installed templates for Visual Studio 2005 and Notepad. It is possible to extend the tool with more templates. This is done through the MSBuild Shell Extension Configurator:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;/li&gt;&lt;li&gt;Select the Editor icon.&lt;/li&gt;&lt;li&gt;Select the New button.&lt;/li&gt;&lt;li&gt;Type a name for the external tool in the Title textbox.&lt;/li&gt;&lt;li&gt;Select the Default checkbox, if this tool should be used as the external tool for opening source files from within the error list window.&lt;/li&gt;&lt;li&gt;Add the path to the external tool in the Target and arguments textbox. The external tool should as a minimum support a command line parameter for specifying the file containing error/warning. You can use the Variables button to insert different types of variables in the Target and arguments textbox.&lt;/li&gt;&lt;li&gt;Select the Add button.&lt;/li&gt;&lt;li&gt;Select the Save button.&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21550" alt="editor.png" /&gt;&lt;br /&gt;&lt;h2&gt;
Targets
&lt;/h2&gt;MSBuildShellExtension comes with three types of targets (Build, Clean and Rebuild) for each of the default file types. Theese targets can be modified or removed and new targets can be added. This is done through the Targets section in the MSBuild Shell Extension Configurator. New targets are added like this:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;/li&gt;&lt;li&gt;Select the Targets icon.&lt;/li&gt;&lt;li&gt;Select the New button.&lt;/li&gt;&lt;li&gt;Type a name for the target in the Title textbox.&lt;/li&gt;&lt;li&gt;Type the name of the target. This is the target name as specified in the MSBuild file.&lt;/li&gt;&lt;li&gt;Select a verbosity for the target in the Verbosity combobox.&lt;/li&gt;&lt;li&gt;Select the configuration for the target in the Configuration combobox.&lt;/li&gt;&lt;li&gt;Unselect the Show error list checkbox, if you don't want to show the error list window when executing builds through MSBuild Shell Extension.&lt;/li&gt;&lt;li&gt;Select the Add button.&lt;/li&gt;&lt;li&gt;Select the Save button.&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21551" alt="target.png" /&gt;&lt;br /&gt;&lt;h2&gt;
Extensions
&lt;/h2&gt;Last, but not least, you are able to extend the shell extension to file extensions of your choise. As default a number of MSBuild extensions are added, but you can add your own file extension like this:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;/li&gt;&lt;li&gt;Select the Extensions icon.&lt;/li&gt;&lt;li&gt;Select the New button.&lt;/li&gt;&lt;li&gt;Type in the file extension in the File extension textbox. The file extension should not contain a '.' before the extension name.&lt;/li&gt;&lt;li&gt;Select the Targets which should be enabled for the new file extension. Each target selected, results in an additional menuitem at the context menu of the specified file extension.&lt;/li&gt;&lt;li&gt;Select the Add button.&lt;/li&gt;&lt;li&gt;Select the Save button.&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=28838" alt="extension.png" /&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Sat, 01 Mar 2008 09:08:11 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Manual 20080301090811A</guid></item><item><title>UPDATED WIKI: Manual</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;version=7</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=Manual"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=Manual"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;i&gt;Manual&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;amp;referringTitle=Manual"&gt;MSBuild Tutorial&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=Manual"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=Manual"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=Manual"&gt;RSS&lt;/a&gt;&lt;br /&gt;&lt;h1&gt;
Manual
&lt;/h1&gt;This short manual tries to explain the basic concepts in MSBuildShellExtension.&lt;br /&gt;&lt;h2&gt;
Editor
&lt;/h2&gt;When double clicking on a file with warning/error in the MSBuildShellExtension error list window, an editor of your choices opens. MSBuildShellExtension comes with two pre-installed templates for Visual Studio 2005 and Notepad. It is possible to extend the tool with more templates. This is done through the MSBuild Shell Extension Configurator:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;/li&gt;&lt;li&gt;Select the Editor icon.&lt;/li&gt;&lt;li&gt;Select the New button.&lt;/li&gt;&lt;li&gt;Type a name for the external tool in the Title textbox.&lt;/li&gt;&lt;li&gt;Select the Default checkbox, if this tool should be used as the external tool for opening source files from within the error list window.&lt;/li&gt;&lt;li&gt;Add the path to the external tool in the Target and arguments textbox. The external tool should as a minimum support a command line parameter for specifying the file containing error/warning. You can use the Variables button to insert different types of variables in the Target and arguments textbox.&lt;/li&gt;&lt;li&gt;Select the Add button.&lt;/li&gt;&lt;li&gt;Select the Save button.&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21550" alt="editor.png" /&gt;&lt;br /&gt;&lt;h2&gt;
Targets
&lt;/h2&gt;MSBuildShellExtension comes with three types of targets (Build, Clean and Rebuild) for each of the default file types. Theese targets can be modified or removed and new targets can be added. This is done through the Targets section in the MSBuild Shell Extension Configurator. New targets are added like this:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;/li&gt;&lt;li&gt;Select the Targets icon.&lt;/li&gt;&lt;li&gt;Select the New button.&lt;/li&gt;&lt;li&gt;Type a name for the target in the Title textbox.&lt;/li&gt;&lt;li&gt;Type the name of the target. This is the target name as specified in the MSBuild file.&lt;/li&gt;&lt;li&gt;Select a verbosity for the target in the Verbosity combobox.&lt;/li&gt;&lt;li&gt;Select the configuration for the target in the Configuration combobox.&lt;/li&gt;&lt;li&gt;Unselect the Show error list checkbox, if you don't want to show the error list window when executing builds through MSBuild Shell Extension.&lt;/li&gt;&lt;li&gt;Select the Add button.&lt;/li&gt;&lt;li&gt;Select the Save button.&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21551" alt="target.png" /&gt;&lt;br /&gt;&lt;h2&gt;
Extensions
&lt;/h2&gt;Last, but not least, you are able to extend the shell extension to file extensions of your choise. As default a number of MSBuild extensions are added, but you can add your own file extension like this:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;/li&gt;&lt;li&gt;Select the Extensions icon.&lt;/li&gt;&lt;li&gt;Select the New button.&lt;/li&gt;&lt;li&gt;Type in the file extension in the File extension textbox. The file extension should not contain a '.' before the extension name.&lt;/li&gt;&lt;li&gt;Select the Targets which should be enabled for the new file extension. Each target selected, results in an additional menuitem at the context menu of the specified file extension.&lt;/li&gt;&lt;li&gt;Select the Add button.&lt;/li&gt;&lt;li&gt;Select the Save button.&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21552" alt="extension.png" /&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Sat, 01 Mar 2008 09:07:28 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Manual 20080301090728A</guid></item><item><title>UPDATED WIKI: MSBuild Tutorial</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild Tutorial&amp;version=15</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Manual&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;i&gt;MSBuild Tutorial&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
MSBuild Tutorial
&lt;/h1&gt;This page gives a short introduction to the MSBuild tool. The tutorial is protected under copyright law and may not be published without permission from the MSBuildShellExtension coordinators at the CodePlex site.&lt;br /&gt;&lt;h2&gt;
Table of Contents
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#MSBuild%20Basics"&gt;MSBuild Basics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Properties"&gt;Properties&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Items"&gt;Items&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Conditions"&gt;Conditions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Frequently%20Used%20Tasks"&gt;Frequently Used Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Custom%20MSBuild%20Tasks"&gt;Custom MSBuild Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Generic%20Targets"&gt;Generic Targets&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Links"&gt;Links&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;a name="MSBuild Basics"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
MSBuild Basics
&lt;/h2&gt;.NET 2.0 contains a new tool called MSBuild. MSBuild is primarily used to build .NET application, but can be used for other types of applications as well. From Windows Vista, MSBuild is distributed with Windows itself, making it a strong platform for implementing scriptet application on non-developer PCs as well.&lt;br /&gt; &lt;br /&gt;Before .NET 2.0, application were build by one or more of these strategies:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Using the build menu from inside Visual Studio&lt;/li&gt;&lt;li&gt;Using the devenv.exe process from the command line with some extra parameters&lt;/li&gt;&lt;li&gt;Using a third-party tool like NAnt (which MSBuild is based on)&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;The drawback with the first two strategies was, that it was hard to script. The drawback with the third solution was, that two build environments had to be held in sync and maintained. .NET 2.0 Visual Studio projects are now implemented in the MSBuild language, but MSBuild have no dependencies to Visual Studio itself. MSBuild can in theory be implemented in all types of file extension, but a number of formats seems to by the supported standard from Microsoft: csproj, vbproj, vcproj, vjsproj, proj, .targets. The first four are different types of project files for Visual Studio, while the last two is new extensions, which are either written in hand or with a tool knowing the MSBuild syntax. A few tools exists for this purpose. My personally opinion is, that the build in xml editor in Visual Studio, is quite good for this purpose. A repeating question among MSBuild developers is, if you should extend the files generated by visual studio with new stuff or you should write your own containing your home-made MSBuild scripts. My personally opinion is to let Visual Studio generate its own projects (example: csproj files) and create you home-made scripts in a .proj file with the same name as the project. I usually start the .proj file by implementing the three targets: Clean, Build and Rebuild, which basically just calls the similar targets in the .csproj file. In this way you avoid updating a auto-generated file, which you basically don’t have control over.&lt;br /&gt; &lt;br /&gt;An MSBuild file is implemented in XML. The root element of a MSBuild XML file will always be a project containing target elements. It is possible to run multiple targets in a MSBuild file. When the MSBuild script is started from the command line, it takes a build file as parameter, as well as the names of the targets, which should be executed.&lt;br /&gt; &lt;br /&gt;A target is implemented as a sequential list of tasks. The tasks is executed in the same order, as they are specified beneath the target element. Both targets and tasks can be dependant on each other.&lt;br /&gt; &lt;br /&gt;This is an example of a very simple build file to build a .NET project:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;The example defines a project with the MSBuild namespace. Using the namespace helps you develop the build file in Visual Studio using Intellisence. The build file contains a single targets named Build. This target contains two tasks: Message and MSBuild. Message outputs a message to the console and is primarily used for debug purposes. MSBuild runs a configurable number of targets on another build file. Caused by that fact, that the .csproj file is also implement in MSBuild, we are able to call targets in the build file, from the example build file. In this case we call the target Build in the .csproj file. All projects generated by Visual Studio automatically implements the Clean, Build and Rebuild targets. These targets are actually executed, when you select the similar commands in the Build menu from within Visual Studio.&lt;br /&gt;&lt;a name="Properties"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Properties
&lt;/h2&gt;To be able to parameterise a build script, MSBuild have implemented properties. A property is a simple key/value type, which can be used from multiple locations in the scripts. Lets look at an example using properties:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;.\bin\debug\msbuildintro.exe&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;The example defines a property defined in a property group. Properties can be defined both outside and inside scope of a target. When a property is defined like this example, the value of the property is assigned before executing the actual targets. In the example, I define a property called MyReleaseOutput and add the value .\release.&lt;br /&gt;In this example I have added two targets as well: Build and Release. The Build target is similar to the one specified in the previous example, while the Release target is new. The Release target introduces a new attribute called DependsOnTargets, which is the way to define dependencies between targets in MSBuild. In this case we tell MSBuild to run the Build target before running the Release targets. If you run the Build target manually before running the Release target, the Build target is only run once.&lt;br /&gt; &lt;br /&gt;The release target introduces two new tasks as well: MakeDir which (well you guessed it) creates a new directory and Copy, which copies on or more files from A to B. MakeDir contain a single attribute, defining the path of the new directory. In this example, that path is the value of the MyReleaseOutput property. Notice the use of the $(propertyname) syntax here. $() is used to reference properties in MSBuild. The copy task in our example points out a single file and the destination folder where this file should be copied to, when executing the Release target. The $(MyReleaseOutput) used is yet again replaced by the value of this property.&lt;br /&gt;&lt;a name="Items"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Items
&lt;/h2&gt;The example above copied a single file from one directory to another. This can certainly be useful in many situation, but other times this is simple not flexible enough. This is were items comes in. An item gives the possibility to create dynamic lists of for instance file names. Lets start by looking at an example:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;MyReleaseFiles Include=&amp;quot;.\bin\debug\*.*&amp;quot; /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;We start by defining an ItemGroup outside scope of a target. This means, that the content is calculated before actually running any targets. In this example I define an ItemGroup containing a single item called MyReleaseFiles. The item contains a single attribute called Include, which acts as a filter for the generated file list. In this case all files beneath the bin\debug directory. I use this item in the copy task beneath the Release target to point out which files should be copied when doing a release. &lt;br /&gt; &lt;br /&gt;The Include filter decided which file to include. We also have the possibility to specify an Exclude filter. The following example shows how:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;MyReleaseFiles Include=&amp;quot;.\bin\debug\*.*&amp;quot; Exclude=&amp;quot;.\bin\debug\*vshost.exe&amp;quot; /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;I added an Exlude attribute to my MyReleaseFiles item. The exclude in this examples excludes all files beneath the bin\debug directory, which ends with vshost.exe. An item containing both Include and Exclude, will be generated by taking all the files specified in the Include and subtracting the files specified in the Exlude.&lt;br /&gt; &lt;br /&gt;The last two examples of using items are actually not that usefull. This is caused by the fact that the content for the MyReleaseFiles item is generated before running the actual targets. This means, that on a new checkout or after a clean, no files exists in the bin\debug directory. The generated file list will therefore be completely empty. Bummer! Let us fix the example. We define a new item inside the scope of a target instead:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;CreateItem Include=&amp;quot;.\bin\debug\*.*&amp;quot; Exclude=&amp;quot;.\bin\debug\*vshost.exe&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Include&amp;quot; ItemName=&amp;quot;MyReleaseFiles&amp;quot;/&amp;gt;
    &amp;lt;/CreateItem&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;I moved the MyReleaseOutput item inside the Release target. This is done using the CreateItem task. The CreateItem task creates a new item on the fly, which means that the content is generated at the point in time, where the CreateItem task is executed. Notice that the CreateItem task contains an Output element. The Output element is used a lot of different places in MSBuild, where a target is able to output some data. In this case is use the ItemName attribute to define the name from the previous example. &lt;br /&gt; &lt;br /&gt;Anyone still reading? If you have read this far, you derserve a little price:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20133" alt="dilbert2002444471010.gif" /&gt;&lt;br /&gt;&lt;a name="Conditions"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Conditions
&lt;/h2&gt;Besides the CreateItem task in a previous example, out build scripts have been very static until now. This can be sufficient in a lot of projects. Some times you need a little more flexible build scripts, though. A feature for fulfilling this in MSBuild is called Conditions. A condition in MSBuild is not that different that a condition in other software languages. It is a possibility to make more flexible structures for instance avoid running targets and/or tasks when certain conditions are met. You can define conditions on all targets and almost all tasks. Lets check out another example:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
    &amp;lt;Configuration Condition=&amp;quot; '$(Configuration)' == '' &amp;quot;&amp;gt;Debug&amp;lt;/Configuration&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro $(Configuration)&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot; Condition=&amp;quot;$(Configuration) == 'Release'&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;CreateItem Include=&amp;quot;.\bin\$(Configuration)\*.*&amp;quot; Exclude=&amp;quot;.\bin\$(Configuration)\*vshost.exe&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Include&amp;quot; ItemName=&amp;quot;MyReleaseFiles&amp;quot; /&amp;gt;
    &amp;lt;/CreateItem&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;I added a lot of new stuff here. But of course you are already quite an MSBuild expert, so I think you will manage. First of all, I have added a new property named Configuration. This property contains a condition attribute, which determines the value of the property at runtime. If the Configuration property has not been set up front, the value of the attribute is set to Debug. Properties can be set up front by using a special syntax on the command line:&lt;br /&gt; &lt;br /&gt;&lt;span class="codeInline"&gt; Msbuild.exe build.proj /p:Configuration=Debug /t:release &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;More new stuff. I changed all references to the debug, with the value of the new Configuration property. This means that I am now able to run the script in both Debug and Release mode.&lt;br /&gt; &lt;br /&gt;The last new addition is the condition attribute on the release target. This conditions examines if the value of the Configuration property is Release and only allows execution of the Release target, if this condition turns out true.&lt;br /&gt;&lt;a name="Frequently Used Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Frequently Used Tasks
&lt;/h2&gt;CallTarget – Executes another target inside the current build file. Used in places, where a target needs to call another target at a specific place inside the target itself. If the target where just dependant of the other target being executed, we would use the DependsOnTargets attribute instead.&lt;br /&gt; &lt;br /&gt;Copy – We already saw this task in action. Copies one or more files from A to B.&lt;br /&gt; &lt;br /&gt;CreateItem – Create dynamic items.&lt;br /&gt; &lt;br /&gt;CreateProperty – Create dynamic properties.&lt;br /&gt; &lt;br /&gt;Delete – Deletes on or more files.&lt;br /&gt; &lt;br /&gt;Exec – Executes an external process. This is typically used to executed external tools, which did not implement MSBuild targets themself.&lt;br /&gt; &lt;br /&gt;MakeDir – Creates one or more directories.&lt;br /&gt; &lt;br /&gt;Message – Outputs a message to the console.&lt;br /&gt; &lt;br /&gt;MSBuild – Executes one or more targets in an external MSBuild file.&lt;br /&gt; &lt;br /&gt;RemoveDir – Removes one or more directories.&lt;br /&gt; &lt;br /&gt;And there are a lot more.&lt;br /&gt;&lt;a name="Custom MSBuild Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Custom MSBuild Tasks
&lt;/h2&gt;It is possible to write your own MSBuild tasks. This can be extremely useful, if you want to integrate some of your own tools with MSBuild or if you need to do stuff, which is not yet supported by MSBuild. The following example shows how to write a simple addition task:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
using System;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
namespace MyTasks
{
  public class AddTask : Task
  {
    private int number1;
    [Required]
    public int Number1
    {
      get { return number1; }
      set { number1 = value; }
    }
    private int number2;
    [Required]
    public int Number2
    {
      get { return number2; }
      set { number2 = value; }
    }
    private int sum;
    [Output]
    public int Sum
    {
      get { return sum; }
      set { sum = value; }
    }
    public override bool Execute()
    {
      try
      {
        sum = number1 + number2;
      }
      catch (ArithmeticException e)
      {
        Console.WriteLine(&amp;quot;Error occured during addition: {0}&amp;quot;, e.Message);
        return false;
      }
      return true;
    }
  }
}
&lt;/pre&gt; &lt;br /&gt;I start by defining the AddTask class which extends the Task class from the MSBuild API. By extending this task, I don’t need to worry about implementing conditions etc.&lt;br /&gt;I defined two properties, which acts as out input variables to the addition task: Number1 and Number2. Both properties are marked with the Required attribute, which tells the script to fail, if these properties are not specified. An output property is added as well. The value of this property will be available within the build script. Let’s see how to use this new and fancy task:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;UsingTask TaskName=&amp;quot;MyTasks.AddTask&amp;quot; AssemblyFile=&amp;quot;.\AddTask.dll&amp;quot;/&amp;gt;
  &amp;lt;Target Name=&amp;quot;Addition&amp;quot;&amp;gt;
    &amp;lt;AddTask Number1=&amp;quot;10&amp;quot; Number2=&amp;quot;12&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Sum&amp;quot; PropertyName=&amp;quot;CalculatedSum&amp;quot; /&amp;gt;
    &amp;lt;/AddTask&amp;gt;
    &amp;lt;Message Text=&amp;quot;10 + 12 = $(CalculatedSum)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;Because my AddTask in an external task not build into the MSBuild framework, I use the UsingTask element to reference it. The name of the task as well as the assembly name is specified.&lt;br /&gt; &lt;br /&gt;The Addition target uses the AddTask with the two Number properties as attributes. The Output element copies the result of the task to a property called CalculatedSum. This property is accessible in the Message task for output on the console.&lt;br /&gt; &lt;br /&gt;You just implemented your first custom MSBuild task. Pretty easy, right?&lt;br /&gt;&lt;a name="Generic Targets"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Generic Targets
&lt;/h2&gt;Once in a while a question keeps popping up in different forums: How do I parameterize a common part of my script, making it possible to use it from different targets? This is a great question. We don't wan't to have the same lines of code spread around our build script, making it longer than necessary and complex to maintain. MSBuild provides the CallTarget task, which executes another target inside the current build file. Unfortunately there is no way to parameterize the CallTarget task, making it unusable for other than simple stuff, where needed tasks are 100% identical.&lt;br /&gt; &lt;br /&gt;Let's look at and example, where we have two targets with some identical tasks:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target1&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from Target1&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target2&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from Target2&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;In the example we define two targets: Target1 and Target2. You will probably notice, that the targets look very similar. The only difference is the text inside the Message task. This is a simple example of the problem and of course changing the text in both message tasks would be fairly simple. But you probably understand the problem here: It would be nice to refactor the targets (let's call it &amp;quot;Extract Target&amp;quot;), so that the Hello World text will only be specified once. First of all we need to move the common tasks to a new target:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;Target Name=&amp;quot;PrintMessage&amp;quot;&amp;gt;
  &amp;lt;Message Text=&amp;quot;Hello World from X&amp;quot; /&amp;gt;
&amp;lt;/Target&amp;gt;
&lt;/pre&gt; &lt;br /&gt;Notice the replaced part of the Text with the X. Now we need to call this target, making sure that X will be replaced with the correct string. For this purpose we use another task called MSBuild. The MSBuild task was originally produced to be able to call targets inside other MSBuild scripts. The great thing about the MSBuild task is, that it has the capability to receive properties. In order to call our PrintMessage target and print the correct string, we parameterize the target like this:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target1&amp;quot;&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;$(MSBuildProjectFile)&amp;quot; Targets=&amp;quot;PrintMessage&amp;quot; Properties=&amp;quot;Caller=Target1&amp;quot;/&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target2&amp;quot;&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;$(MSBuildProjectFile)&amp;quot; Targets=&amp;quot;PrintMessage&amp;quot; Properties=&amp;quot;Caller=Target2&amp;quot;/&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;PrintMessage&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from $(Caller)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;We use the MSBuild tasks in both Target1 and Target2. The $(MSBuildProjectFile) is a build-in property in MSBuild, which returns the filename of the current build file. What we do here is, that we call the PrintMessage task on this. The properties attribute specify a single property named Caller. Multiple properties can be specified inside this attribute by separating them with semi colon. In the PrintMessage task we simple print the message with the Caller property specified inside the Text attribute.&lt;br /&gt;&lt;a name="Links"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Links
&lt;/h2&gt;The MSBuild documentation is actually quite good and a must for all serious MSBuild developers: &lt;a href="http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx" class="externalLink"&gt;http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;A lot of different tools for handling MSBuild files exists. I haven’t been able to find a tool, making it possible to run build scripts from within Visual Studio. You could start by installing the MSBuildShellExtension tool from: &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;MSBuildShellExtension&lt;/a&gt;.&lt;br /&gt; &lt;br /&gt;Besides the build in tasks in MSBuild, there is a great community project, implementing a lot of nice tasks not implemented by Microsoft. Targets for search and replace, zipping, sending out mails, modifying subversion etc., can be found here: &lt;a href="http://msbuildtasks.tigris.org/" class="externalLink"&gt;http://msbuildtasks.tigris.org/&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Fri, 08 Feb 2008 13:41:26 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: MSBuild Tutorial 20080208014126P</guid></item><item><title>UPDATED WIKI: MSBuild Tutorial</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild Tutorial&amp;version=14</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Manual&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;i&gt;MSBuild Tutorial&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
MSBuild Tutorial
&lt;/h1&gt;This page gives a short introduction to the MSBuild tool. The tutorial is protected under copyright law and may not be published without permission from the MSBuildShellExtension coordinators at the CodePlex site.&lt;br /&gt;&lt;h2&gt;
Table of Contents
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#MSBuild%20Basics"&gt;MSBuild Basics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Properties"&gt;Properties&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Items"&gt;Items&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Conditions"&gt;Conditions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Frequently%20Used%20Tasks"&gt;Frequently Used Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Custom%20MSBuild%20Tasks"&gt;Custom MSBuild Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Generic%20Targets"&gt;Generic Targets&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Links"&gt;Links&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;a name="MSBuild Basics"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
MSBuild Basics
&lt;/h2&gt;.NET 2.0 contains a new tool called MSBuild. MSBuild is primarily used to build .NET application, but can be used for other types of applications as well. From Windows Vista, MSBuild is distributed with Windows itself, making it a strong platform for implementing scriptet application on non-developer PCs as well.&lt;br /&gt; &lt;br /&gt;Before .NET 2.0, application were build by one or more of these strategies:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Using the build menu from inside Visual Studio&lt;/li&gt;&lt;li&gt;Using the devenv.exe process from the command line with some extra parameters&lt;/li&gt;&lt;li&gt;Using a third-party tool like NAnt (which MSBuild is based on)&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;The drawback with the first two strategies was, that it was hard to script. The drawback with the third solution was, that two build environments had to be held in sync and maintained. .NET 2.0 Visual Studio projects are now implemented in the MSBuild language, but MSBuild have no dependencies to Visual Studio itself. MSBuild can in theory be implemented in all types of file extension, but a number of formats seems to by the supported standard from Microsoft: csproj, vbproj, vcproj, vjsproj, proj, .targets. The first four are different types of project files for Visual Studio, while the last two is new extensions, which are either written in hand or with a tool knowing the MSBuild syntax. A few tools exists for this purpose. My personally opinion is, that the build in xml editor in Visual Studio, is quite good for this purpose. A repeating question among MSBuild developers is, if you should extend the files generated by visual studio with new stuff or you should write your own containing your home-made MSBuild scripts. My personally opinion is to let Visual Studio generate its own projects (example: csproj files) and create you home-made scripts in a .proj file with the same name as the project. I usually start the .proj file by implementing the three targets: Clean, Build and Rebuild, which basically just calls the similar targets in the .csproj file. In this way you avoid updating a auto-generated file, which you basically don’t have control over.&lt;br /&gt; &lt;br /&gt;An MSBuild file is implemented in XML. The root element of a MSBuild XML file will always be a project containing target elements. It is possible to run multiple targets in a MSBuild file. When the MSBuild script is started from the command line, it takes a build file as parameter, as well as the names of the targets, which should be executed.&lt;br /&gt; &lt;br /&gt;A target is implemented as a sequential list of tasks. The tasks is executed in the same order, as they are specified beneath the target element. Both targets and tasks can be dependant on each other.&lt;br /&gt; &lt;br /&gt;This is an example of a very simple build file to build a .NET project:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;The example defines a project with the MSBuild namespace. Using the namespace helps you develop the build file in Visual Studio using Intellisence. The build file contains a single targets named Build. This target contains two tasks: Message and MSBuild. Message outputs a message to the console and is primarily used for debug purposes. MSBuild runs a configurable number of targets on another build file. Caused by that fact, that the .csproj file is also implement in MSBuild, we are able to call targets in the build file, from the example build file. In this case we call the target Build in the .csproj file. All projects generated by Visual Studio automatically implements the Clean, Build and Rebuild targets. These targets are actually executed, when you select the similar commands in the Build menu from within Visual Studio.&lt;br /&gt;&lt;a name="Properties"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Properties
&lt;/h2&gt;To be able to parameterise a build script, MSBuild have implemented properties. A property is a simple key/value type, which can be used from multiple locations in the scripts. Lets look at an example using properties:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;.\bin\debug\msbuildintro.exe&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;The example defines a property defined in a property group. Properties can be defined both outside and inside scope of a target. When a property is defined like this example, the value of the property is assigned before executing the actual targets. In the example, I define a property called MyReleaseOutput and add the value .\release.&lt;br /&gt;In this example I have added two targets as well: Build and Release. The Build target is similar to the one specified in the previous example, while the Release target is new. The Release target introduces a new attribute called DependsOnTargets, which is the way to define dependencies between targets in MSBuild. In this case we tell MSBuild to run the Build target before running the Release targets. If you run the Build target manually before running the Release target, the Build target is only run once.&lt;br /&gt; &lt;br /&gt;The release target introduces two new tasks as well: MakeDir which (well you guessed it) creates a new directory and Copy, which copies on or more files from A to B. MakeDir contain a single attribute, defining the path of the new directory. In this example, that path is the value of the MyReleaseOutput property. Notice the use of the $(propertyname) syntax here. $() is used to reference properties in MSBuild. The copy task in our example points out a single file and the destination folder where this file should be copied to, when executing the Release target. The $(MyReleaseOutput) used is yet again replaced by the value of this property.&lt;br /&gt;&lt;a name="Items"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Items
&lt;/h2&gt;The example above copied a single file from one directory to another. This can certainly be useful in many situation, but other times this is simple not flexible enough. This is were items comes in. An item gives the possibility to create dynamic lists of for instance file names. Lets start by looking at an example:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;MyReleaseFiles Include=&amp;quot;.\bin\debug\*.*&amp;quot; /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;We start by defining an ItemGroup outside scope of a target. This means, that the content is calculated before actually running any targets. In this example I define an ItemGroup containing a single item called MyReleaseFiles. The item contains a single attribute called Include, which acts as a filter for the generated file list. In this case all files beneath the bin\debug directory. I use this item in the copy task beneath the Release target to point out which files should be copied when doing a release. &lt;br /&gt; &lt;br /&gt;The Include filter decided which file to include. We also have the possibility to specify an Exclude filter. The following example shows how:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;MyReleaseFiles Include=&amp;quot;.\bin\debug\*.*&amp;quot; Exclude=&amp;quot;.\bin\debug\*vshost.exe&amp;quot; /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;I added an Exlude attribute to my MyReleaseFiles item. The exclude in this examples excludes all files beneath the bin\debug directory, which ends with vshost.exe. An item containing both Include and Exclude, will be generated by taking all the files specified in the Include and subtracting the files specified in the Exlude.&lt;br /&gt; &lt;br /&gt;The last two examples of using items are actually not that usefull. This is caused by the fact that the content for the MyReleaseFiles item is generated before running the actual targets. This means, that on a new checkout or after a clean, no files exists in the bin\debug directory. The generated file list will therefore be completely empty. Bummer! Let us fix the example. We define a new item inside the scope of a target instead:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;CreateItem Include=&amp;quot;.\bin\debug\*.*&amp;quot; Exclude=&amp;quot;.\bin\debug\*vshost.exe&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Include&amp;quot; ItemName=&amp;quot;MyReleaseFiles&amp;quot;/&amp;gt;
    &amp;lt;/CreateItem&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;I moved the MyReleaseOutput item inside the Release target. This is done using the CreateItem task. The CreateItem task creates a new item on the fly, which means that the content is generated at the point in time, where the CreateItem task is executed. Notice that the CreateItem task contains an Output element. The Output element is used a lot of different places in MSBuild, where a target is able to output some data. In this case is use the ItemName attribute to define the name from the previous example. &lt;br /&gt; &lt;br /&gt;Anyone still reading? If you have read this far, you derserve a little price:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20133" alt="dilbert2002444471010.gif" /&gt;&lt;br /&gt;&lt;a name="Conditions"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Conditions
&lt;/h2&gt;Besides the CreateItem task in a previous example, out build scripts have been very static until now. This can be sufficient in a lot of projects. Some times you need a little more flexible build scripts, though. A feature for fulfilling this in MSBuild is called Conditions. A condition in MSBuild is not that different that a condition in other software languages. It is a possibility to make more flexible structures for instance avoid running targets and/or tasks when certain conditions are met. You can define conditions on all targets and almost all tasks. Lets check out another example:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
    &amp;lt;Configuration Condition=&amp;quot; '$(Configuration)' == '' &amp;quot;&amp;gt;Debug&amp;lt;/Configuration&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro $(Configuration)&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot; Condition=&amp;quot;$(Configuration) == 'Release'&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;CreateItem Include=&amp;quot;.\bin\$(Configuration)\*.*&amp;quot; Exclude=&amp;quot;.\bin\$(Configuration)\*vshost.exe&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Include&amp;quot; ItemName=&amp;quot;MyReleaseFiles&amp;quot; /&amp;gt;
    &amp;lt;/CreateItem&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;I added a lot of new stuff here. But of course you are already quite an MSBuild expert, so I think you will manage. First of all, I have added a new property named Configuration. This property contains a condition attribute, which determines the value of the property at runtime. If the Configuration property has not been set up front, the value of the attribute is set to Debug. Properties can be set up front by using a special syntax on the command line:&lt;br /&gt; &lt;br /&gt;&lt;span class="codeInline"&gt; Msbuild.exe build.proj /p:Configuration=Debug /t:release &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;More new stuff. I changed all references to the debug, with the value of the new Configuration property. This means that I am now able to run the script in both Debug and Release mode.&lt;br /&gt; &lt;br /&gt;The last new addition is the condition attribute on the release target. This conditions examines if the value of the Configuration property is Release and only allows execution of the Release target, if this condition turns out true.&lt;br /&gt;&lt;a name="Frequently Used Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Frequently Used Tasks
&lt;/h2&gt;CallTarget – Executes another target inside the current build file. Used in places, where a target needs to call another target at a specific place inside the target itself. If the target where just dependant of the other target being executed, we would use the DependsOnTargets attribute instead.&lt;br /&gt; &lt;br /&gt;Copy – We already saw this task in action. Copies one or more files from A to B.&lt;br /&gt; &lt;br /&gt;CreateItem – Create dynamic items.&lt;br /&gt; &lt;br /&gt;CreateProperty – Create dynamic properties.&lt;br /&gt; &lt;br /&gt;Delete – Deletes on or more files.&lt;br /&gt; &lt;br /&gt;Exec – Executes an external process. This is typically used to executed external tools, which did not implement MSBuild targets themself.&lt;br /&gt; &lt;br /&gt;MakeDir – Creates one or more directories.&lt;br /&gt; &lt;br /&gt;Message – Outputs a message to the console.&lt;br /&gt; &lt;br /&gt;MSBuild – Executes one or more targets in an external MSBuild file.&lt;br /&gt; &lt;br /&gt;RemoveDir – Removes one or more directories.&lt;br /&gt; &lt;br /&gt;And there are a lot more.&lt;br /&gt;&lt;a name="Custom MSBuild Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Custom MSBuild Tasks
&lt;/h2&gt;It is possible to write your own MSBuild tasks. This can be extremely useful, if you want to integrate some of your own tools with MSBuild or if you need to do stuff, which is not yet supported by MSBuild. The following example shows how to write a simple addition task:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
using System;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
namespace MyTasks
{
  public class AddTask : Task
  {
    private int number1;
    [Required]
    public int Number1
    {
      get { return number1; }
      set { number1 = value; }
    }
    private int number2;
    [Required]
    public int Number2
    {
      get { return number2; }
      set { number2 = value; }
    }
    private int sum;
    [Output]
    public int Sum
    {
      get { return sum; }
      set { sum = value; }
    }
    public override bool Execute()
    {
      try
      {
        sum = number1 + number2;
      }
      catch (ArithmeticException e)
      {
        Console.WriteLine(&amp;quot;Error occured during addition: {0}&amp;quot;, e.Message);
        return false;
      }
      return true;
    }
  }
}
&lt;/pre&gt; &lt;br /&gt;I start by defining the AddTask class which extends the Task class from the MSBuild API. By extending this task, I don’t need to worry about implementing conditions etc.&lt;br /&gt;I defined two properties, which acts as out input variables to the addition task: Number1 and Number2. Both properties are marked with the Required attribute, which tells the script to fail, if these properties are not specified. An output property is added as well. The value of this property will be available within the build script. Let’s see how to use this new and fancy task:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;UsingTask TaskName=&amp;quot;MyTasks.AddTask&amp;quot; AssemblyFile=&amp;quot;.\AddTask.dll&amp;quot;/&amp;gt;
  &amp;lt;Target Name=&amp;quot;Addition&amp;quot;&amp;gt;
    &amp;lt;AddTask Number1=&amp;quot;10&amp;quot; Number2=&amp;quot;12&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Sum&amp;quot; PropertyName=&amp;quot;CalculatedSum&amp;quot; /&amp;gt;
    &amp;lt;/AddTask&amp;gt;
    &amp;lt;Message Text=&amp;quot;10 + 12 = $(CalculatedSum)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;Because my AddTask in an external task not build into the MSBuild framework, I use the UsingTask element to reference it. The name of the task as well as the assembly name is specified.&lt;br /&gt; &lt;br /&gt;The Addition target uses the AddTask with the two Number properties as attributes. The Output element copies the result of the task to a property called CalculatedSum. This property is accessible in the Message task for output on the console.&lt;br /&gt; &lt;br /&gt;You just implemented your first custom MSBuild task. Pretty easy, right?&lt;br /&gt;&lt;a name="Generic Targets"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Generic Targets
&lt;/h2&gt;Once in a while a question keeps popping up in different forums: How do I parameterize a common part of my script, making it possible to use it from different targets? This is a great question. We don't wan't to have the same lines of code spread around our build script, making it longer than necessary and complex to maintain. MSBuild contains the CallTarget task, which executes another target inside the current build file. Unfortunately there is no way to parameterize the CallTarget task, making it unusable for other than simple stuff, where needed tasks are 100% identical.&lt;br /&gt; &lt;br /&gt;Let's look at and example, where we have two targets with some identical tasks:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target1&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from Target1&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target2&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from Target2&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;In the example we define two targets: Target1 and Target2. You will probably notice, that the targets look very similar. The only difference is the text inside the Message task. This is a simple example of the problem and of course changing the text in both message tasks would be fairly simple. But you probably understand the problem here: It would be nice to refactor the targets (let's call it &amp;quot;Extract Target&amp;quot;), so that the Hello World text will only be specified once. First of all we need to move the common tasks to a new target:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;Target Name=&amp;quot;PrintMessage&amp;quot;&amp;gt;
  &amp;lt;Message Text=&amp;quot;Hello World from X&amp;quot; /&amp;gt;
&amp;lt;/Target&amp;gt;
&lt;/pre&gt; &lt;br /&gt;Notice the replaced part of the Text with the X. Now we need to call this target, making sure that X will be replaced with the correct string. For this purpose we use another task called MSBuild. The MSBuild task was originally produced to be able to call targets inside other MSBuild scripts. The great thing about the MSBuild task is, that it has the capability to receive properties. In order to call our PrintMessage target and print the correct string, we parameterize the target like this:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target1&amp;quot;&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;$(MSBuildProjectFile)&amp;quot; Targets=&amp;quot;PrintMessage&amp;quot; Properties=&amp;quot;Caller=Target1&amp;quot;/&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target2&amp;quot;&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;$(MSBuildProjectFile)&amp;quot; Targets=&amp;quot;PrintMessage&amp;quot; Properties=&amp;quot;Caller=Target2&amp;quot;/&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;PrintMessage&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from $(Caller)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;We use the MSBuild tasks in both Target1 and Target2. The $(MSBuildProjectFile) is a build-in property in MSBuild, which returns the filename of the current build file. What we do here is, that we call the PrintMessage task on this. The properties attribute specify a single attribute name Caller. Multiple properties can be specified inside this attribute by separating them with semi colon. In the PrintMessage task we simple print the message with the Caller property specified inside the Text attribute.&lt;br /&gt;&lt;a name="Links"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Links
&lt;/h2&gt;The MSBuild documentation is actually quite good and a must for all serious MSBuild developers: &lt;a href="http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx" class="externalLink"&gt;http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;A lot of different tools for handling MSBuild files exists. I haven’t been able to find a tool, making it possible to run build scripts from within Visual Studio. You could start by installing the MSBuildShellExtension tool from: &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;MSBuildShellExtension&lt;/a&gt;.&lt;br /&gt; &lt;br /&gt;Besides the build in tasks in MSBuild, there is a great community project, implementing a lot of nice tasks not implemented by Microsoft. Targets for search and replace, zipping, sending out mails, modifying subversion etc., can be found here: &lt;a href="http://msbuildtasks.tigris.org/" class="externalLink"&gt;http://msbuildtasks.tigris.org/&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Fri, 08 Feb 2008 13:30:18 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: MSBuild Tutorial 20080208013018P</guid></item><item><title>UPDATED WIKI: MSBuild Tutorial</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild Tutorial&amp;version=13</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Manual&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;i&gt;MSBuild Tutorial&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20144" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
MSBuild Tutorial
&lt;/h1&gt;This page gives a short introduction to the MSBuild tool. The tutorial is protected under copyright law and may not be published without permission from the MSBuildShellExtension coordinators at the CodePlex site.&lt;br /&gt;&lt;h2&gt;
Table of Contents
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#MSBuild%20Basics"&gt;MSBuild Basics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Properties"&gt;Properties&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Items"&gt;Items&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Conditions"&gt;Conditions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Frequently%20Used%20Tasks"&gt;Frequently Used Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Custom%20MSBuild%20Tasks"&gt;Custom MSBuild Tasks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Generic%20Targets"&gt;Generic Targets&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#Links"&gt;Links&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;a name="MSBuild Basics"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
MSBuild Basics
&lt;/h2&gt;.NET 2.0 contains a new tool called MSBuild. MSBuild is primarily used to build .NET application, but can be used for other types of applications as well. From Windows Vista, MSBuild is distributed with Windows itself, making it a strong platform for implementing scriptet application on non-developer PCs as well.&lt;br /&gt; &lt;br /&gt;Before .NET 2.0, application were build by one or more of these strategies:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Using the build menu from inside Visual Studio&lt;/li&gt;&lt;li&gt;Using the devenv.exe process from the command line with some extra parameters&lt;/li&gt;&lt;li&gt;Using a third-party tool like NAnt (which MSBuild is based on)&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;The drawback with the first two strategies was, that it was hard to script. The drawback with the third solution was, that two build environments had to be held in sync and maintained. .NET 2.0 Visual Studio projects are now implemented in the MSBuild language, but MSBuild have no dependencies to Visual Studio itself. MSBuild can in theory be implemented in all types of file extension, but a number of formats seems to by the supported standard from Microsoft: csproj, vbproj, vcproj, vjsproj, proj, .targets. The first four are different types of project files for Visual Studio, while the last two is new extensions, which are either written in hand or with a tool knowing the MSBuild syntax. A few tools exists for this purpose. My personally opinion is, that the build in xml editor in Visual Studio, is quite good for this purpose. A repeating question among MSBuild developers is, if you should extend the files generated by visual studio with new stuff or you should write your own containing your home-made MSBuild scripts. My personally opinion is to let Visual Studio generate its own projects (example: csproj files) and create you home-made scripts in a .proj file with the same name as the project. I usually start the .proj file by implementing the three targets: Clean, Build and Rebuild, which basically just calls the similar targets in the .csproj file. In this way you avoid updating a auto-generated file, which you basically don’t have control over.&lt;br /&gt; &lt;br /&gt;An MSBuild file is implemented in XML. The root element of a MSBuild XML file will always be a project containing target elements. It is possible to run multiple targets in a MSBuild file. When the MSBuild script is started from the command line, it takes a build file as parameter, as well as the names of the targets, which should be executed.&lt;br /&gt; &lt;br /&gt;A target is implemented as a sequential list of tasks. The tasks is executed in the same order, as they are specified beneath the target element. Both targets and tasks can be dependant on each other.&lt;br /&gt; &lt;br /&gt;This is an example of a very simple build file to build a .NET project:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;The example defines a project with the MSBuild namespace. Using the namespace helps you develop the build file in Visual Studio using Intellisence. The build file contains a single targets named Build. This target contains two tasks: Message and MSBuild. Message outputs a message to the console and is primarily used for debug purposes. MSBuild runs a configurable number of targets on another build file. Caused by that fact, that the .csproj file is also implement in MSBuild, we are able to call targets in the build file, from the example build file. In this case we call the target Build in the .csproj file. All projects generated by Visual Studio automatically implements the Clean, Build and Rebuild targets. These targets are actually executed, when you select the similar commands in the Build menu from within Visual Studio.&lt;br /&gt;&lt;a name="Properties"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Properties
&lt;/h2&gt;To be able to parameterise a build script, MSBuild have implemented properties. A property is a simple key/value type, which can be used from multiple locations in the scripts. Lets look at an example using properties:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;.\bin\debug\msbuildintro.exe&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;The example defines a property defined in a property group. Properties can be defined both outside and inside scope of a target. When a property is defined like this example, the value of the property is assigned before executing the actual targets. In the example, I define a property called MyReleaseOutput and add the value .\release.&lt;br /&gt;In this example I have added two targets as well: Build and Release. The Build target is similar to the one specified in the previous example, while the Release target is new. The Release target introduces a new attribute called DependsOnTargets, which is the way to define dependencies between targets in MSBuild. In this case we tell MSBuild to run the Build target before running the Release targets. If you run the Build target manually before running the Release target, the Build target is only run once.&lt;br /&gt; &lt;br /&gt;The release target introduces two new tasks as well: MakeDir which (well you guessed it) creates a new directory and Copy, which copies on or more files from A to B. MakeDir contain a single attribute, defining the path of the new directory. In this example, that path is the value of the MyReleaseOutput property. Notice the use of the $(propertyname) syntax here. $() is used to reference properties in MSBuild. The copy task in our example points out a single file and the destination folder where this file should be copied to, when executing the Release target. The $(MyReleaseOutput) used is yet again replaced by the value of this property.&lt;br /&gt;&lt;a name="Items"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Items
&lt;/h2&gt;The example above copied a single file from one directory to another. This can certainly be useful in many situation, but other times this is simple not flexible enough. This is were items comes in. An item gives the possibility to create dynamic lists of for instance file names. Lets start by looking at an example:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;MyReleaseFiles Include=&amp;quot;.\bin\debug\*.*&amp;quot; /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;We start by defining an ItemGroup outside scope of a target. This means, that the content is calculated before actually running any targets. In this example I define an ItemGroup containing a single item called MyReleaseFiles. The item contains a single attribute called Include, which acts as a filter for the generated file list. In this case all files beneath the bin\debug directory. I use this item in the copy task beneath the Release target to point out which files should be copied when doing a release.&lt;br /&gt; &lt;br /&gt;The Include filter decided which file to include. We also have the possibility to specify an Exclude filter. The following example shows how:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;MyReleaseFiles Include=&amp;quot;.\bin\debug\*.*&amp;quot; Exclude=&amp;quot;.\bin\debug\*vshost.exe&amp;quot; /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;I added an Exlude attribute to my MyReleaseFiles item. The exclude in this examples excludes all files beneath the bin\debug directory, which ends with vshost.exe. An item containing both Include and Exclude, will be generated by taking all the files specified in the Include and subtracting the files specified in the Exlude.&lt;br /&gt; &lt;br /&gt;The last two examples of using items are actually not that usefull. This is caused by the fact that the content for the MyReleaseFiles item is generated before running the actual targets. This means, that on a new checkout or after a clean, no files exists in the bin\debug directory. The generated file list will therefore be completely empty. Bummer! Let us fix the example. We define a new item inside the scope of a target instead:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;CreateItem Include=&amp;quot;.\bin\debug\*.*&amp;quot; Exclude=&amp;quot;.\bin\debug\*vshost.exe&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Include&amp;quot; ItemName=&amp;quot;MyReleaseFiles&amp;quot;/&amp;gt;
    &amp;lt;/CreateItem&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot;  /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;I moved the MyReleaseOutput item inside the Release target. This is done using the CreateItem task. The CreateItem task creates a new item on the fly, which means that the content is generated at the point in time, where the CreateItem task is executed. Notice that the CreateItem task contains an Output element. The Output element is used a lot of different places in MSBuild, where a target is able to output some data. In this case is use the ItemName attribute to define the name from the previous example.&lt;br /&gt; &lt;br /&gt;Anyone still reading? If you have read this far, you derserve a little price:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20133" alt="dilbert2002444471010.gif" /&gt;&lt;br /&gt;&lt;a name="Conditions"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Conditions
&lt;/h2&gt;Besides the CreateItem task in a previous example, out build scripts have been very static until now. This can be sufficient in a lot of projects. Some times you need a little more flexible build scripts, though. A feature for fulfilling this in MSBuild is called Conditions. A condition in MSBuild is not that different that a condition in other software languages. It is a possibility to make more flexible structures for instance avoid running targets and/or tasks when certain conditions are met. You can define conditions on all targets and almost all tasks. Lets check out another example:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;MyReleaseOutput&amp;gt;.\release&amp;lt;/MyReleaseOutput&amp;gt;
    &amp;lt;Configuration Condition=&amp;quot; '$(Configuration)' == '' &amp;quot;&amp;gt;Debug&amp;lt;/Configuration&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
  &amp;lt;Target Name=&amp;quot;Build&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Building msbuildintro $(Configuration)&amp;quot; /&amp;gt;
    &amp;lt;MSBuild Projects=&amp;quot;msbuildintro.csproj&amp;quot; Targets=&amp;quot;Build&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Release&amp;quot; DependsOnTargets=&amp;quot;Build&amp;quot; Condition=&amp;quot;$(Configuration) == 'Release'&amp;quot;&amp;gt;
    &amp;lt;MakeDir Directories=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
    &amp;lt;CreateItem Include=&amp;quot;.\bin\$(Configuration)\*.*&amp;quot; Exclude=&amp;quot;.\bin\$(Configuration)\*vshost.exe&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Include&amp;quot; ItemName=&amp;quot;MyReleaseFiles&amp;quot; /&amp;gt;
    &amp;lt;/CreateItem&amp;gt;
    &amp;lt;Copy SourceFiles=&amp;quot;@(MyReleaseFiles)&amp;quot; DestinationFolder=&amp;quot;$(MyReleaseOutput)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;I added a lot of new stuff here. But of course you are already quite an MSBuild expert, so I think you will manage. First of all, I have added a new property named Configuration. This property contains a condition attribute, which determines the value of the property at runtime. If the Configuration property has not been set up front, the value of the attribute is set to Debug. Properties can be set up front by using a special syntax on the command line:&lt;br /&gt; &lt;br /&gt;&lt;span class="codeInline"&gt; Msbuild.exe build.proj /p:Configuration=Debug /t:release &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;More new stuff. I changed all references to the debug, with the value of the new Configuration property. This means that I am now able to run the script in both Debug and Release mode.&lt;br /&gt; &lt;br /&gt;The last new addition is the condition attribute on the release target. This conditions examines if the value of the Configuration property is Release and only allows execution of the Release target, if this condition turns out true.&lt;br /&gt;&lt;a name="Frequently Used Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Frequently Used Tasks
&lt;/h2&gt;CallTarget – Executes another target inside the current build file. Used in places, where a target needs to call another target at a specific place inside the target itself. If the target where just dependant of the other target being executed, we would use the DependsOnTargets attribute instead.&lt;br /&gt; &lt;br /&gt;Copy – We already saw this task in action. Copies one or more files from A to B.&lt;br /&gt; &lt;br /&gt;CreateItem – Create dynamic items.&lt;br /&gt; &lt;br /&gt;CreateProperty – Create dynamic properties.&lt;br /&gt; &lt;br /&gt;Delete – Deletes on or more files.&lt;br /&gt; &lt;br /&gt;Exec – Executes an external process. This is typically used to executed external tools, which did not implement MSBuild targets themself.&lt;br /&gt; &lt;br /&gt;MakeDir – Creates one or more directories.&lt;br /&gt; &lt;br /&gt;Message – Outputs a message to the console.&lt;br /&gt; &lt;br /&gt;MSBuild – Executes one or more targets in an external MSBuild file.&lt;br /&gt; &lt;br /&gt;RemoveDir – Removes one or more directories.&lt;br /&gt; &lt;br /&gt;And there are a lot more.&lt;br /&gt;&lt;a name="Custom MSBuild Tasks"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Custom MSBuild Tasks
&lt;/h2&gt;It is possible to write your own MSBuild tasks. This can be extremely useful, if you want to integrate some of your own tools with MSBuild or if you need to do stuff, which is not yet supported by MSBuild. The following example shows how to write a simple addition task:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
using System;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
namespace MyTasks
{
  public class AddTask : Task
  {
    private int number1;
    [Required]
    public int Number1
    {
      get { return number1; }
      set { number1 = value; }
    }
    private int number2;
    [Required]
    public int Number2
    {
      get { return number2; }
      set { number2 = value; }
    }
    private int sum;
    [Output]
    public int Sum
    {
      get { return sum; }
      set { sum = value; }
    }
    public override bool Execute()
    {
      try
      {
        sum = number1 + number2;
      }
      catch (ArithmeticException e)
      {
        Console.WriteLine(&amp;quot;Error occured during addition: {0}&amp;quot;, e.Message);
        return false;
      }
      return true;
    }
  }
}
&lt;/pre&gt; &lt;br /&gt;I start by defining the AddTask class which extends the Task class from the MSBuild API. By extending this task, I don’t need to worry about implementing conditions etc.&lt;br /&gt;I defined two properties, which acts as out input variables to the addition task: Number1 and Number2. Both properties are marked with the Required attribute, which tells the script to fail, if these properties are not specified. An output property is added as well. The value of this property will be available within the build script. Let’s see how to use this new and fancy task:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;UsingTask TaskName=&amp;quot;MyTasks.AddTask&amp;quot; AssemblyFile=&amp;quot;.\AddTask.dll&amp;quot;/&amp;gt;
  &amp;lt;Target Name=&amp;quot;Addition&amp;quot;&amp;gt;
    &amp;lt;AddTask Number1=&amp;quot;10&amp;quot; Number2=&amp;quot;12&amp;quot;&amp;gt;
      &amp;lt;Output TaskParameter=&amp;quot;Sum&amp;quot; PropertyName=&amp;quot;CalculatedSum&amp;quot; /&amp;gt;
    &amp;lt;/AddTask&amp;gt;
    &amp;lt;Message Text=&amp;quot;10 + 12 = $(CalculatedSum)&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;Because my AddTask in an external task not build into the MSBuild framework, I use the UsingTask element to reference it. The name of the task as well as the assembly name is specified.&lt;br /&gt; &lt;br /&gt;The Addition target uses the AddTask with the two Number properties as attributes. The Output element copies the result of the task to a property called CalculatedSum. This property is accessible in the Message task for output on the console.&lt;br /&gt; &lt;br /&gt;You just implemented your first custom MSBuild task. Pretty easy, right?&lt;br /&gt;&lt;a name="Generic Targets"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Generic Targets
&lt;/h2&gt;Once in a while a question keeps popping up in different forums: How do I parameterize a common part of my script, making it possible to use it from different targets? This is a great question. We don't wan't to have the same lines of code spread around our build script, making it longer than necessary and complex to maintain. MSBuild contains the CallTarget task, which executes another target inside the current build file. Unfortunately there is no way to parameterize the CallTarget task, making it unusable for other than simple stuff, where needed tasks are 100% identical.&lt;br /&gt; &lt;br /&gt;Let's look at and example, where we have two targets with some identical tasks:&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;Project xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target1&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from Target1&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;Target2&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;Hello World from Target2&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/pre&gt; &lt;br /&gt;In the example we define two targets: Target1 and Target2.&lt;br /&gt; &lt;br /&gt;&lt;a name="Links"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;
Links
&lt;/h2&gt;The MSBuild documentation is actually quite good and a must for all serious MSBuild developers: &lt;a href="http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx" class="externalLink"&gt;http://msdn2.microsoft.com/en-us/library/wea2sca5(VS.80).aspx&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;A lot of different tools for handling MSBuild files exists. I haven’t been able to find a tool, making it possible to run build scripts from within Visual Studio. You could start by installing the MSBuildShellExtension tool from: &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=MSBuild%20Tutorial"&gt;MSBuildShellExtension&lt;/a&gt;.&lt;br /&gt; &lt;br /&gt;Besides the build in tasks in MSBuild, there is a great community project, implementing a lot of nice tasks not implemented by Microsoft. Targets for search and replace, zipping, sending out mails, modifying subversion etc., can be found here: &lt;a href="http://msbuildtasks.tigris.org/" class="externalLink"&gt;http://msbuildtasks.tigris.org/&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Fri, 08 Feb 2008 13:15:57 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: MSBuild Tutorial 20080208011557P</guid></item><item><title>UPDATED WIKI: Screenshots</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;version=9</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=Screenshots"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20142" alt="bullet.gif" /&gt; &lt;i&gt;Screenshots&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20142" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;amp;referringTitle=Screenshots"&gt;Manual&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20142" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;amp;referringTitle=Screenshots"&gt;MSBuild Tutorial&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20142" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=Screenshots"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20142" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=Screenshots"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20142" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=Screenshots"&gt;RSS&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;&lt;h1&gt;
Screenshots
&lt;/h1&gt; &lt;br /&gt;Context menu in the explorer:&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=17587" alt="msbuildshellex.gif" /&gt;&lt;br /&gt; &lt;br /&gt;During the build, an error component - like the one included in Visual Studio - is shown:&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=17588" alt="errorlist.jpg" /&gt;&lt;br /&gt; &lt;br /&gt;Configuration application:&lt;br /&gt; &lt;br /&gt;First page on the configurator makes it possible to define which tool should be used to open files from the error list:&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21553" alt="editor.png" /&gt;&lt;br /&gt; &lt;br /&gt;Second page of the configurator makes it possible to define new targets:&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21555" alt="target.png" /&gt;&lt;br /&gt; &lt;br /&gt;Third page of the configurator makes it possible to define new file extensions:&lt;br /&gt; &lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21554" alt="extension.png" /&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Thu, 08 Nov 2007 18:21:29 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Screenshots 20071108062129P</guid></item><item><title>UPDATED WIKI: Manual</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;version=6</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=Manual"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=Manual"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;i&gt;Manual&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;amp;referringTitle=Manual"&gt;MSBuild Tutorial&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=Manual"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=Manual"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=Manual"&gt;RSS&lt;/a&gt;&lt;br /&gt;&lt;h1&gt;
Manual
&lt;/h1&gt;This short manual tries to explain the basic concepts in MSBuildShellExtension.&lt;br /&gt;&lt;h2&gt;
Editor
&lt;/h2&gt;When double clicking on a file with warning/error in the MSBuildShellExtension error list window, an editor of your choices opens. MSBuildShellExtension comes with two pre-installed templates for Visual Studio 2005 and Notepad. It is possible to extend the tool with more templates. This is done through the MSBuild Shell Extension Configurator:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;/li&gt;&lt;li&gt;Select the Editor icon.&lt;/li&gt;&lt;li&gt;Select the New button.&lt;/li&gt;&lt;li&gt;Type a name for the external tool in the Title textbox.&lt;/li&gt;&lt;li&gt;Select the Default checkbox, if this tool should be used as the external tool for opening source files from within the error list window.&lt;/li&gt;&lt;li&gt;Add the path to the external tool in the Target and arguments textbox. The external tool should as a minimum support a command line parameter for specifying the file containing error/warning. You can use the Variables button to insert different types of variables in the Target and arguments textbox.&lt;/li&gt;&lt;li&gt;Select the Add button.&lt;/li&gt;&lt;li&gt;Select the Save button.&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21550" alt="editor.png" /&gt;&lt;br /&gt;&lt;h2&gt;
Targets
&lt;/h2&gt;MSBuildShellExtension comes with three types of targets (Build, Clean and Rebuild) for each of the default file types. Theese targets can be modified or removed and new targets can be added. This is done through the Targets section in the MSBuild Shell Extension Configurator. New targets are added like this:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;/li&gt;&lt;li&gt;Select the Targets icon.&lt;/li&gt;&lt;li&gt;Select the New button.&lt;/li&gt;&lt;li&gt;Type a name for the target in the Title textbox.&lt;/li&gt;&lt;li&gt;Type the name of the target. This is the target name as specified in the MSBuild file.&lt;/li&gt;&lt;li&gt;Select a verbosity for the target in the Verbosity combobox.&lt;/li&gt;&lt;li&gt;Select the configuration for the target in the Configuration combobox.&lt;/li&gt;&lt;li&gt;Unselect the Show error list checkbox, if you don't want to show the error list window when executing builds through MSBuild Shell Extension.&lt;/li&gt;&lt;li&gt;Select the Add button.&lt;/li&gt;&lt;li&gt;Select the Save button.&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21551" alt="target.png" /&gt;&lt;br /&gt;&lt;h2&gt;
Extensions
&lt;/h2&gt;Last, but not least, you are able to extend the shell extension to file extensions of your choise. As default a number of MSBuild extensions are added, but you can add your own file extension like this:&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;/li&gt;&lt;li&gt;Select the Extensions icon.&lt;/li&gt;&lt;li&gt;Select the New button.&lt;/li&gt;&lt;li&gt;Type in the file extension in the File extension textbox. The file extension should not contain a '.' before the extension name.&lt;/li&gt;&lt;li&gt;Select the Targets which should be enabled for the new file extension. Each target selected, results in an additional menuitem at the context menu of the specified file extension.&lt;/li&gt;&lt;li&gt;Select the Add button.&lt;/li&gt;&lt;li&gt;Select the Save button.&lt;/li&gt;
&lt;/ul&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21552" alt="extension.png" /&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Thu, 08 Nov 2007 18:17:14 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Manual 20071108061714P</guid></item><item><title>UPDATED WIKI: Manual</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;version=5</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=Manual"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=Manual"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;i&gt;Manual&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;amp;referringTitle=Manual"&gt;MSBuild Tutorial&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=Manual"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=Manual"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=Manual"&gt;RSS&lt;/a&gt;&lt;br /&gt;&lt;h1&gt;
Manual
&lt;/h1&gt;This short manual tries to explain the basic concepts in MSBuildShellExtension.&lt;br /&gt;&lt;h2&gt;
Editor
&lt;/h2&gt;When double clicking on a file with warning/error in the MSBuildShellExtension error list window, an editor of your choices opens. MSBuildShellExtension comes with two pre-installed templates for Visual Studio 2005 and Notepad. It is possible to extend the tool with more templates. This is done through the MSBuild Shell Extension Configurator:&lt;br /&gt; &lt;br /&gt;1. Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;br /&gt;2. Select the Editor icon.&lt;br /&gt;3. Select the New button.&lt;br /&gt;4. Type a name for the external tool in the Title textbox.&lt;br /&gt;5. Select the Default checkbox, if this tool should be used as the external tool for opening source files from within the error list window.&lt;br /&gt;6. Add the path to the external tool in the Target and arguments textbox. The external tool should as a minimum support a command line parameter for specifying the file containing error/warning. You can use the Variables button to insert different types of variables in the Target and arguments textbox.&lt;br /&gt;7. Select the Add button.&lt;br /&gt;8. Select the Save button.&lt;br /&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21550" alt="editor.png" /&gt;&lt;br /&gt;&lt;h2&gt;
Targets
&lt;/h2&gt;MSBuildShellExtension comes with three types of targets (Build, Clean and Rebuild) for each of the default file types. Theese targets can be modified or removed and new targets can be added. This is done through the Targets section in the MSBuild Shell Extension Configurator. New targets are added like this:&lt;br /&gt; &lt;br /&gt;1. Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;br /&gt;2. Select the Targets icon.&lt;br /&gt;3. Select the New button.&lt;br /&gt;4. Type a name for the target in the Title textbox.&lt;br /&gt;5. Type the name of the target. This is the target name as specified in the MSBuild file.&lt;br /&gt;6. Select a verbosity for the target in the Verbosity combobox.&lt;br /&gt;7. Select the configuration for the target in the Configuration combobox.&lt;br /&gt;8. Unselect the Show error list checkbox, if you don't want to show the error list window when executing builds through MSBuild Shell Extension.&lt;br /&gt;9. Select the Add button.&lt;br /&gt;10. Select the Save button.&lt;br /&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21551" alt="target.png" /&gt;&lt;br /&gt;&lt;h2&gt;
Extensions
&lt;/h2&gt;Last, but not least, you are able to extend the shell extension to file extensions of your choise. As default a number of MSBuild extensions are added, but you can add your own file extension like this:&lt;br /&gt; &lt;br /&gt;1. Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;br /&gt;2. Select the Extensions icon.&lt;br /&gt;3. Select the New button.&lt;br /&gt;4. Type in the file extension in the File extension textbox. The file extension should not contain a '.' before the extension name.&lt;br /&gt;5. Select the Targets which should be enabled for the new file extension. Each target selected, results in an additional menuitem at the context menu of the specified file extension.&lt;br /&gt;6. Select the Add button.&lt;br /&gt;7. Select the Save button.&lt;br /&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21552" alt="extension.png" /&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Thu, 08 Nov 2007 18:15:51 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Manual 20071108061551P</guid></item><item><title>UPDATED WIKI: Manual</title><link>http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Manual&amp;version=4</link><description>&lt;div class="wikidoc"&gt;
&lt;b&gt;Menu&lt;/b&gt;&lt;br /&gt;&lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Home&amp;amp;referringTitle=Manual"&gt;Home&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Screenshots&amp;amp;referringTitle=Manual"&gt;Screenshots&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;i&gt;Manual&lt;/i&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;amp;referringTitle=Manual"&gt;MSBuild Tutorial&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Donations&amp;amp;referringTitle=Manual"&gt;Donations&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=Search&amp;amp;referringTitle=Manual"&gt;Search&lt;/a&gt; &lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=20143" alt="bullet.gif" /&gt; &lt;a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=RSS&amp;amp;referringTitle=Manual"&gt;RSS&lt;/a&gt;&lt;br /&gt;&lt;h1&gt;
Manual
&lt;/h1&gt;This short manual tries to explain the basic concepts in MSBuildShellExtension.&lt;br /&gt;&lt;h2&gt;
Editor
&lt;/h2&gt;When double clicking on a file with warning/error in the MSBuildShellExtension error list window, an editor of your choices opens. MSBuildShellExtension comes with two pre-installed templates for Visual Studio 2005 and Notepad. It is possible to extend the tool with more templates. This is done through the MSBuild Shell Extension Configurator:&lt;br /&gt; &lt;br /&gt;1. Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;br /&gt;2. Select the Editor icon.&lt;br /&gt;3. Select the New button.&lt;br /&gt;4. Type a name for the external tool in the Title textbox.&lt;br /&gt;5. Select the Default checkbox, if this tool should be used as the external tool for opening source files from within the error list window.&lt;br /&gt;6. Add the path to the external tool in the Target and arguments textbox. The external tool should as a minimum support a command line parameter for specifying the file containing error/warning. You can use the Variables button to insert different types of variables in the Target and arguments textbox.&lt;br /&gt;7. Select the Add button.&lt;br /&gt;8. Select the Save button.&lt;br /&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21550" alt="editor.png" /&gt;&lt;br /&gt;&lt;h2&gt;
Targets
&lt;/h2&gt;MSBuildShellExtension comes with three types of targets (Build, Clean and Rebuild) for each of the default file types. Theese targets can be modified or removed and new targets can be added. This is done through the Targets section in the MSBuild Shell Extension Configurator. New targets are added like this:&lt;br /&gt; &lt;br /&gt;1. Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;br /&gt;2. Select the Targets icon.&lt;br /&gt;3. Select the New button.&lt;br /&gt;4. Type a name for the target in the Title textbox.&lt;br /&gt;5. Type the name of the target. This is the target name as specified in the MSBuild file.&lt;br /&gt;6. Select a verbosity for the target in the Verbosity combobox.&lt;br /&gt;7. Select the configuration for the target in the Configuration combobox.&lt;br /&gt;8. Unselect the Show error list checkbox, if you don't want to show the error list window when executing builds through MSBuild Shell Extension.&lt;br /&gt;9. Select the Add button.&lt;br /&gt;10. Select the Save button.&lt;br /&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;img src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=msbuildshellex&amp;amp;DownloadId=21551" alt="target.png" /&gt;&lt;br /&gt;&lt;h2&gt;
Extensions
&lt;/h2&gt;Last, but not least, you are able to extend the shell extension to file extensions of your choise. As default a number of MSBuild extensions are added, but you can add your own file extension like this:&lt;br /&gt; &lt;br /&gt;1. Open the Configurator through Start | All Programs | MSBuildShellExtension | Configurator&lt;br /&gt;2. Select the Extensions icon.&lt;br /&gt;3. Select the New button.&lt;br /&gt;4. Type in the file extension in the File extension textbox. The file extension should not contain a '.' before the extension name.&lt;br /&gt;5. Select the Targets which should be enabled for the new file extension. Each target selected, results in an additional menuitem at the context menu of the specified file extension.&lt;br /&gt;6. Select the Add button.&lt;br /&gt;7. Select the Save button.&lt;br /&gt; &lt;br /&gt;Example:&lt;br /&gt;&lt;span class="unresolved"&gt;Cannot resolve link: &lt;/span&gt;[image:extension]&lt;br /&gt;
&lt;/div&gt;</description><author>ThomasArdal</author><pubDate>Thu, 08 Nov 2007 18:14:59 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Manual 20071108061459P</guid></item></channel></rss>