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.
相关问题
- Generic Generics in Managed C++
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
- Should I use static function in c# where many call
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.
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/