Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I select the target framework of a CodeDom compiler using C#?

Tags:

c#

codedom

So I have a CodeDOM compiler written in C# that's supposed to compile another application based on one of its resources. How would I change the target .NET framework of the resource (or of the outputted executable of the compiler)?

like image 817
Alper Avatar asked Aug 28 '11 16:08

Alper


1 Answers

You could pass options to the compiler using the following constructor:

var providerOptions = new Dictionary<string, string>();
providerOptions.Add("CompilerVersion", "v3.5");
var compiler = new CSharpCodeProvider(providerOptions);
...
like image 66
Darin Dimitrov Avatar answered Oct 24 '22 02:10

Darin Dimitrov