This tech note shows how to compile a C# source file using the command line and tools provided with the .NET SDK
Compiling a source file into a library:
csc /t:library /out:bin/myLibraryAssembly.dll myCodeBehindFile.cs
Compiling a source file recursively into a library:
csc /t:library /out:bin/myLibraryAssembly.dll /recurse:*.cs
Compiling a source file into an exe:
csc /out:mySingleFileAssembly.exe myCodeBehindFile.cs
Note: You may need to set up path variables for you system if using cscresults in a "program not found error". The reason is because the system can't find the csc.exe program. Environment variables can be found in the control panel under "System". Your system path variable should include the paths to your compiler tools:
C:\Program Files\Microsoft.NET\FrameworkSDK\Bin\;
C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\;
C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\;
If you don't have access to the system variables, you may be able to put the path variable in your user path variable.
You may have to restart your computer to complete the change.