.NET Core/5 IConfiguration does not work on Ubuntu 20.10 x64 on Raspberry Pi 4 4GB

651 Views Asked by At

I've had multiple apps installed on my 32 bit Raspbian for the past 11 months or so with no problems to run them at all. Recently, I wanted to experiment with MongoDB and I needed a 64 bit OS version to get the latest build, so I decided to go with Ubuntu Desktop 20.10 x64. After installing Ubuntu, I tried starting one of my apps to see if all is well and it is not. At first, I thought it was a problem with .NET 5 (I migrated the app just to see if it works), but the problem persisted with .NET Core 3.1 as well, although it worked just fine before the OS switch.

The problems is that IConfiguration does not have values for the appsettings.json files. IConfiguration contains appsettings.json and appsettings.Production.json as providers, the providers contain the sections that I have defined, the sections contain the defined keys, but there are only null values on all of them.

I am unable to run the 32 bit version of dotnet, so I cannot really pinpoint where the problem is coming from. Does anyone know why it might do that?

To be noted that I've also tried running another .NET Core app that I used to host on Raspbian, which is not developed by me, and I get the same results. Everything breaks because the configuration is broken.

1

There are 1 best solutions below

0
On BEST ANSWER

The main problem was that I did not define the WorkingDirectory variable in the App.service file as I did before installing Ubuntu on my Raspberry. I tested this with an app and it's working when the variable is set, and not working when it's not.

The App.service file should look like this:

[Unit]
Description=App

[Service]
WorkingDirectory=/var/www/App/
ExecStart=dotnet /var/www/App/App.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=App
Environment=ASPNETCORE_URLS="http://localhost:5000"

[Install]
WantedBy=multi-user.target