How to specify MSBuild version in nant script?

I have a nant script that for one of its purposes uses msbuild tags to create a Visual Studio 2010 solution.

The problem is that it does not fire when it reaches 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 calls the version of MSBuild.NET 2.0, it will not compile the VS2010 solution. However, I cannot figure out how to make it invoke the correct version of MSBuild.

If I run "where is MSBuild" (from the same VS2010 command line that the script build failed), 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 a 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 as if you need to use version 4.0, but it is not. Any idea what gives? I know that I used to consider this issue, but I can’t remember what it was for my life.

+5
4

, , skolima , , :

    <property name="nant.settings.currentframework" value="net-3.5"/> 

.

+4

NAnt/NAntContrib v2.0.

: Nant msbuild .net 4.0 rc

+1
+1

: <msbuild> task msbuild.exe NAnt? a

Essentially, if you set a property that points to the MSBuild executable, you can prevent a (long-term) problem when upgrading to a newer version of .NET than what NAnt supports out of the box.

0
source

All Articles