Generate .dll/.exe using Visual Studio Command Prompt.
Post date: Jun 1, 2011 2:16:02 PM
open Start>>VisualStudio2005/2008 >> Visual Studio tools>>Visual Studio Command Prompt.
Now in command Prompt Locate the Directory where you have saved the .cs file just created. Using CD command.
Here I have given myfile name "test.cs".
Now for compiling our dll using csc.exe we need to pass arguments you csc.exe like what type of file we want to generate, What will be name of output dll file and source file from which we are building our dll File.
csc /target:library /out:MyMaths.dll test.cs
Press Enter and you will get your desired DLL file generated!!
You just have created DLL fFile with Command Line C# Compiler. Now use that dll file in any .net project !!
Now you will raise question how do I compile multiple source file (.cs) files?
Well simple just execute commad like below one pass 2 names of source files in command while compiling it.
csc /target:library /out:MyMaths.dll test.cs test2.cs
Compiles File.cs producing File.exe:
csc File.cs
Compiles File.cs producing File.dll:
csc /target:library File.cs
Compiles File.cs and creates My.exe:
csc /out:My.exe File.cs
Compiles all the C# files in the current directory, with optimizations on and defines the DEBUG symbol. The output is File2.exe:
csc /define:DEBUG /optimize /out:File2.exe *.cs
Compiles all the C# files in the current directory producing a debug version of File2.dll. No logo and no warnings are displayed:
csc /target:library /out:File2.dll /warn:0 /nologo /debug *.cs
Compiles all the C# files in the current directory to Something.xyz (a DLL):
csc /target:library /out:Something.xyz *.cs