Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
333 views
in Technique[技术] by (71.8m points)

<msbuild> task or msbuild.exe with NAnt?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:WINDOWSMicrosoft.NETFrameworkv3.5MSBuild.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 FilesCruiseControl.NETserverThoughtWorks.CruiseControl.MsBuild.dll"'/>
    </exec>
</target>

The value MSBuildPath for different versions of .NET are

  • 2.0, 3.0 C:WindowsMicrosoft.NETFramework64v2.0.50727MSBuild.exe
  • 3.5 C:WindowsMicrosoft.NETFramework64v3.5MSBuild.exe
  • 4, 4.5.x, 4.6.x, 4.7.x C:WindowsMicrosoft.NETFramework64v4.0.30319MSBuild.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...