简体   繁体   English

当我在Visual Studio中创建项目引用时,我是否必须在部署时包含这些项目的DLL?

[英]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.

相关问题 在项目中“添加为链接”时如何引用dll? - How do I reference dlls when “added as link” in project? MsBuild在我生成时会删除依赖项dll,然后在Visual Studio中进行调试 - MsBuild deletes dependency dlls when I build, then debug in Visual Studio 如何在ngrok上部署visual studio项目? - How do I deploy a visual studio project on ngrok? 我想签署我的项目的输出DLL,但这些项目可以在不同的机器上工作 - I want to sign output DLLs of my project but those projects could work on different machines 如何将 dll 作为引用包含在 nuget 中,当 nuget 添加到项目时,该引用也被复制为引用 - How do I include dll as reference in nuget that also gets copied as reference when nuget added to project Visual Studio C# 我可以使用哪个 Class 库项目引用 Blazor 项目 - Visual Studio C# with which Class Library Projects can I reference a Blazor Project 当我添加对项目的引用时,Visual Studio / Tools是否可以向我显示循环依赖关系图? - Can Visual Studio/Tools show me the Circular Dependency Graph when I add a reference to a project? 当我在同一解决方案中卸载项目时,Visual Studio 中的引用路径不起作用 - Reference Path in Visual Studio not working when I unload the project in the same solution 如何在Visual Studio中正确显示MVC项目? - How do I make a MVC project appear properly in Visual Studio? 我可以在没有Visual Studio的情况下编译DLL吗? - Can I compile DLLs without Visual Studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM