msbuild
Build software projects using MSBuild project files
TLDR
Build the first project file in the current directory
Build a specific project file
Specify one or more semicolon-separated targets to build
Specify one or more semicolon-separated properties
Specify the build tools version to use
Display detailed information at the end of the log about how the project was configured
Display help
SYNOPSIS
msbuild [options]
PARAMETERS
/target:
Specifies the target to build. If omitted, the default target is built.
/property:
Sets a global property for the build.
/verbosity:
Sets the verbosity level of the build output (quiet, minimal, normal, detailed, diagnostic).
/consoleloggerparameters:
Parameters for the console logger. Allows customization of the console output format. See msbuild.exe /help
/fileLogger
Logs the output to a file.
/fileloggerparameters:
Parameters for the file logger. Allows customization of the file log. See msbuild.exe /help
/nodeReuse:
Specifies whether to reuse nodes between builds for performance.
/maxCpuCount[:number]
Specifies the maximum number of concurrent processes to use when building. Defaults to number of processors.
The path to the project file (.csproj, .vbproj, .fsproj, etc.).
/help
Displays help information.
DESCRIPTION
MSBuild, the Microsoft Build Engine, is a platform for building applications. While primarily associated with the .NET ecosystem and Windows, msbuild is also available on Linux. It allows you to build .NET projects using project files (.csproj, .vbproj, etc.) that define the build process. msbuild reads these XML-based project files and executes a sequence of tasks to compile, link, and package your code. This facilitates cross-platform .NET development and allows you to leverage existing build scripts on different operating systems. The Linux version provides a command-line interface for running builds, making it suitable for integration into continuous integration and continuous deployment (CI/CD) pipelines. Build definitions consist of targets, dependencies, tasks and properties that specify how the source code is processed to create binaries.
CAVEATS
The Linux version of msbuild requires .NET SDK to be installed. Features may vary compared to the Windows version depending on the installed workloads. Ensure .NET Runtime is configured correctly for your projects.
ENVIRONMENT VARIABLES
MSBuild respects several environment variables that can influence its behavior. For instance, variables like MSBuildSDKsPath can be used to customize the location where MSBuild searches for SDKs.
Consult the official MSBuild documentation for a comprehensive list of supported environment variables.
TROUBLESHOOTING
Build failures can occur due to missing dependencies, incorrect project configurations, or incompatible target frameworks. Carefully examine the build output for error messages and warnings. Ensure that all required NuGet packages are installed and that the project file is correctly configured for the target platform.
Use the /verbosity:detailed or /verbosity:diagnostic flags to get more verbose output.
HISTORY
MSBuild originated as part of the .NET Framework and Visual Studio on Windows. The cross-platform implementation for Linux and macOS has been developed as part of the .NET Core (now .NET) initiative, to enable .NET development on non-Windows operating systems. The goal was to provide a consistent build experience across different platforms using the same project file format.
SEE ALSO
dotnet(1)