How to run a .NET Core console application on Linux [duplicate]

I am using Visual Studio 2015 and created a .NET Core console application. After compiling, I have my project DLL file in the debug folder. And if I want to run it on another computer, I have to install .NET on it and then write dotnet myApp.dll in command window (CMD). But I need to run my application without any installations.

I have read that I must publish my application. I do it with the command dotnet publish -c Release. Now in folder release I have a new folder, publish, with myApp.dll and other dll-files and folder runtimes for different systems. For example, in the Ubuntu.16.04-x64 folder I have file System.Security.Cryptography.Native.OpenSsl.so. But how can I run my application without any new installations of .NET or something else?


Follow the below steps to run your application:

  1. Publish your application as a self contained application:

    dotnet publish -c release -r ubuntu.16.04-x64 --self-contained
    
  2. Copy the publish folder to the Ubuntu machine

  3. Open the Ubuntu machine terminal (CLI) and go to the project directory

  4. Provide execute permissions:

    chmod 777 ./appname
    
  5. Execute the application

    ./appname