MSBuild

Description

Runs the MSBuild build tool of Microsoft's .NET framework 2.0.

You can either use an existing build file or nest a build file (snippet) as a child into the task. If you don't specify either, MSBuild's default build file search algorithm will apply.

Parameters

Attribute Description Required
buildfile External build file to invoke MSBuild on. No.
vm Same as dotnetexec's vm attribute. Specify the framework to use. No.
failOnError Stops the build if MSBuild returns with a code indicating an error. No - defaults to true.
errorProperty Name of the Ant property to set if MSBuild indicated an error. Only useful if the failOnError attribute is set to false. No.

Parameters specified as nested elements

target

target has a single required attribute name - specifies a target to be run.

property

property has two required attributes. name and value that specify name and value of a property that is to be defined in the MSBuild invocation.

build

This element allows no attributes. You can nest a MSBuild build file into it and MSBuild will be executed on that. You can also nest a build file snippet instead and Ant will wrap the necessary MSBuild <Project> around it.

Examples

Let MSBuild search for a *.proj file in the (Ant) project's base directory and execute the default target in it:

<msbuild/>

Let MSBuild execute the targets named foo and bar in the build file msbuild.proj in Ant's basedir and pass the property /property:test=testvalue to it:

      <msbuild buildfile="msbuild.proj">
        <target name="foo"/>
        <target name="bar"/>
        <property name="test" value="testvalue"/>
      </msbuild>
    

Define a build file embeded into the task, let MSBuild execute the echo target of that build file.

      <msbuild>
        <target name="echo">
        <build>
          <Project DefaultTargets="empty" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
            <Target Name="empty"/>
            <Target Name="echo">
              <Message Text="This is MSBuild"/>
            </Target>
          </Project>
        </build>
      </msbuild>
    

Run MSBuild's Message task:

      <msbuild>
        <build>
          <Message Text="This is MSBuild"
             xmlns="http://schemas.microsoft.com/developer/msbuild/2003"/>
        </build>
      </msbuild>