Answer the question
In order to leave comments, you need to log in
How to compile a .NET Core project under ubuntu into one file?
On .NET Core, a netcoreapp2.0 console application for ubuntu is implemented and the project is built on the same ubuntu.
The project is published by the team dotnet publish -c release -r ubuntu.16.04-x64
The project is assembled and the finished project with all the necessary libraries and other dependencies is in the publish folder, which can be transferred to any ubuntu server and it will work fine there, but I would like not to miss the entire folder with a bunch of libraries, but just one executable file well, or at least somehow reduce the number of output files.
Is this possible, and if so, how to implement it, what are the ways?
Answer the question
In order to leave comments, you need to log in
There is something like that , but I would say it is not quite right and while it is in a pre-alpha state. The result is one "bold" executable file.
UPD. There is still this , but there will be even more crutches here
In theory, you can build a deb package that will contain your application.
Also, you can look here - https://docs.snapcraft.io/build-snaps/your-first-snap
This does not only apply to Core under Ubuntu. This also applies to regular .Net under Windows.
This problem is solved by adding all the dependencies of the executable file (for example, .exe) to the resources of this .exe itself. Then, when the application starts, the AppDomain.AssemblyResolve event handler is registered, which retrieves the required assembly from the resources, loads it into the domain, and returns a reference to it to the environment. AppDomain.AssemblyResolve is called every time the application needs a dependency.
It is simple and easy to implement, and it does not take much time.
There are also libraries that are built into the build process and allow you to automate this business. ILMerge has already been mentioned above , there is alsoFody , maybe there are some other analogues.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question