views:

614

answers:

2

I'm using NAnt 0.85 to build a legacy project. The script itself uses the csc task (not the msbuild task) and works fine.

The project is on its way to migrating over .NET 3.5. We already use VS2008, and C# 3.0, while still targeting .NET 2.0 framework runtime.

Now the problem occurs when we want to upgrade our NAnt scripts, to compile C#3.0 code using csc task.

I managed to compile C#3.0 code with NAnt, by modifying the nant.exe.config to add the net-3.5 framework section, but still, I can't figure a way to ensure that resulting assemblies will execute on .NET 2.0 runtime.

More problematic : if I'm using LinqBridge to leverage Linq without System.Core and .NET 3.5 runtime, the csc task fails and gave me an error message indicating that all linq-related calls are ambiguous. In fact, NAnt csc task seems to automatically reference System.Core.dll, which causes a conflict with the only reference I effectively added to the <references> section, under the csc task: LinqBridge.dll.

Do you now how to solve that?

+1  A: 

Executing on .NET 2.0 is mostly just a case of making sure you don't add a reference to any .NET 3.5-specific libraries. There are other subtleties where new types (e.g. DateTimeOffset) have been added to .NET 2.0 SP1 in existing libraries, but that's a different matter.

I suspect the LinqBridge problem is due to csc using the default response file. It's possible that specifying

noconfig="true"

will fix this. The documentation states that noconfig "Instructs the compiler not to use implicit references to assemblies" which sounds like what you want.

Jon Skeet
The noconfig="true" actually solved my problem. What I consider weird, thought, is that System.Core.dll is handled as a "default" dependency by the csc task when noconfig is false. In VS2008, and generally speaking in a csproj, it must be added manually if needed, which makes sense to me. It's not like say, mscorlib.
Romain Verdier
A lot of assemblies are in there - it's handy when compiling test programs from the command line. Look in csc.rsp to find out the defaults.
Jon Skeet
+1  A: 

Where to set noconfig="true" ??? Please specify. I have the same problem that i cant run my application online because of csc.exe problem.