tags:

views:

130

answers:

4

Is the path for the C# compiler, csc.exe, stored in a reference location somewhere?

I am working on a custom tool to compile code snippets into their own DLL's by the users so location could vary, would like to automate this as much as possible before resorting to the locate file dialog box!

+2  A: 

You can find the compiler here:

%windir%\Microsoft.NET\Framework\v[version number]\csc.exe

So, for .net 3.5, it would be

%windir%\Microsoft.NET\Framework\v3.5\csc.exe
Fredrik Mörk
+7  A: 

Is there any reason you want to invoke the binary directly, instead of using CSharpCodeProvider to programmatically compile?

You may be interested in my own snippet compiler (Snippy), which you can download the source for on my C# in Depth site.

Jon Skeet
+1 for the programmatic view. No -1 for self-promotion, because Snippy's actually useful.
Steven Sudit
interesting, will look into thisDoes this *require* a code file ? in this case there's only a custom function to compile from the code editor
Kumar
No - I never write the source to disk in Snippy, for example.
Jon Skeet
A: 

Not that I'm aware of. You can add it to your Environment Variable (Control Panel > System > Advanced > Environment Variables and add it under PATH). The path would be C:\Windows\Microsoft.NET\Framework[Framework Version] -- for example: C:\Windows\Microsoft.NET\Framework\v2.0.50727.

Nathan Loding
+1  A: 

Look at the document Command-line Building With csc.exe.

FerranB