2009-07-28 65 views

回答

23

NAntContrib假定.NET Framework V2.0。如果你想使用.NET 3.5,你需要直接调用MsBuild.exe。在升级到新版本的.NET时,只需修改MSBuildPath属性。

下面是一个例子:

<property name="MSBuildPath" value="C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe"/>  
<target name="build"> 
    <exec program="${MSBuildPath}"> 
     <arg line='"${SolutionFile}"' /> 
     <arg line="/property:Configuration=${SolutionConfiguration}" /> 
     <arg value="/target:Rebuild" /> 
     <arg value="/verbosity:normal" /> 
     <arg value="/nologo" /> 
     <arg line='/logger:"C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll"'/> 
    </exec> 
</target> 

不同版本.NET的值MSBuildPath

  • 2.0,3.0 C:\Windows\Microsoft.NET\Framework64\v2.0.50727\MSBuild.exe
  • 3.5 C:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild.exe
  • 4,4.5 4.5.1 ,4.5.2 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe

对于一个32位的构建,改变Framework64Framework

更新 上的一些评论跟进,在value属性被用于那些没有空格的参数。 line用于需要由于空格而被分隔的参数。否则,应用程序将使用该空间作为输入的结尾。

+0

哇,谢谢。我从来没有想到NAntContrib远远落后。 – keithm 2009-07-30 11:37:58

2

下面是一个简单的目标

<target> 

    <loadtasks assembly="${nant::get-base-directory()}/../../nantcontrib-0.85/bin/NAnt.Contrib.Tasks.dll" /> 

    <msbuild project="${filepath.root}/yourproject.csproj" verbose="true">  
      <arg value="/p:Platform=${build.platform}" /> 
      <arg value="/t:Rebuild" /> 
      <arg value="/p:OutputPath=${build.dir}/bin/" /> 
     </msbuild> 

</target>