[英]When I make a project reference in Visual Studio, do I then have to include the DLLs for those projects when I deploy?
I have a console application and two class library projects. 我有一个控制台应用程序和两个类库项目。
The console application has to project references to the class library projects. 控制台应用程序必须投影对类库项目的引用。
When I build, it generates DLLs for these two projects. 当我构建时,它会为这两个项目生成DLL。 Do I have to include these with my console applications exe file?
我是否必须将这些包含在我的控制台应用程序exe文件中? Is there a way I can make it so I don't have to include these 2 dlls?
有没有办法让它成功,所以我不需要包括这两个dll?
Ideally, I'd like to have a single exe. 理想情况下,我想要一个单独的exe。
You must include any referenced assemblies as they are dependencies of your application. 您必须包含任何引用的程序集,因为它们是应用程序的依赖项。
That being said, however, Microsoft offers a tool called ILMerge that will allow you combine the dependency assemblies with your executable to create one, all-inclusive, executable assembly that you can ship to customers. 尽管如此,Microsoft提供了一个名为ILMerge的工具,它允许您将依赖项程序集与可执行文件组合在一起,以创建一个可以发送给客户的可包含的可执行程序集。
查看ILMerge 。
You can merge the assemblies into one, using ilmerge , otherwise you'll have to deploy the exe file and the dlls. 您可以使用ilmerge将程序集合并为一个程序集,否则您将必须部署exe文件和dll。 eg you can run a command like
例如,你可以运行像这样的命令
ilmerge /target:winexe /out:MyProg.exe Program.exe ClassLib1.dll ClassLib.dll
Visual Studio provides no built-in way to do this, so you'd have to run the above command manually,as a Post Build event, or add it manually to your .csproj file. Visual Studio没有提供内置的方法来执行此操作,因此您必须手动运行上述命令,作为Post Build事件,或手动将其添加到.csproj文件中。
您应该能够通过选择引用并将“复制本地”属性设置为false来完成。
小心ILMerge并确保您了解走这条路线的性能影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.