MSBuild

Description

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

Unlike the nant task, this task doesn't support nested build files. MSBuild requires a certain default namespace and there is no easy way to write an XML file of that type within Ant 1.6.x - without repeating code that is already present in Ant 1.7 or some ugly hacks, that is. Use the Ant 1.7+ version of this antlib and Ant 1.7+ if you want nested build file snippets, alternatively use the echo task to write the build file (see example below).

If you don't specify a build file, 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.

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.

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 an Ant build file, let MSBuild execute the echo target of that build file.

      <tempfile property="ms.proj" suffix=".proj"/>
      <echo file="${ms.proj}"><![CDATA[
        <Project DefaultTargets="echo" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
          <Target Name="echo">
            <Message Text="This is MSBuild"/>
          </Target>
        </Project>]]></echo>
      <msbuild buildfile="${ms.proj}"
        xmlns="antlib:org.apache.ant.dotnet"
        />
      <delete file="${ms.proj}"/>
    

Copyright © 2003-2005 The Apache Software Foundation. All rights Reserved.