It looks like there are (at least) two options for getting nant to use csproj files: using the task of NAntContrib or using msbuild.exe directly (e.g., codecampserver). Am I reading this right, and if so, what is the advantage of using msbuild.exe over the NAntContrib task?
<msbuild> task or msbuild.exe with NAnt?
Asked Answered
The NAntContrib assumes .NET Framework V2.0. If you want to use .NET 3.5, you'll need to call MsBuild.exe directly. As you upgrade to new versions of .NET, you need only modify the MSBuildPath property.
Here's an example:
<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>
The value MSBuildPath
for different versions of .NET are
- 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.x, 4.6.x, 4.7.x
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
For a 32-bit build, change Framework64
to Framework
Update
Following up on some of the comments, the value
attribute is used for parameters that have no white space characters where as line
is used for parameters that contain white spaces. Otherwise, the NAnt would use the space as an end of input.
Wow, thanks. I never imagined that NAntContrib was so far behind. –
Brisco
-1 You can use <msbuild> with .NET 3.5. Make sure You have the latest nightlies of NAnt and NAntContrib (tested NAnt Nightly 20090130 and NAntContrib Nightly 20090201). –
Gallipot
I am new to NAnt and am a little confused about the meaning of the arg line arg value when dealing with msbuild. Can someone explain to me the difference as the documentation still did not clear things up for me. –
Saltillo
'value' is used for parameters that have no spaces. 'line' is used for parameters that need to be delimited due to spaces. Otherwise, the application would use the space as an end of input. –
Immateriality
@TheChairman - Your comment as it stands is not useful. It would be useful if you explained how to pick the version of msbuild associated with
<msbuild>
. The version is a moving target and the comment regarding 3.5
now also refers to an antique. As a beginner to NAnt, this answer works and the default <msbuild>
does not work. –
Clarabelle Here is a simple target
<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>
© 2022 - 2024 — McMap. All rights reserved.