.net核心软件包依赖项 [英] .net core package dependencies

查看:127
本文介绍了.net核心软件包依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个可以部署的本机.NET Core可执行文件,但是当我发布项目时,编译器会将所有依赖项导出到同一目录中,并且可执行文件需要它们在未运行的系统上运行安装了.NET Core运行时。有没有办法将DLL与项目DLL或可执行文件一起编译/打包?

I'm wanting to build a native .NET Core executable that I can deploy but when I publish the project, the compiler exports all the dependencies into the same directory and the executable needs them to run on a system that doesn't have .NET Core runtime installed. Is there a way to compile/package the DLL's in with the project DLL or executable? Thanks.

推荐答案

要将依赖项合并到编译的程序集中,请查看Costura for Fody:

For merging dependencies into the compiled assembly, check out Costura for Fody:

https://github.com/Fody/Fody

https://github.com/Fody/Costura

我以前使用过它,并且效果很好。您可以定义某些依赖项以合并到名为 FodyWeavers.xml 的文件中(请参见Costura-Fody链接以获取示例)。

I've used it before, and it works well. You can define certain dependencies to merge in a file called FodyWeavers.xml (see the Costura-Fody link for examples).

因此,例如(取自Costura README.md 的),您可以具有两个依赖项 Foo和 Bar,可以按照如下方式在FodyWeavers中合并到目标组件中。

So, for example (taken from the Costura README.md) you can have two dependencies 'Foo' and 'Bar' that can be merged into your target assembly as follows in the FodyWeavers.xml file.

<Costura>
    <IncludeAssemblies>
        Foo
        Bar
    </IncludeAssemblies>
</Costura>

除此之外,ILMerge是一种不错的选择: https://www.nuget.org/packages/ilmerge

Other than that, ILMerge is a fine way to go: https://www.nuget.org/packages/ilmerge

编辑:找到了一个链接,该链接描述了如何在自包含的应用程序中部署所需的.NET核心依赖项: http://druss.co/2016/08/deploy-and-run-net-core-application-without-installed- runtime-self-contained-applications /

Found a link describing deploying required .NET core dependencies in a self-contained application: http://druss.co/2016/08/deploy-and-run-net-core-application-without-installed-runtime-self-contained-applications/

这篇关于.net核心软件包依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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