MSBuild Command Line Reference

MSBuild.exe builds the specified project or solution file with the specified options.

MSBuild.exe [Switches] [ProjectFile]

Arguments

Argument Description

ProjectFile

Builds the specified targets in the project file. If a project file is not specified, MSBuild searches the current working directory for a file name extension that ends in "proj" and uses that file. This argument also accepts Visual Studio 2005 solution files.

Switches


Switch Description

/help

Displays usage information. /? or /h are also acceptable.

Msbuild.exe /?

/nologo

Hide the startup banner and copyright message.

/version

Display version information only. /ver is also acceptable.

@file

Insert command line settings from a text file. Specify each response file separately. For more information, see MSBuild Response Files.

/noautoresponse

Do not auto-include the MSBuild.rsp file. /noautorsp is also acceptable.

/target:targets

Build these targets in this project. Use a semicolon or a comma to separate multiple targets, or specify each target separately. /t is also acceptable. For example:

/target:Resources;Compile

/property:name=value

Set or override these project-level properties, where name is the property name and value is the property value. Use a semicolon or a comma to separate multiple properties, or specify each property separately. /p is also acceptable. For example:

/property:WarningLevel=2;OutputDir=bin\Debug

/logger:logger

Specifies the logger to use to log events from MSBuild. To specify multiple loggers, specify each logger separately.

The logger syntax is:

[ LoggerClass ,] LoggerAssembly [; LoggerParameters ]

The LoggerClass syntax is:

[ PartialOrFullNamespace .] LoggerClassName

NoteNote

You do not need to specify the logger class if there is exactly one logger in the assembly.

The LoggerAssembly syntax is:

{ AssemblyName [, StrongName ] | AssemblyFile }

Logger parameters are optional and are passed to the logger exactly as you type them. For example:

/logger:XMLLogger,C:\Loggers\MyLogger.dll;OutputAsHTML

/consoleloggerparameters:parameters

Specifies the parameters to pass to the console logger. /clp is also acceptable. The available parameters are:

  • PerformanceSummary: Displays the amount of time spent in tasks, targets, and projects.

  • NoSummary: Hides the error and warning summary displayed at the end of a build.

  • NoItemAndPropertyList: Hides the list of items and properties displayed at the beginning of each project build in diagnostic verbosity.

/verbosity:level

Display this amount of information in the build log. Individual loggers choose what events to show at a particular verbosity level. A logger may also choose to ignore the verbosity setting.

The available verbosity levels are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. /v is also acceptable. For example:

/verbosity:quiet

/noconsolelogger

Disable the default console logger and do not log events to the console. /noconlog is also acceptable.

/validate:schema

Validates the project file, and, if successful, builds the project.

If schema is not specified, validates the project against the default schema.

If schema is specified, validates the project against the specified schema.

Remarks

To pass parameters to the default console logger, disable it with /noconsolelogger and then specify it with the /logger syntax. For example, use the following command line to show the performance summary normally only displayed in diagnostic verbosity:

msbuild myproject.csproj /noconsolelogger /l:ConsoleLogger,Microsoft.Build.Engine.dll;performancesummary

Example

The following example builds the rebuild target of the MyProject.proj project.

MSBuild.exe MyProject.proj /t:rebuild

You can use MSBuild.exe to perform more complicated builds. For example, you can use it to build specific targets of specific projects in a solution. The following example rebuilds the project NotInSolutionFolder, and cleans the project InSolutionFolder, which is in the NewFolder solution folder.

msbuild SlnFolders.sln /t:NotInSlnfolder:Rebuild;NewFolder\InSolutionFolder:Clean

See Also

Other Resources

MSBuild Reference