visual-studio 一个 DLL,多个项目?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2016722/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:21:52  来源:igfitidea点击:

one DLL, multiple projects?

.netvisual-studiodll

提问by Sarah Vessels

Is it possible to force my C# solution file to make a single DLL containing all the projects in the solution, instead of one DLL per project? This dudesays that isn't possible but I notice that's a post from 2004. I'm using Visual Studio 2008 Team System and it's a C# application.

是否可以强制我的 C# 解决方案文件创建一个包含解决方案中所有项目的 DLL,而不是每个项目一个 DLL? 这家伙说这是不可能的,但我注意到这是 2004 年的帖子。我使用的是 Visual Studio 2008 Team System,它是一个 C# 应用程序。

回答by Reed Copsey

No. Each project will compile into a separate library or application.

不会。每个项目都将编译成一个单独的库或应用程序。

You can, however, merge these together into a single DLL or EXE file using ILMergepost compilation.

但是,您可以使用ILMerge后期编译将这些合并到一个 DLL 或 EXE 文件中。

回答by Dirk Vollmar

It is not possible with Visual Studio directly, but you can merge assemblies using ILMerge. This could e.g. be done in a post-build step:

直接使用 Visual Studio 是不可能的,但您可以使用ILMerge合并程序集。例如,这可以在构建后步骤中完成:

ilmerge /target:winexe /out:SelfContainedProgram.exe 
    Program.exe ClassLibrary1.dll ClassLibrary2.dll

If your project is an ASP.Net project you can rely on the ASP.NET Merge Tool.

如果您的项目是 ASP.Net 项目,您可以依赖ASP.NET 合并工具

回答by brendan

Never done it personally but looks like this tool could make that happen:

从来没有亲自做过,但看起来这个工具可以做到这一点:

ILMerge

合并

回答by SLaks

It is possible, and it was even possible in 2004.

这是可能的,甚至在 2004 年就有可能。

However, Visual Studio does not expose it.

但是,Visual Studio 不会公开它。

You need to use netmodules.

您需要使用netmodules

回答by Samuel Neff

You could create an MSBuild script that uses XSLT to combine all of the csproj files into one and then builds it. You won't need to copy cs files or anything like that, just dynamically generate a new csproj file.

您可以创建一个 MSBuild 脚本,该脚本使用 XSLT 将所有 csproj 文件合并为一个,然后进行构建。您不需要复制 cs 文件或类似的文件,只需动态生成一个新的 csproj 文件。