简体   繁体   English

将一个C#项目编译成另一个

[英]Compiling one C# Project into another

I have a C# Application that uses some other Assemblies, so when I compile, I end up with my .exe and 2 or 3 other .dll Files. 我有一个使用其他程序集的C#应用​​程序,所以当我编译时,我最终得到我的.exe和2或3个其他.dll文件。 Ideally, I only want 1 .exe file. 理想情况下,我只想要1个.exe文件。 At the moment I use ILMerge for that, but as the Assemblies that I use are Open Source (and under the same license), I wonder if there is an easy way to add them to my Solution and compile them into the .exe? 目前我使用ILMerge,但由于我使用的程序集是开源的(并且在相同的许可下),我想知道是否有一种简单的方法将它们添加到我的解决方案并将它们编译成.exe?

What I do not want: 想要的:

  • Creating a Subfolder in my main .exe and copying all the other files into it 在我的主.exe中创建一个子文件夹,并将所有其他文件复制到其中
  • Adding it as a separate solution but then add it to my .exe Project with "Add as Link" 将其添加为单独的解决方案,然后使用“添加为链接”将其添加到我的.exe项目

I suppose that ILMerge is more or less doing exactly what I want, but if I can apply the merging on a compiler level already, that would be what I want. 我想ILMerge或多或少正在做我想要的,但如果我已经可以在编译器级别上应用合并,那就是我想要的。

Needless to say, the referenced assemblies have no main() function, so no clashes are to be expected. 不用说,引用的程序集没有main()函数,因此不会产生任何冲突。

You could add the dependencies as embedded resources and then load them manually but this would require a code change so it's not ideal. 您可以将依赖项添加为嵌入式资源,然后手动加载它们 ,但这需要更改代码,因此它并不理想。

I think that ILMerge is your best option here. 我认为ILMerge是你最好的选择。

由于我从未尝试过,我不知道这是否有效和/或是否符合您的期望,但是,可以选择将.net代码编译为netmodule而不是程序集,然后理论上这些模块可能是添加到其他程序集,您可以在这里这里阅读它。

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

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