Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Newly built .NET8.0 hello world console application fails to run

Tags:

c#

.net

.net-8.0

I've installed dotnet-sdk-8.0 as described here. Then I've created a new console application:

mkdir console
dotnet new console
dotnet build

running the binary conplains that .NET 8 is not installed

> ./bin/Debug/net8.0/console
You must install .NET to run this application.

App: /root/console/bin/Debug/net8.0/console
Architecture: x64
App host version: 8.0.0
.NET location: Not found

Learn more:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=linux-x64&os=ubuntu.22.04&apphost_version=8.0.0

dotnet --info disagrees:

> dotnet --info
.NET SDK:
 Version:           8.0.100
 Commit:            57efcf1350
 Workload version:  8.0.100-manifests.6c33ef20

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/8.0.100/

.NET workloads installed:
 Workload version: 8.0.100-manifests.6c33ef20
There are no installed workloads to display.

Host:
  Version:      8.0.0
  Architecture: x64
  Commit:       5535e31a71

.NET SDKs installed:
  8.0.100 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

I'm on ubuntu 22.04

> cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
like image 785
Rytis I Avatar asked Oct 16 '25 19:10

Rytis I


1 Answers

The problem is caused by previous install of dotnet-sdk-7.0 that doesn't property remove following files

/etc/dotnet/install_location
/etc/dotnet/install_location_x64
/etc/profile.d/dotnet.sh

removing them by hand solves the issue

> ./bin/Debug/net8.0/console
Hello, World!
like image 54
Rytis I Avatar answered Oct 18 '25 09:10

Rytis I



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!