Question

We use Nant to automate our builds. We are upgrading out projects to .NET 4.5. It looks like Nant 0.92 which is the latest build only supports .NET 4.0. Is there anyway to get Nant to work with .NET 4.5? I looked on the Nant site and could not find any details about supporting .NET 4.5.

Was it helpful?

Solution

.NET 4.5 is an in place upgrade for .NET 4 so you still use the same MSBuild path to build your project. If you call the msbuild.exe directly, you can leverage any version of NAnt to build your project.

Given the example below, when you want to change to .NET 5 (or any other version of .NET), you simply update the property that points to msbuild.exe and the rest should work (assuming no breaking changes in the msbuild.exe arguments).

<property name="MSBuildPath" value="c:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.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" />
  </exec>
</target>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top