Geeks With Blogs
Gaurav Bodar - ALM Consultant, TFS specialist ALM, TFS, Agile, Scrum, Sharepoint, IT Service

Technorati Tags: ,,


What is MSBuild? MSBuild is a general-purpose build system created by Microsoft and is

used to build most Microsoft Visual Studio projects. MSBuild is shipped with the Microsoft

.NET Framework. What this means is that you do not need to have Visual Studio installed in

order to build your applications.

Project File Details

you should follow these

conventions for specifying the extension of the file:

 .proj A project file

 .targets A file that contains shared targets, which are imported into other files

 .props Default settings for a build process

 .tasks A file that contains Using Task declarations

Mainly MSBUILD definition is stored in two xsd files:

  •  Microsoft.Build.Core.xsd file describes all the fundamental elements that an MSBuild file can contain
  •  Microsoft.Build.Commonttypes.xsd defines all known elements; this is mainly used to describe the elements that Visual Studio–generated project files can contain.

Properties and Targets

MSBuild properties are simply key-value pairs. The key for the property is the name that you

will use to refer to the property. The value is its value. When you declare static properties,

they are always contained in a PropertyGroup element, which occurs directly within

the Project element.

simple example of declaring static properties:

<Project xmlns="">





MSBuild fundamentally has two execution elements: tasks and targets. A task is the smallest

unit of work in an MSBuild file, and a target is a sequential set of tasks. A task must always

be contained within a target. Here’s a sample that shows you the simplest MSBuild file that

contains a target:

<Project xmlns="">

<Target Name="HelloWorld">



The command you will be invoking to start MSBuild is msbuild .exe. The basic usage for the command is as follows:



Building applications usually means dealing with many files. Because of this, you use

a specific construct when referencing files in MSBuild: items. Items are usually file-based

references, but they can be used for other purposes as well. When you

define a property, you are declaring a key-value pair, which is a one-to-one relationship.

When you declare items, one item can contain a list of many values. In terms of code,

a property is analogous to a variable and an item to an array. Take a look at how an item

is declared in the following snippet

<Project xmlns="">


<SolutionFile Include="..\Build.sln" />


<Target Name="Print">

<Message Text="SolutionFile: @(SolutionFile)" />



Item Metadata

Another difference between properties and items is that items can have metadata associated with them. When you create an item, each of its elements is a full-fledged .NET object, which can have a set of values (metadata) associated with it.

To see how things change when an item contains more than one value, let’s examine

<Project xmlns=""



<Compile Include="*.cs" />


<Target Name="Print">

<Message Text="Compile fullpath: @(Compile->'%(FullPath)')" />



Item Transformation

Many times you would need to modify the Item without changing the existing item list. MSBuild has this feature inbuilt named transformation.

In the following example, a list of .resx files is transformed into a list of .resources files.


For MSBuild Command Line
MSBuild Reserved Properties

Item Meta data

To find more MSBUILD Task

MSBuild Extension Pack (

Microsoft SDC Tasks (

MSBuild Community Tasks (

Important Toolset from Codeplex


Third party Tool Sidekick

Posted on Wednesday, August 28, 2013 11:20 AM MSBUILD , tfs build | Back to top

Comments on this post: MSBuild Quick Start

# re: MSBuild Quick Start
Requesting Gravatar...
The article about MSBuild is very useful, informative and thanks for the same. The example of declaring static properties discussed in properties and targets section found to be very useful to me. It is illustrated perfectly and in a understandable manner. catalina island hotels
Left by rosemary on Mar 22, 2016 10:55 PM

# re: MSBuild Quick Start
Requesting Gravatar...
Thanks for the information. I've used this idea in my project and it really work fine on my end. - Mark Zokle
Left by George on Nov 02, 2016 12:30 AM

comments powered by Disqus

Copyright © Gaurav Bodar | Powered by: