-
Notifications
You must be signed in to change notification settings - Fork 0
MSBuild Task
The MSBuild Task can be used in a rakefile to simplify calling msbuild.exe. Remember to require ‘albacore’ at the top of your rakefile after installing the Albacore gem.
Here is an example of how to use the MSBuild Task
desc "Run a sample build using the MSBuildTask"
msbuild :msbuild do |msb|
msb.properties = { :configuration => :Debug }
msb.targets = [ :Clean, :Build ]
msb.solution = 'lib/spec/support/TestSolution/TestSolution.sln'
end
The default rake task name is “msbuild”. You can specify any name you wish, as the rake task name.
You can specify the location of the MSBuild.exe that you wish to use. If you do not provide a location, then the task will default to using the MSBuild.exe that is included in the .NET 4.0 Framework.
If an invalid or incorrect msbuild path is specified (i.e. if the file or folder specified does not exist), the MSBuildTask will fail with an exception stating that the msbuild file was not found:
F, [2009-10-04T14:01:33.481000 #5436] FATAL -- : Command not found: i don't exist.exe
F, [2009-10-04T14:01:33.481000 #5436] FATAL -- : MSBuild Failed. See Build Log For Detail
rake aborted!
This is the solution file or msbuild file that you are going to build. This is the one setting for MSBuild that is required. If you don’t provide a valid visual studio solution or msbuild file, you will get an error.
If not solution is provided, the MSBuiltTask will fail with an exception stating that the solution cannot be nil.
F, [2009-09-28T09:42:48.405000 #1048] FATAL -- : solution cannot be nil
rake aborted!
solution cannot be nil
You can specify any valid MSBuild command line property, here, as a hash literal. For example, if you wanted to provide a property called “foo” with a value of “bar”, and a property called “widget” with a value of “wombat”, you would do so like this:
msb.properties :foo => :bar, :widget => :wombatYou are not required to use :symbols for these values. You can provide string values if you wish. However, if you try to use data types such as “true” or “false”, you must specify them as symbols or strings, directly.
The properties setting is optional. If you don’t provide any values for this, the defaults from your solution or msbuild file will be used.
*Note that albacore in JRuby may yield the error “MSBUILD : error MSB1006: Property is not valid” when using commas in a property. Spaces may be substituted as a workaround:
:nowarn => "0067,0105":nowarn => "0067 0105"IronRuby does not seem to have a problem with commas.
You can specify any valid target for your solution or msbuild file, here, as an array. The example above is calling the Clean and then Build targets, in that order. If you only want to call Rebuild, as another example, you would set the targets like this:
msb.targets :RebuildYou are not required to use :symbols for these values. You can provide string values if you wish. However, if you try to use data types such as “true” or “false”, you must specify them as symbols or strings, directly.
The properties setting is optional. If you don’t provide any values for this, the defaults from your solution or msbuild file will be used.
Sets the msbuild “/verbosity” parameter to the specified value.
msb.verbosity = "normal"This option is separate from the logging options below, as it pertains to the msbuild parameter directly. The logging options below refer to the msbuild task object model.
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.
Sets the msbuild “/logger” parameter to the specified value.
msb.loggermodule = JetBrains.BuildServer.MSBuildLoggers.MSBuildLogger,C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MSBuildLoggers.dllThis setting is optional and allows for a logging module to be specified for MSBuild to use, such as the JetBrains TeamCity logger.
This option is separate from the logging options below, as it pertains to the msbuild parameter directly. The logging options below refer to the msbuild task object model.
Hides the startup banner and copyright message.
msb.nologoSpecifies the number of worker processes that are involved in the build.
msb.max_cpu_count = 4There are many other command line options in msbuild.exe that are either plain switches, like
/noconsoleloggeror switches with values, like
/toolsVersion:3.5You can provide a hash of these switches and their values as primitives or strings.
msb.other_switches :noconsolelogger => true, :toolsVersion => 3.5
The MSBuildTask uses the built in logging options to provide some potentially useful information at run-time. By default, no additional information is logged, other than what MSBuild produces.
When the log_level is set to :verbose, the full command line call for MSBuild will be logged. This includes the expanded path to the msbuild exe as well as the command line parameters that are passed to it.
D, [2009-09-28T09:18:22.254000 #7152] DEBUG -- : Executing MSBuild: "C:\Windows/Microsoft.NET/Framework/v3.5/MSBuild.exe" "TestSolution/TestSolution.sln" /property:configuration=Debug /target:Clean;Build
This task supports configuration via an external YAML file. For more information, see the yamlconfig page.
This task supports additional command line options, including a .parameters collection for passing in options that are not directly supported. For more information, see the commandline task options documentation.
- Build-Server Integration
- Command Line Task Options
- Configuration
- Custom Tasks
- Logging Options
- Sample Usages
- Task Arguments and Rakefile Parameters
- YAML Configuration
- ASP.NET Compiler - ASP.Net website compiler
- Assembly Info Generator - generate assembly info dynamically
- CSC - C# compiler
- Exec - Execute arbitrary cmd
- Fluent Migrator - Run FluentMigrator on migration library
- ILMerge - Merge dll/exe-s together
- MSBuild and XBuild - Compile a .sln-file or a MsBuild xml-file
- MSpec - Test using MSpec (machine.specifications)
- MSTest - Test using Microsoft Test Framework
- NAnt - Run a NAnt script
- NChurn - Calculate per-file churn
- NCover Console - Run NCover for tests/library
- NCover Reports - Generate a report from a coverage run
- NDepend - Run NDepend to check static code metrics
- NuGet Install - Install NuGet packages
- NuGet Pack - Create NuGet packages
- NuGet Push - Push NuGet packages to official MS repo
- NuGet Publish - Publish NuGet packages
- NUnit - Test using NUnit
- NuSpec - Generate a NuSpec file
- Output - File copying and template expansion
- PLink - SSH into a remote computer and run a command
- SQLCmd - Run a SQL command as a part of your build process
- UnZip - Unzip a directory
- XBuild - Run XBuild (will be merged into MsBuild)
- XUnit - Test using XUnit
- Zip - Zip a directory or files
- Edit the Wiki Locally - How to edit the wiki without using Github's interface
- How to Build Albacore
- How to Contribute