How to compile one project into several DLLs in .NET.

I am trying to compile a single .Net C # project into multiple DLLs. But here is what.

This is my project structure.

Bin 
Dir1 
Dir2 
File1.cs 
File2.cs 
myproject.csproj

I want to compile this project into File1.dll and File2.dll files. Both the File1.dll and File2.dll files use the code in the various .cs files that are in Dir1 and Dir2. Some of these classes in .cs files present in subdirectories require File1.cs, and the rest require File2.cs. There will be some that are used by both File1.cs and File2.cs.

I used the following:

csc /t:library /out:File1.dll /recurse:*.cs
csc /t:library /out:File2.dll /recurse:*.cs

DLL . , , dll , .cs Dir1 Dir2, File1.cs File1.dll File2.dll?

- Visual Studio.

...

. . , , , - DLL, File1.dll File2.dll. ..

, , , , File1.cs, File2.cs. , . , dll, File1.dll, File2.dll. . File1.dll File2.dll, . , ?

.

.

+5
4

, .

, , (Add as link), .

+9

DLL, , . myproject1.csproj File1.cs ( ) myproject2.csproj, File2.cs. , .

, , #if, .

+2

. CS .

, , , .

+1
source

You can use conditional compilation characters ( #if DLL1, #if DLL2).

Then in the build step, call msbuild with the option /p:DefineConstantsto set these characters.

MSBUILD /p:DefineConstants=DLL1 ...

basically compile your project twice with compilation conditionals set.

+1
source

All Articles