简体   繁体   English

将解决方案中的项目合并到一个项目中?

[英]Merge projects in solution into a single project?

I have a solution with a few projects. 我有一些项目的解决方案。 How I can merge all projects into a single project? 如何将所有项目合并到一个项目中? I want to just compile my solution and get single file application at the output. 我想编译我的解决方案并在输出中获取单个文件应用程序。


Note: this question has been edited for clarity. 注意:为清楚起见,此问题已经过编辑。 Originally it was confusing and seemed to imply that it was looking for information on merging already-compiled assemblies. 最初它令人困惑,似乎暗示它正在寻找合并已经编译的程序集的信息。

我想你正在寻找ILMerge

(Answer based on old interpretation of question) (基于旧问题解释的答案)

I am assuming you want to merge all of the resulting assemblies into a single one, and not the projects in to a single solution. 我假设您要将所有生成的程序集合并为一个,而不是将项目合并到单个解决方案中。

If that is the case, use ILMerge . 如果是这种情况,请使用ILMerge

From the site: 从网站:

ILMerge is a utility for merging multiple .NET assemblies into a single .NET assembly. ILMerge是一个用于将多个.NET程序集合并到单个.NET程序集中的实用程序。 It works on executables and DLLs alike and comes with several options for controlling the processing and format of the output. 它适用于可执行文件和DLL,并带有几个选项来控制输出的处理和格式。 See the accompanying documentation for details. 有关详细信息,请参阅随附文档

This is not the only tool - you can also use Mono.Merge for the same functionality. 这不是唯一的工具 - 您也可以使用Mono.Merge获得相同的功能。

You want to merge the projects, not just the assemblies? 您想合并项目,而不仅仅是程序集?

I don't know any automated process, but I think you'll want to do something like: 我不知道任何自动化过程,但我认为你会想做类似的事情:

  1. Create your "master" project. 创建“主”项目。
  2. Look at the .NET and binary references (not project references) that other projects have. 查看其他项目具有的.NET和二进制引用(不是项目引用)。 Add each of these references to the "master" project. 将这些引用添加到“master”项目中。
  3. Create a folder for each project that you want to merge into the master project. 为要合并到主项目的每个项目创建一个文件夹。
  4. For each project, copy all files from that project to the corresponding folder in the master project. 对于每个项目,将该项目中的所有文件复制到主项目中的相应文件夹。 Make sure you give it the same BuildAction. 确保给它提供相同的BuildAction。
  5. Build! 建立! If the build fails, then you have more work to do. 如果构建失败,那么您还有更多工作要做。
  6. Remove the original projects from the solution. 从解决方案中删除原始项目。

Does every file in each project use its own namespace? 每个项目中的每个文件都使用自己的命名空间吗? If so, the above is all you have to do that I can think of. 如果是这样,以上就是我能想到的所有事情。 Otherwise, you'll want to make it so, recompile, and retest before trying to merge the projects into one. 否则,在尝试将项目合并为一个项目之前,您需要这样做,重新编译并重新测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 Wrapper 项目用于添加到解决方案中的多个项目的单个 WCF 服务 - Using a Wrapper project for a single WCF service added to multiple projects in a solution 如何在具有其他项目的解决方案中编译单个项目? - How to compile a single project in a solution that has other projects? 单个解决方案中的多个Web项目 - Multiple Web Projects in a Single Solution 单个解决方案中的多个MVC项目 - Multiple MVC projects in a single solution 在单个解决方案中调试多个项目 - Debugging multiple projects in a single solution 一个Visual Studio解决方案中是否可以有两个不同类型的项目(即,桌面项目和Web项目)? - Can you have two projects of different types (i.e. a desktop project and a web project) in a single visual studio solution? 单个解决方案中来自多个项目的日志 - Log from multiple projects in single solution 在一个解决方案中处理多个项目中的通用类 - Handling common classes in multiple projects in a single solution 在几个解决方案项目中引用共享项目 - Referencing shared project in several projects of solution .NET解决方案 - 许多项目与一个项目 - .NET solution - many projects vs one project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM