Menu

#756 Issue Specifying Compiling Framework

open-invalid
nobody
Core (183)
5
2011-05-05
2010-10-26
Liam Kenny
No

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:

<?xml version="1.0"?>
<project name="Test" default="run" basedir=".">
<description></description>
<property name="debug" value="true"/>
<property name="nant.settings.currentframework" value="net-3.5" />
<target name="run">
<script language="c#">
<code>
<![CDATA[
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);
}
]]>
</code>
</script>
</target>
</project>

Discussion

  • Ryan Boggs

    Ryan Boggs - 2011-05-05
    • status: open --> open-invalid
     
  • Ryan Boggs

    Ryan Boggs - 2011-05-05

    If I am not mistaken, .net 3.5 is built upon the 2.0 clr. Thus, the System.Environment.Version will always spit out 2.0 when the target frame work is net-2.0, 3.0, or 3.5. So chances are, that code is running on 3.5.

    Have you tried your code in a simple console project? What does that output say?

     

Log in to post a comment.