MSBuild Command Line Reference
MSBuild.exe builds the specified project or solution file, with the specified options.
MSBuild.exe [Switches] [ProjectFile]
|
Switch |
Description |
||
|---|---|---|---|
|
/help |
Displays usage information. /? or /h are also acceptable. For example: Msbuild.exe /? |
||
|
/nologo |
Hides the startup banner and copyright message. |
||
|
/version |
Displays version information only. /ver is also acceptable. |
||
|
@file |
Inserts command line settings from a text file. Specify each response file separately. For more information, see MSBuild Response Files. |
||
|
/noautoresponse |
Does not auto-include the MSBuild.rsp file. /noautorsp is also acceptable. |
||
|
/target:targets |
Builds 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 |
Sets or overrides 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
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 |
||
|
/distributedlogger:<central logger>*<forwarding logger> |
Use this logger to log events from MSBuild. To specify multiple loggers, specify each logger separately. (Short form /dl) The <logger> syntax is: [<logger class>,]<logger assembly>[;<logger parameters>] The <logger class> syntax is: [<partial or full namespace>.]<logger class name> The <logger assembly> syntax is: {<assembly name>[,<strong name>] | <assembly file>} The <logger parameters> are optional, and are passed to the logger exactly as you typed them. (Short form: /l) Examples: /dl:XMLLogger,MyLogger,Version=1.0.2,Culture=neutral /dl:MyLogger,C:\My.dll*ForwardingLogger,C:\Logger.dll |
||
|
/consoleloggerparameters:parameters |
Specifies the parameters to pass to the console logger. /clp is also acceptable. The available parameters are as follows:
|
||
|
/verbosity:level |
Displays this amount of information in the build log. Individual loggers display events based upon the verbosity level. A logger can also be configured 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 |
Disables the default console logger and does not log events to the console. /noconlog is also acceptable. |
||
|
/validate:schema |
Validates the project file and, if validation succeeds, 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. |
||
|
/maxcpucount:number |
Specifies the number of worker processes that are involved in the build. For example: C:\Windows\WinFX\v3.5>msbuild.exe *.proj /maxcpucount:3. This example instructs MSBuild to build using three MSBuild.exe processes, thus allowing three projects to build in parallel. /m is also acceptable. |
||
|
/ignoreprojectextensions:<extensions> |
List of extensions to ignore when the project file to build is being determined. Use a semicolon or a comma to separate multiple extensions. (Short form: /ignore) Example: /ignoreprojectextensions:.vcproj,.sln |
||
|
/fileLogger |
Logs the build output to a single file ("msbuild.log") in the current directory. The location of the file and other parameters for the fileLogger can be specified through the addition of the "/fileLoggerParameters" switch. (Short form: /fl) |
||
|
/distributedFileLogger |
Logs the build output to multiple log files, one log file per MSBuild node. The initial location for these files is the current directory. By default the files are called "MSBuild<nodeid>.log". The location of the files and other parameters for the fileLogger can be specified with the addition of the "/fileLoggerParameters" switch. If a log file name is set through the fileLoggerParameters switch the distributed logger will use the fileName as a template and append the node id to this fileName to create a log file for each node. |
||
|
/fileloggerparameters:<parameters> |
Specifies the parameters for the file logger and distributed file logger. (Short form: /flp) The available parameters are: LogFile - The path to the log file into which the build log is written. The distributed file logger uses this as a prefix for its log file names. Append - Determines if the build log is appended to or overwrite the log file. When you set the switch, the build log is appended to the log file. When you do not set the switch, the contents of an existing log file are overwritten. The default is not to append to the log file. Verbosity - Overrides the default verbosity setting of detailed. Encoding - specifies the encoding for the file, for example, UTF-8. Any of the console logger parameters can also be used. For example: /fileLoggerParameters:LogFile=MyLog.log;Append; Verbosity=diagnostic;Encoding=UTF-8 |
||
|
/toolsversion:version |
Specifies the version of the Toolset to use to build the project. This command lets you build a project by using a version different from that specified in the Project Element (MSBuild). For example: C:\Windows\WinFX\v3.5>msbuild.exe *.proj /ToolsVersion:3.5 /p:Configuration=Debug Valid values for version are as follows: 2.0, 3.0, and 3.5. For more information about Toolsets, see Building for Specific .NET Framework Versions. |
||
|
/nodeReuse:<parameters> |
Enables or Disables the re-use of MSBuild nodes. The parameters are: True - Nodes remain after the build completes and are reused by subsequent builds. False - Nodes do not remain after the build completes. (Short form: /nr) Example: /nr:true |
To pass parameters to the default console logger, first disable it with /noconsolelogger and then specify it with the /logger syntax. For example, use the following command line to show the performance summary ordinarily only displayed in diagnostic verbosity:
msbuild myproject.csproj /noconsolelogger /l:ConsoleLogger,Microsoft.Build.Engine.dll;performancesummary
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 complex 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:NotInSolutionfolder:Rebuild;NewFolder\InSolutionFolder:Clean
Is not /property:OutputDir=[Path], use /property:OutputPath=[Path]
- 9/19/2011
- Alex Almeida
Does MsBuild return an error level that I can check in a .bat file? Doesn't seem to be documented...
thanks,
Chaim
- 3/17/2011
- AbqSteve
msbuild.exe *.proj
Using wildcard characters is not supported and will yield:
MSBUILD : error MSB1009: Project file does not exist.
Attempting to specify several projects will yield:
MSBUILD : error MSB1008: Only one project can be specified.
I therefore recommend all instances of *.proj be replaced with example.proj.
- 9/9/2010
- Oli_is_cool
- Create a test project to run your task in
- Edit the .csproj/.vbproj file and add in the necessary MSBuild XML to make use of your task. Here is what I added:
<UsingTask AssemblyFile="D:\tasks\assemblyinfotask.dll" TaskName="AssemblyInfo"/>
<Target Name="BeforeBuild" Outputs="@(AssemblyInfo)">
<AssemblyInfo AssemblyInfoFile="@(AssemblyInfo)"/>
</Target> - Close the test project
- Open your custom task project
- Go to Project > projectname Properties…
- Go to the Debug tab
- Change the start action to “Start external program” and put in the full path to MSBuild as the program. In my case the path is “E:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe”
- Change the “Command line arguments” to the full path to your test project
- Close the property window
Voila! Now you can set a breakpoint on the Execute() method in your custom task and single-step through all your code
thanks to
http://blogs.msdn.com/msbuild/archive/2005/09/28/474951.aspx
- 4/1/2010
- Y2KPRABU
Q: What would happen if my solution had multiple projects and I gave just the Solutionfile as the parameter:
a. Builds all the projects in the solution.
b. Builds only one project under the solution?
A: It builds everything that is required in the solution. It builds it in the required order. It's quite handy, really.
I have a build file that I would like to pass the folder name (For a copy command, not outputdir) to. Is there a way from the msbuild commandline to pass a value for use in the .proj file?
For example I would like to do the following:
Prompt the user for a version number. (e.g. 1.1, 2.0, etc.) from a batch file that runs the msbuild command.
Then, I build the output directory by using my base output dir + the passed-in value.
Is this even possible?
Best regards and thanks in advance.
Ryan
- 11/23/2009
- rkbrown
But there are some edge cases where it will fail to identify the correct build order, even if Visual Studio can build the project without any problems.
- 10/27/2009
- Lars Mæhlum
Or, load up the MSBuild environment variables with a call to "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86
Happy Building :)
- 4/22/2009
- Strahlee
- 4/22/2009
- maxc
/consoleloggerparameters:<parameters>
Parameters to console logger. (Short form: /clp)
The available parameters are:
PerformanceSummary--Show time spent in tasks, targets and projects.
Summary--Show error and warning summary at the end.
NoSummary--Don't show error and warning summary at the end.
ErrorsOnly--Show only errors.
WarningsOnly--Show only warnings.
NoItemAndPropertyList--Don't show list of items and properties at the start of each project build.
ShowCommandLine--Show TaskCommandLineEvent messages
ShowTimestamp--Display the Timestamp as a prefix to any message.
ShowEventId--Show eventId for started events, finished events, and messages
ForceNoAlign--Does not align the text to the size of the console buffer
DisableMPLogging-- Disable the multiprocessor logging style of output when running in non-multiprocessor mode.
EnableMPLogging--Enable the multiprocessor logging style even when running in non-multiprocessor mode. This logging style is on by default.
Verbosity--overrides the /verbosity setting for this logger.
Example:
/consoleloggerparameters:PerformanceSummary;NoSummary;Verbosity=minimal
=============================================================
Sayed Ibrahim Hashimi
http://www.sedodream.com
- 9/14/2008
- Sayed Ibrahim Hashimi
Note: