.net core package dependencies

為{幸葍}努か 提交于 2019-12-13 07:12:31

问题


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.


回答1:


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

https://github.com/Fody/Fody

https://github.com/Fody/Costura

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).

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>

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

EDIT: 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/



来源:https://stackoverflow.com/questions/39873960/net-core-package-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!