Visual studio one project with several dlls as output?
I'm programming a project with plugin support. Since many of the plugins are relatively small (only one source-file/class) I would like to have them all in one project in visual studio, but to successfully do this I would need each source-file/class to be compiled into its own dll file, is this possible using visual studio?
If this is not possible with visual studio, would it be possible using another build system, while still coding and debugging with visual studio?
Currently I've set the plugins project output type to console, and programmed a main() method that will compile all .cs files in the source directory to dlls and copy those to the proper directory. Then I set that console app to be the post-build event of the plugins project. It works, but it seems like a very ugly hack.
Using visual studio 2010.
You could create one project for each plugin and group all projects in a solution.
If you don't want to have one project per plugin, you could create a custom build with MSBuild using CSC task
How to generate a dll for each plugin file
-
In a project you add all plugins files
-
Edit the project file to specify which class will generate a plugin library :
<ItemGroup> <Compile Include="Class1.cs"> <Plugin>true</Plugin> </Compile> <Compile Include="Class2.cs" /> <Compile Include="Class3.cs"> <Plugin>true</Plugin> </Compile> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup>
-
Add a new target in your project file to generate the plugins library
<Target Name="BuildPlugins"> <CSC Condition="%(Compile.Plugin) == 'true'" Sources="%(Compile.FullPath)" TargetType="library" OutputAssembly="$(OutputPath)%(Compile.FileName).dll" EmitDebugInformation="true" /> </Target>
-
If you want to create the plugins library after each build, add an after build target :
<Target Name="AfterBuild" DependsOnTargets="BuildPlugins"> </Target>
You just have to create a Solution
then add as many projects you want.
You can have like 5 Class Library
projects and compile them, generating 5 DLLs.