This project is read-only.

Using the MSBuild tasks

After installing BuildTools 2.0, the MSBuild extensions path (commonly located at C:\Program Files\MSBuild) has been updated with the BuildTools MSBuild tasks and targets. These targets integrate seamlessly with the build process and work from Visual Studio as well as TFSBuild. The only thing you need to do to use the tasks is update your project files to import the BuildTools.targets files. The following steps describe how to configure your project file:
  • Unload your project in Visual Studio by right clicking and choosing the "Unload Project" menu item.
  • Open the project file by right clicking on the unloaded project and choosing the "Edit MyProject.csproj" menu item.
  • Inside the project file, find the line saying <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> (near the bottom), and add the following import underneath it.
<Import Project="$(MSBuildExtensionsPath)\BuildTools\BuildTools.targets" />
  • To set up your version numbering, add the following property group right above the import statements:
  • Save and close the project file and reload the project.
  • Remove the AssemblyVersion and AssemblyFileVersion attributes from your project's AssemblyInfo.cs file (as they will conflict with the ones added automatically).

In the default configuration, the BuildTools MSBuild tasks will generate version numbers based on the current date and the project starting date specified above. The version numbering scheme is as followed: a.b.cMMdd.HHmm, where a is the MajorVersion property, b is the MinorVersion property, c is the number of full years passed since the starting date (UTC time) and the other numbers come from formatting the current date. If you don't define the StartingDate property, the BuildTools MSBuild tasks will use the creation date of the project file by default. Other methods of generating build and revision numbers will be discussed in this documentation later.

Each build will now automatically contain a meaningful version for the AssemblyVersion and AssemblyFileVersion attributes. The AssemblyVersion attribute will only use the MajorVersion and MinorVersion attributes (i.e., while the AssemblyFileVersion attribute will use the entire generated version (i.e. 2.0.10227.2034). Also, you can version multiple projects in the same solution differently (for example, MyProject.Core.dll could be version 2.1.x.y; while MyProject.Extensions.dll could be version 1.5.x.y) by just tweaking the property values for each project. The only information that needs updating in source control is the starting date of the projects, and their major/minor versions.

Last edited Feb 27, 2010 at 10:02 PM by WouterDemuynck, version 2


No comments yet.