We encountered this issue when trying to execute code within the script tag. nant.settings.currentframework was set to net-3.5 in both the build file and the Nant.exe.config file, but it was still compiled in the 2.0 Framework.
According to Gert: "We use CodeDOM to compile the script, and hence it uses the C# compiler corresponding to the CLR on which NAnt is running.
The current target framework – as specified using the nant.settings.currentframework – does not affect this."
My sample build-file is below:
<project name="Test" default="run" basedir=".">
<property name="debug" value="true"/>
<property name="nant.settings.currentframework" value="net-3.5" />
public static void ScriptMain(Project project)
string str = "Hello World from Nant C#; Version ";
string ver = System.Environment.Version.ToString();
project.Log(Level.Info, str.ToString() + ver);
Log in to post a comment.