ASPNET Core 2 Self Contained App on Windows and Linux
Running on windows as a well as linux.
Get the correct RID for your running platform.
The modify the .csproj for the running assebmly and add each of the RIDs in.
ubuntu.14.04-x64
ubuntu.16.04-x64
After this then build it using the runtime identifier like so:
RUN dotnet publish -c Release -r ubuntu.16.04-x64 -o /app/out
Now just copy that to the correct environment and run the app with dotnet run and it should be golden.
References
- How to Publish a Self Contained Application -
https://blogs.msdn.microsoft.com/luisdem/2017/03/19/net-core-1-1-how-to-publish-a-self-contained-application/ - Self-Contained NET Core Applications -
https://www.hanselman.com/blog/SelfcontainedNETCoreApplications.aspx - Self-Contained Linux Applications - https://github.com/dotnet/core/blob/master/Documentation/self-contained-linux-apps.md
- Ubuntu 14.04 Prerequisites for Dot Net Core Runtime - https://github.com/dotnet/cli/blob/rel/1.0.0/scripts/docker/ubuntu.14.04/Dockerfile#L20 - Line 20-Line 30
- RIDs Catalog - https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
6.Create a DockerFile https://docs.docker.com/engine/examples/dotnetcore/#create-a-dockerfile-for-an-aspnet-core-application