MSBuild
MSBuild, or the Microsoft Build Engine platform, is a collection of tools used to build applications using Microsoft and third-party compilers like Intel and NVIDIA CUDA.
What is MSBuild?
MSBuild, or the Microsoft Build Engine platform, is a collection of tools used to build applications using Microsoft and third-party compilers like Intel and NVIDIA CUDA. It uses an XML control schema to instruct the system on how to compile the project. While MSBuild is included and used by Visual Studio, it is separate and useable without installing the full Visual Studio suite.
What can it do, and how does it work?
MSBuild is the Microsoft toolchain for compiling code, linking it with any necessary dependencies, and then converting it into assembly language for use in an executable file.
When you run MSBuild, either via Visual Studio or on the command line, the project file and any deployment directives are combined into a single set of instructions. As MSBuild iterates through each project in the build instructions, then builds the project using the appropriate compiler and linker. If the project is web-based, it invokes additional tools like MSDeploy or VSDBCMD to deploy web applications and interact with any necessary databases. Additionally, MSBuild can execute tests and any additional workloads specified in the project file.
Try it now
Get Free LicenseHistory of MSBuild and the Latest Version
Microsoft has released various compilers since the MS-DOS and Windows 9x days. Development suites like Microsoft Visual C++ and Visual Basic included these compilers as built-in components tailored to the specific language those products targeted, rather than stand-alone tools.
In 1997, Microsoft released Visual Studio 97, which included a unified development environment for multiple languages. Microsoft released MSBuild in 2003 as part of the .NET Framework, allowing developers to compile .NET projects. Still, it wasn’t until Visual Studio 2013 when the MSBuild system (then version 12) emerged as a stand-alone software package that could build not only .NET applications but C#, C++, and Visual Basic programs as well.
Since 2013, MSBuild has continued to be released as part of Visual Studio but is also available as a separate download. As of this writing, the latest stable version of the MSBuild Tools is 2019 – 16.9.3.
How to Download and Install MSBuild
The easiest way to install MSBuild is to install it as part of Microsoft’s Visual Studio IDE, available at https://visualstudio.microsoft.com/downloads/. If you want to install MSBuild without Visual Studio, you can download them from https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019.
The Visual Studio installer is more complex as it allows the installation of various compilers, language support modules for the IDE, and other related tools like Git. If you choose the build tools (commonly called MSBuild) installer, it will still use the Visual Studio setup system but only preselect the MSBuild Tools. Clicking the Install button without selecting other items will set up MSBuild.
MSBuild Examples
In contrast to compiler systems like GCC, MSBuild takes most of its parameters from the project XML and development environment specification files. As such, a typical command line build looks like this:
MSbuild.exe Project.proj /fl /ds /p:TargetEnvPropsFile=EnvConfig\Dev.proj
The .proj files are produced automatically by Visual Studio, but since they are simply XML files, you can either create them yourself or edit existing files.
In the above example, the /fl switch tells MSBuild to log the output of the build process to a file called msbuild.log. The /ds switch, short for /detailedsummary, produces a detailed report at the end of the build.
You can specify /m:X to use X CPU cores on the system to increase the speed of the compiler and /v:X to adjust the verbosity of MSBuild using values “q” for quiet, “m” for minimal, “n” for normal, “d” for detailed, or “diag” for diagnostic.
You can reference additional command line parameters for MSBuild (https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/msbuild/msbuild-command-line-reference) and explore the XML format of the project files (https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/web-deployment-in-the-enterprise/understanding-the-project-file).
MSBuild for Windows
MSBuild is native to Windows and runs well on this platform. Installation is covered under the previous heading “How to Download and Install MSBuild”.
MSBuild for Linux
On Linux, you have the choice of downloading binaries of MSBuild or compiling the tools from scratch. Installing the pre-built binaries is easy—just grab the .NET Core SDK for Linux (https://dotnet.microsoft.com/download).
If you are adventurous and want to compile MSBuild from source, you can find the project at GitHub (https://github.com/dotnet/msbuild). Microsoft has provided directions on building the suite on Linux ( https://github.com/dotnet/msbuild/blob/main/documentation/wiki/Building-Testing-and-Debugging-on-.Net-Core-MSBuild.md).
Advantages
MSBuild is an excellent tool for automating the building of software on Windows. Its deep integration with the operating system, superb compatibility with Visual Studio, open-source license, and flexibility make it an excellent choice. Using it outside Visual Studio allows for command line integration with external build scripts and systems, enabling more robust automation possibilities.
Is it Open Source?
Microsoft released MSBuild as free and open-source software at GitHub (https://github.com/dotnet/msbuild) under the MIT License.
MSBuild and Incredibuild
Incredibuild turbocharges development with Virtualized Distributed Processing™ technology, turning every host into a supercomputer with hundreds of cores. With Incredibuild, accelerated product development from compilation to testing and release automation delivers better products to market radically faster.
Incredibuild virtualizes your local MSBuild environment on every host you specify, and is bundled as the accelerator of choice within Microsoft Visual Studio. Using the same code, processes, and tools, developers and managers accelerate product development with X8 faster builds, 80% shorter release cycles, and X4 the number of iterations, consistently releasing better products to market radically faster.