C# Tutorials - Herong's Tutorial Examples - v3.31, by Dr. Herong Yang
What Is MSBuild?
A quick introduction is provided on MSBuild, the Microsoft Build Engine, which is a platform for building .NET applications using a project file in XML format.
What Is MSBuild? MSBuild, short name for Microsoft Build Engine, is a platform for building .NET applications. MSBuild supports a build project file in XML format to control the build process and generate the final executable file.
As described on wikipedia.org, MSBuild uses similar concepts like other popular build tools: Apache Ant, and Make.
Target - A Target contains a set of tasks for MSBuild to execute. The focus of MSBuild is the result Target specified when invoking MSBuild with the project file. This is because a Project may contain several Target entries, each executed sequentially (and conditionally). Subsequent dependent Targets are executed before the requested Target. The execution flow of the current Target can be directed using the following attributes: Condition, BeforeTargets, AfterTargets, and DependsOnTargets. Each Target may be self contained with the necessary Tasks to complete itself. A Target is typically an action executed on a file, set of files or directory.
Task - A Task is a command which is executed in order to complete a Target. Tasks are used to group and execute any number of actions during the build process. They are typically implemented in a .NET assembly as a class which inherits from the Task class or implements the ITask interface. Many basic tasks are shipped as part of the .NET Framework, and community developed tasks are freely available. Some examples of Tasks include copying files, creating directories, or parsing XML.
Properties and Items - MSBuild provides Properties and Items, which are conceptually equivalent to make's macros. Properties specify static values, whereas Items are usually used to define sets of files or folders on which to perform Tasks. Specifying files on Items is made easy by the support of wildcards.
Visual Studio actually uses MSBuild to perform the build task.
MSBuild is included in .NET Framework SDK. So you can MSBuild to build your .NET applications without installing and using Visual Studio.
If you have .NET Framework 4.6.1 SDK installed, MSBuild is located at: "C:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe". You can run the following command to verify:
C:\herong>"C:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild" /version Microsoft (R) Build Engine version 4.6.1055.0 [Microsoft .NET Framework, version 4.0.30319.42000] Copyright (C) Microsoft Corporation. All rights reserved. 4.6.1055.0
Table of Contents