I am trying to compile a .cs file using CSharpCodeProvider from a .net 3.5 application, and I want to target the .net4 compiler, but I get this error "Csc.exe compiler executable could not be found." I have .net4 installed. Below is the code I'm using, with some lines omitted for brevity. When I install CompilerVersion in "v3.5", I get no errors.
CompilerResults results = null; using (CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary<string, string>() {{"CompilerVersion", "v4.0"},})) { CompilerParameters options = new CompilerParameters(); ... results = provider.CompileAssemblyFromFile(options, Directory.GetFiles(path, "*.cs", SearchOption.AllDirectories)); }
source share