在编译的可执行文件中嵌入的DLL [英] Embedding DLLs in a compiled executable

查看:308
本文介绍了在编译的可执行文件中嵌入的DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您知道,我还没有看到这个在任何地方一个很好的答案。是否有可能嵌入pre-现有的DLL为编译C#可执行文件(这样你只有一个文件分发)?如果可能的话,怎么会去这样做呢?

You know, I haven't seen a good answer for this anywhere. Is it possible to embed a pre-existing DLL into a compiled C# executable (so that you only have one file to distribute)? If it is possible, how would one go about doing it?

通常情况下,我是酷只有离开以外的dll和有安装程序处理的一切,但已经有一对夫妇在工作中谁问过我这个人,我真的不知道。

Normally, I'm cool with just leaving the DLLs outside and having the setup program handle everything, but there have been a couple of people at work who have asked me this and I honestly don't know.

推荐答案

我强烈建议使用 Costura.Fody - 迄今为止最好的和最简单的方式嵌入资源在汇编。它可作为的NuGet包。

I highly recommend to use Costura.Fody - by far the best and easiest way to embed resources in your assembly. It's available as NuGet package.

Install-Package Costura.Fody

将它添加到项目后,它会自动嵌入被复制到输出目录到您的主要的组件的所有引用。你可能想通过添加目标到项目清理嵌入的文件:

After adding it to the project, it will automatically embed all references that are copied to the output directory into your main assembly. You might want to clean the embedded files by adding a target to your project:

Install-CleanReferencesTarget

您还可以指定是否包括PDB的,排除某些组件,或提取动态的组件。据我所知,也非托管程序集的支持。

You'll also be able to specify whether to include the pdb's, exclude certain assemblies, or extracting the assemblies on the fly. As far as I know, also unmanaged assemblies are supported.

更新

目前,一些人正试图增加对DNX 支持。

Currently, some people are trying to add support for DNX.

这篇关于在编译的可执行文件中嵌入的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆