I appreciate the answers, and I know skolima's would work, the solution ended up being as simple as the addition of this tag:
<property name="nant.settings.currentframework" value="net-3.5"/>
Thanks again.
题
I have a nant script that in one of its targets uses the msbuild tags to build a Visual Studio 2010 solution.
The problem is it fails when it hits this point, the error is:
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)
The error makes sense, if it's calling the .NET 2.0 version of MSBuild it won't compile the VS2010 solution. However, I can't figure out how to get it to call the right version of MSBuild.
If I run 'where MSBuild' (from the same VS2010 Command Prompt that the build script failed in), I get:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe
If I run 'msbuild /version' (again, same window) I get:
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
So everything looks like it should be using the 4.0 version, but it's not. Any idea what gives? I know I've addressed this issue before, but can't remember what it was to save my life.
解决方案
I appreciate the answers, and I know skolima's would work, the solution ended up being as simple as the addition of this tag:
<property name="nant.settings.currentframework" value="net-3.5"/>
Thanks again.
其他提示
Older versions of NAnt/NAntContrib default to v2.0.
Sounds like: Nant msbuild task with .net 4.0 rc
What I usually use is I execute NAnt
with -t:net-4.0
switch (or any other framework version) and in my script I would have <exec program="${framework::get-tool-path('msbuild.exe')}" managed="strict" />
to actually invoke msbuild. Yes, this doesn't use the built-in <msbuild/>
task but is more resilient.
I answered a similar question: <msbuild> task or msbuild.exe with NAnt? a while back
Essentially, if you set a property that points to the MSBuild executable, you can avert the (long term) issue when you upgrade to a newer of .NET than what NAnt supports out ofthe box.