如何在nant脚本中指定MSBuild版本?

Mik*_*ike 5 msbuild nant msbuild-4.0

我有一个nant脚本,在其一个目标中使用msbuild标记来构建Visual Studio 2010解决方案.

问题是当它到达这一点时失败,错误是:

Solution file error MSB5014: File format version is not recognized.  MSBuild can only read solution files between versions 7.0 and 9.0, inclusive.

Failed to start MSBuild.

External Program Failed:  C:\Windows\Microsoft.NET\Framework\v2.0.50727\msbuild.exe (return code was 1)
Run Code Online (Sandbox Code Playgroud)

错误是有道理的,如果它调用.NET 2.0版本的MSBuild它将无法编译VS2010解决方案.但是,我无法弄清楚如何让它调用正确版本的MSBuild.

如果我运行'where MSBuild'(来自构建脚本失败的VS2010命令提示符),我得到:

 C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
 C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe
Run Code Online (Sandbox Code Playgroud)

如果我运行'msbuild/version'(再次,同一个窗口)我得到:

 Microsoft (R) Build Engine version 4.0.30319.17929
 [Microsoft .NET Framework, version 4.0.30319.18034]
 Copyright (C) Microsoft Corporation. All rights reserved.

 4.0.30319.17929
Run Code Online (Sandbox Code Playgroud)

所以一切看起来都应该使用4.0版本,但事实并非如此.知道是什么给出的吗?我知道我之前已经解决了这个问题,但不记得拯救我的生命是什么.

Mik*_*ike 4

我很欣赏这些答案,并且我知道 skolima 会起作用,解决方案最终就像添加此标签一样简单:

    <property name="nant.settings.currentframework" value="net-3.5"/> 
Run Code Online (Sandbox Code Playgroud)

再次感谢。