Reputation: 896
Is it possible to get the DLL file for a single .CS file inside a big project ?
For eg: I have a project named 'Operations' in VS2012 where I have numerous window forms and .CS files.
I need to get a DLL file for the .CS files (which I have changed)... I know we can build the entire project and get the DLL file but how do I get the DLL file for one specific .CS file in that Project ?
Thanks
Upvotes: 0
Views: 3127
Reputation: 1440
It is possible as long as you have no dependencies on the other files in your project.
You can see different options How to: Build a Single-File Assembly
In short to create a single file dll you can use one of these command lines
:: will create File.dll
csc File.cs -t:library
:: will create FileOther.dll
csc File.cs -t:library -out:FileOther.dll
One of these to create a single file exe (file must have static main somewhere for an entry point)
:: will create File.exe
csc File.cs
:: will create FileOther.exe
csc -out:FileOther.exe File.cs
To create a dll or exe from multiple files you can specify multiple files on the command line: note that if doing an exe then either: only one should have a static main; OR you need to also use the /main switch
:: will create File.dll
csc File.cs File2.cs -t:library
:: will create File2.dll
csc File2.cs File.cs -t:library
:: will create File.exe
csc File.cs File2.cs
:: will create FileOther.exe
csc -out:FileOther.exe File.cs File2.cs
:: will create FileOther.exe using the entry point from NAMESPACE_WITH_MAIN_TO_USE
csc -out:FileOther.exe File.cs File2.cs /main:NAMESPACE_WITH_MAIN_TO_USE
:: will create alldirectory.exe
csc -out:alldirectory.exe *.cs
More general usage for the command line compiler can be found at Command-line build with csc.exe
Upvotes: 0
Reputation: 187
A DLL is the output for a library project, and not for a cs file.
If you want to have a dll for the specific class, - create a new project with the specific .cs - compile it in a new dll file - add the reference to the new dll file in your main porject
Upvotes: 2
Reputation: 31
I think the easiest way to do this would be to move the file into its own project and reference that project when you need to access the class.
Upvotes: 2