BeetleDev.com
info
Saturday, September 26, 2020
Beetle Blog
Compiling a C# file using the command line
By: douglas - C# - 8/9/2002 12:00:00 AM

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.


Last Modified: 7/17/2003 1:24:00 PM

Beetle Blog v0.2.2


Copyright © 1997 - 2020 BeetleDev.com. All rights reserved.