Prerequisites

Before publishing your .NET Core 5 application on a Linux machine, ensure the following requirements:

1. Install .NET Core SDK: Verify that the correct version of the .NET Core 5 SDK is installed.

  • Use the following command to check the installed version:
    dotnet –version
  • To install the .NET Core 5 SDK, follow the official Microsoft documentation.

2. Verify Dependencies:

  • Ensure essential dependencies like libicu, libcurl, and libssl are installed.

-> On Ubuntu-based distributions, install these dependencies with:
sudo apt update

  • sudo apt install libicu libcurl4 libssl1.1

Publish the Application

  1. Navigate to Project Directory:
    cd /path/to/your/project
  2. Restore Dependencies: Ensure the dotnet restore command completes without errors before publishing:
    dotnet restore
    If you encounter issues during restore, check the nuget.config file and verify the package sources are reachable.
  3. Publish the Application: Use the following command to publish your application:
    dotnet publish AppName.sln -c Release -o /path/to/output
    -c Release: Specifies the build configuration.
    -o /path/to/output: Specifies the output directory
    .
  4. Troubleshooting Stuck Restore Process:
    – Clear NuGet cache:
    – dotnet nuget locals all –clear
    – Check network connectivity and proxy settings.
    – Run the command with –verbosity detailed to get more information:
    dotnet restore –verbosity detailed

Run the Application

Once the application is published, navigate to the output directory and run the application:

cd /path/to/output
./AppName

If the application does not start, check the execution permissions:
chmod +x AppName

Logs and Diagnostics

Enable detailed logging with the following environment variable:
export
DOTNET_CLI_TELEMETRY_OPTOUT=1

  • export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
  • Check logs in the system journal (for system services):
    journalctl -xe

Conclusion

Following these steps, you can publish and run your .NET Core 5 application on a Linux machine. If issues persist, verify system dependencies, network connectivity, and environment configurations.

Need Help With .Net Development?

Work with our skilled .Net developers to accelerate your project and boost its performance.

Hire .Net Developers

Support On Demand!

Related Q&A