MSBuild

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

This page describes how to configure a Bamboo task to use an MSBuild executable.


Note that you cannot use Clover to collect code coverage for MSBuild builds, as Clover only supports builders of Java/Groovy-based projects, such as Ant, Maven, or Grails.


To configure an MSBuild task:

  1. Navigate to the Tasks configuration tab for the job (this will be the default job if creating a new plan).
  2. Select the name of the desired MSBuild task, or select Add task MSBuild if creating a new task.
  3. Complete the following settings:

    Task description
    A description of the task, which is displayed in Bamboo.

    Disable this task
    Check, or clear, to selectively run this task.

    Add condition to task
    Make task run only when a certain condition is met. 
    You can find conditions on Atlassian Marketplace or implement your own.  


    Executable
    The MSBuild executable that is available to perform the task. The executable you select will become one of the task's (and so, the job's) requirements.

    You can add other executables, if required.

    Project file
    The name of the solution, project file, or MSBuild project to execute, for example ExampleSolution.sln. You can include variables (see Bamboo variables).

    Options
    The MSBuild command line options that you want to include. 

    By default, Bamboo 5.7 (and later versions) writes the contents of the Projects File and Options fields to an MSBuild response file. See below for more information.

    You can include variables (see Bamboo variables).

  4. If required, specify environment variables and working directory settings:

    Environment variables (Optional)
    Additional system environment variables that you want to pass to your build. Note that existing environment variables are automatically available to the executable. You can also include Bamboo global or build-specific variables (see Bamboo variables).
    Multiple variables should be separated with spaces. Parameters with spaces must be quoted (e.g ANT_OPTS="-Xms200m -Xmx700m").

    Working subdirectory (Optional) 
    An alternative subdirectory, relative to the job's root directory, where Bamboo will run the executable. The root directory contains everything checked out from the job's configured source repository. If you leave this field blank, Bamboo will look for build files in the root directory. This option is useful if your task has a build script in a subdirectory and the executable needs to be run from within that subdirectory.

    Run as Powershell script (Optional, Windows only)
    Check the Run as Powershell script checkbox to run the script with Powershell instead of cmd.exe which interprets .bat files. The inline editor supports Powershell syntax.

  5. Select Save.

MSBuild task type configuration screen

Passing options to MSBuild

By default, Bamboo 5.7 (and later versions) writes the contents of the Projects file and Options fields to an MSBuild response file:

# MSBuild response file generated by Atlassian Bamboo
%CONTENTS_OF_OPTIONS_FIELD%
%CONTENTS_OF_PROJECTS_FILE_FIELD%

and then runs the following command:

msbuild.exe @<full-path-to-response-file>response-file.rsp

This allows you to use the same settings with the Bamboo MSBuild task as you would use when calling MSBuild on the command line.

You can disable creation of the response file. In that case, Bamboo will create a .bat file instead:

"<full-path-to-msbuild>msbuild.exe" %CONTENTS_OF_OPTIONS_FIELD% %CONTENTS_OF_PROJECTS_FILE_FIELD%

and run that.

Click here to see how to disable use of the response file...

To disable use of the MSBuild response file, set the bamboo.plugin.dotnet.msbuild.useResponseFile system property to false.

There are a couple of ways to do that:

  • If you start the Bamboo server or remote agents manually you can set the property on the command line, as an argument to the JVM, like this:

    -Dbamboo.plugin.dotnet.msbuild.useResponseFile=false

    Do this on all Bamboo agents, and on the Bamboo server if you use local agents.

  • If your agents are run as a service, set the system property in the <Bamboo agent home directory>/conf/wrapper.conf configuration file, like this:

    # The Bamboo Agent home configuration file
    wrapper.java.additional.1=-Dbamboo.home=/home/bamboo/bamboo-agent-home
    wrapper.java.additional.2=-Dbamboo.agent.ignoreServerCertName=false
    wrapper.java.additional.3=-Dbamboo.plugin.dotnet.msbuild.useResponseFile=false
  • If your Bamboo server runs as a service, add the system property to the <Bamboo home directory>/conf/wrapper.conf  configuration file.

 





Last modified on Aug 10, 2021

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.