Visual Studio的一个项目有几个DLL文件作为输出? [英] Visual studio one project with several dlls as output?

查看:210
本文介绍了Visual Studio的一个项目有几个DLL文件作为输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编程插件的支持的一个项目。
由于许多插件都比较小(只有一个源文件/班),我想将它们全部在Visual Studio中一个项目,但要成功地做到这一点,我需要每个源文件/类其编译成自己的DLL文件,并使用Visual Studio是这可能吗?

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?

如果这是不可能的视觉工作室,这将有可能使用其他的编译系统,同时还进行编码和使用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?

目前我已经设置了插件项目输出类型控制台,程序将在源目录中的所有文件的.cs编译成dll文件,并复制那些正确的目录一个main()方法。然后,我设置控制台应用程序是插件项目的生成后事件。它的工作原理,但它似乎是一个非常丑陋的黑客攻击。

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.

使用Visual Studio 2010。

Using visual studio 2010.

推荐答案

您可以为每个插件和组中的解决方案,所有项目一个项目。

You could create one project for each plugin and group all projects in a solution.

如果你不想让每个插件的一个项目,你可以创建一个自定义生成使用的MSBuild的 CSC任务

If you don't want to have one project per plugin, you could create a custom build with MSBuild using CSC task


  1. 在一个项目中添加的所有插件文件

  2. 编辑项目文件来指定哪些类将生成一个插件库:

  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>


  • 在您的项目文件来生成插件库中添加一个新的目标。

  • 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>
    


  • 这篇关于Visual Studio的一个项目有几个DLL文件作为输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆