Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

targeting specific frawework version in csc.exe

Tags:

c#

How do you specify a target framework version for the csc.exe c# compiler via command-line invocation (e.g., no .csproj file and not going thru the MSBUILD engine)?

e.g, using the C# 3.0 csc.exe compiler, how do you compile to IL targeting the 2.0 .net framework?

like image 977
sbohlen Avatar asked Sep 28 '08 16:09

sbohlen


1 Answers

In the specific case of the C# 3 compiler, there isn't a problem so long as you don't use any assemblies or types which aren't in .NET 2.0 - the IL is the same (as opposed to targeting 1.1, for instance).

In addition to this, you can use /noconfig /nostdlib and then explicitly reference the .NET 2.0 assemblies (in c:\Windows\Microsoft.NET\Framework\v2.0.50727 for example). It looks like the /lib command line option can make this slightly easier by letting you specify a directory to look in for references, but I haven't tried that myself.

like image 128
Jon Skeet Avatar answered Sep 28 '22 06:09

Jon Skeet