Publish the C# console program to run on the Linux server – effectively solve A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not

Table of Contents

Starting point: The console program written in C# contains the function of subscribing to device-side data and storing the data to the local computer. However, the local computer sometimes shuts down. How to deploy the program to run on the server side and save the data for a long time?

1. C# console program publishing operation steps

1) Select Production in the development environment -> Publish selected content

2) Select the next step, and select the target framework net6.0, the target runtime linux-x64, and change the target location to the path you want for easy viewing.

3) After the configuration is completed, select the publish button

4) Find the published content under the publishing path

5) View linux-x64 content

2. Compress the released Linux package and upload it to the designated location of the Linux server

3. Install the .net operating environment under Linux

When running the dotnet -h command, the following error will be reported:

Possible installation methods are as follows【1】

1) Remove previously existing .net packages (make sure they are not installed from the wrong repository)

?edit

2) Configure Microsoft’s repository to ignore .net packages

3) Delete the dotnet package you installed before

4) Manually install dotnet package

#1 Download the installation package

#2 Install SDK

#3 Configure the environment

#4 Verify the installation is successful dotnet -h

4. Run the program

refer to

Starting point: The console program written in C# contains the function of subscribing to device-side data and storing the data to the local computer. However, the local computer sometimes shuts down. How to deploy the program to the server to run? And save data for a long time

C# console development environment:

Win11 x64 development framework net5.0

Server environment: ubuntu22.04

The net environment supported under the server environment ubuntu22.04 is: net6.0 or above

Install .NET on Ubuntu 22.04 – .NET | Microsoft Learn

For this purpose, the framework selected when packaging and publishing the C# console program should be net6.0

Note: Solving the error problem A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist

1. C# Console Program Release Operation Steps

1) Select production in the development environment-“Publish the selected content

2) Select the next step, and select the target Framework net6.0, target runtime linux-x64 target location is changed to the path you want for easy viewing

3) After the configuration is completed, select the publish button

4) Find the published content under the publishing path

5) View linux-x64 content

2. Compress the released linux package and upload it to the designated location of the linux server

Decompression method for example:

rar x linux-x64.rar

3. Install the .net operating environment under Linux

Refer to this installation method: Installing .NET on Ubuntu 22.04 – .NET | Microsoft Learn

When running the dotnet -h command, the following error will be reported:

A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist

tried:

.net – A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist – Stack Overflow

cannot be effectively solved

The reason is: There are two dotnet folders on the system as follows

One symptom of these problems is that both the /usr/lib64/dotnet and /usr/share/dotnet folders are on your system.

Possible installation methods are as follows【1】

1) Remove previously existing .net packages (ensure they are not installed from the wrong repository )

sudo apt remove 'dotnet*' 'aspnet*' 'netstandard*'
< /h5>

2) Configure Microsoft’s repository to ignore .net packages

echo 'excludepkgs=dotnet*,aspnet*,netstandard*' | sudo tee -a /etc/yum.repos.d/microsoft-prod.repo

3) Delete the dotnet package that you installed before

rm -rf dotnet

4) Manually install dotnet package

Download .NET 6.0 SDK (v6.0.415) – Linux x64 Binaries

#1 Download the installation package
wget https://download.visualstudio.microsoft.com/download/pr/62a75533-4a7d-47e3-9863-4ab5eea04ea8/d802c8f82a8c2b5f276f68b87c682b70/dotnet-sdk-6.0.415-linux-x64.tar.gz
#2 Install SDK
mkdir -p $HOME/dotnet & amp; & amp; tar zxf dotnet-sdk-6.0.415-linux-x64.tar.gz -C $HOME/dotnet
#3 Configuration Environment
export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet

Or you can configure it in bashrc

#4 Verify whether the installation is successful dotnet -h

4. Run the program

dotnetxxx.dll
nohup dotnet xxx.dll &

You can see in the server background that the execution was successful!

reference

【1】Troubleshoot .NET package mix ups on Linux – .NET | Microsoft Learn

【2】Download .NET 6.0 SDK (v6.0.415) – Linux x64 Binaries

【3】 Download .NET 6.0 (Linux, macOS and Windows)

【4】 .net – A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist – Stack Overflow

【5】C# console program is published to the server Linux system to run_c# linux system service_QQ128619’s blog-CSDN blog

【6】linux install dotnet sdk_linux install dotnet-CSDN blog

The knowledge points of the article match the official knowledge files, and you can further learn related knowledge. CS entry skill treeHomepageOverview 37627 people are learning the system