Monday, October 15, 2018

NAnt msbuild latest .NET Framework versions problem fixed


   The problem with NAnt is that the latest supported version for .net framework is 4.5 (msbuild 13).
So, the following snippet:

    <msbuild project="D:\MyProject\MyProj.sln">
      <property name="nant.settings.currentframework" value="net-4.7.1">
      </property>
    </msbuild>

gives us the error

Target framework could not be changed. "net-4.7.1" is not a valid framework identifier.

The workaround is pretty simple - not to use <msbuild> at all. Instead of <msbuild> use <exec>:

    <exec
       program="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" 
       commandline="D:\MyProject\MyProj.sln -t:rebuild" />

Set 'program' attribute to path to actual msbuild.exe file, 'commandline' - path to your solution.

No comments:

Post a Comment