wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
install SDK
sudo apt-get update
sudo apt-get install -y dotnet-sdk-8.0
Cehck this link for further information. Check dotnet version
dotnet -version
Doenload API code on Server. In my case I have my code in /opt/dotnetAPI/
cat /etc/systemd/system/callhome-bill-api.service
unit file to start .net code
[Unit]
Description=API
Wants=network.target
After=network.target
[Service]
Environment="ASPNETCORE_URLS=http://*:5000"
Environment="ASPNETCORE_WEBROOT=/opt/dotnetAPI/"
Environment="ASPNETCORE_CONTENTROOT=/opt/dotnetAPI/"
ExecStart=/usr/bin/dotnet /opt/dotnetAPI/API.dll
ExecStop=/bin/kill ${MAINPID}
Restart=on-failure
RestartSec=5s
Type=simple
[Install]
WantedBy=multi-user.target
Dot Net Envoirnmnet Variables
Check this link for compiling dotnet code on linux
Enjoy ;)