简体   繁体   中英

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 .

From the site:

ILMerge is a utility for merging multiple .NET assemblies into a single .NET assembly. It works on executables and DLLs alike and comes with several options for controlling the processing and format of the output. See the accompanying documentation for details.

This is not the only tool - you can also use Mono.Merge for the same functionality.

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. Add each of these references to the "master" project.
  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.
  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM