简体   繁体   中英

.net core package dependencies

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.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM