Visual Studio One Project with Several Dlls as Output

Visual studio one project with several dlls as output?

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

  1. In a project you add all plugins files

  2. 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>
  3. 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>
  4. If you want to create the plugins library after each build, add an after build target :

    <Target Name="AfterBuild" DependsOnTargets="BuildPlugins">
    </Target>

Project with multiple DLL output

Each Project will create one DLL so you would need one Project per DLL. You could have them all in the same Solution though.

Generating two dlls from one project in csproj

You're not referencing System.Windows.Forms so it fails to find any of the Window derivatives.
Try adding it to the list of references, or remove the custom list of references entirely.

How can I create different DLLs in one project?

Here is a sample Post-Build event:

if "$(ConfigurationName)" == "Debug" goto Debug
if "$(ConfigurationName)" == "Release" goto Release

goto End

:Debug
del "$(TargetDir)DebugOutput.dll"
rename "$(TargetPath)" "DebugOutput.dll"

:Release
del "$(TargetDir)ReleaseOutput.dll"
rename "$(TargetPath)" "ReleaseOutput.dll"

:End

Change DebugOutput.dll and ReleaseOutput.dll to the proper filenames. you can change "Debug" and "Release" to support other configurations, and add sections to support more configurations.


That script will create two dlls with different file names; to create two different AssemblyNames, you have two options.

The assembly name is built as follows:

Name <,Culture = CultureInfo> <,Version = Major.Minor.Build.Revision> <, StrongName> <,PublicKeyToken> '\0'

So you have to either change the culture info, the version or the strong name.

The two simplest options are:

  1. Change the assembly version:

    #if SOME_COMPILER_SYMBOL
    [assembly: AssemblyVersion("1.0.0.0")]
    #else
    [assembly: AssemblyVersion("1.0.0.1")]
    #endif
  2. Change the keyfile - create two keyfiles with the sn tool, and in AssemblyInfo.cs:

    #if SOME_COMPILER_SYMBOL
    [assembly: AssemblyKeyFile("FirstKey.snk")]
    #else
    [assembly: AssemblyKeyFile("SecondKey.snk")]
    #endif

Both these options will result in two different assemblies as far as the GAC knows - since it compares the full assembly name, and not the 'simple' name.

Multiple DLLs from referenced .NET Standard projects

I found the following solution:

The ClockProject requires the MainProject and the TimeProject.

If I reference only the TimeProject in the ClockProject then it works (because the TimeProject references the MainProject), but the MainProject.dll is copied to the ClockProject Output folder, which I do not want.

However, if I reference BOTH projects in the ClockProject, the Main- and TimeProject and set both to CopyLocal = false, then only the ClockProject.dll will be copied into the Output folder of the ClockProject.

Place all output dlls in common directory from Visual Studio

You can set the output directory in each project properties.

Right click on the project, select Properties

For C#, it is one of the Build property page, under Output, Output directory.

In VB.Net projects, it is on the Compile tab, in the textbox at the top.



Related Topics



Leave a reply



Submit