dotnet / dotnet/sdk

Installation & Packaging (Linux/RHEL 9)

Open
#55,100 1 comment 0 reactions 1 assignee Claimed by @mthalman View on GitHub
untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Describe the bug

Greetings dotnet/sdk team,

I'm having an issue installing Microsoft’s official .NET SDK on RHEL 9. During the installation, the installers say that packages are installing successfully, but then when attempting to write and change C# code in VSCode, I get an error message that says:

Image

Then I open the terminal to see what's wrong, and then it says all of this...
----
2026-07-01 11:07:01.172 [info] Locating .NET runtime version 10.0.5
2026-07-01 11:07:06.175 [info] Dotnet path: /home/mcook85/.config/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/10.0.9~x64~aspnetcore/dotnet
2026-07-01 11:07:06.175 [info] Activating C# + C# Dev Kit...
2026-07-01 11:07:07.060 [info] info: Program[0]
2026-07-01 11:07:07.060 [info] Server started with process ID 6279
2026-07-01 11:07:08.725 [info] [Program] Language server initialized
2026-07-01 11:07:08.727 [info] [Program] Monitoring client process 6011 for exit
2026-07-01 11:07:12.602 [error] [textDocument/_vs_getProjectContexts] [LanguageServerProjectLoader] Error while loading /home/mcook85/Documents/Scripts/2026_0630-(FightingEntropy).cs: Exception thrown: Microsoft.CodeAnalysis.MSBuild.RemoteInvocationException: An exception of type System.InvalidOperationException was thrown: Error while calling hostfxr function hostfxr_resolve_sdk2. Error code: -2147450725 Detailed error: No .NET SDKs were found.

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

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found

at Microsoft.CodeAnalysis.MSBuild.RpcClient.InvokeCoreAsync(Int32 targetObject, String methodName, List`1 parameters, Type expectedReturnType, CancellationToken cancellationToken) in /_/src/Workspaces/MSBuild/Core/Rpc/RpcClient.cs:line 185
at Microsoft.CodeAnalysis.MSBuild.RpcClient.InvokeNullableAsync[T](Int32 targetObject, String methodName, List`1 parameters, CancellationToken cancellationToken) in /_/src/Workspaces/MSBuild/Core/Rpc/RpcClient.cs:line 128
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.g__NoLock_GetBuildHostAsync|16_0(BuildHostProcessKind buildHostKind, String projectOrSolutionFilePath, String dotnetPath, CancellationToken cancellationToken) in /_/src/Workspaces/MSBuild/Core/MSBuild/BuildHostProcessManager.cs:line 152
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetBuildHostAsync(BuildHostProcessKind buildHostKind, String projectOrSolutionFilePath, String dotnetPath, CancellationToken cancellationToken) in /_/src/Workspaces/MSBuild/Core/MSBuild/BuildHostProcessManager.cs:line 104
at Microsoft.CodeAnalysis.LanguageServer.FileBasedPrograms.CanonicalMiscellaneousFilesProjectProvider.LoadCanonicalProjectAsync(CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/FileBasedPrograms/CanonicalMiscellaneousFilesProjectProvider.cs:line 76
at Microsoft.CodeAnalysis.LanguageServer.FileBasedPrograms.CanonicalMiscellaneousFilesProjectProvider.LoadCanonicalProjectAsync(CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/FileBasedPrograms/CanonicalMiscellaneousFilesProjectProvider.cs:line 78
at Microsoft.CodeAnalysis.LanguageServer.FileBasedPrograms.CanonicalMiscellaneousFilesProjectProvider.GetProjectInfoAsync(String miscDocumentPath, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/FileBasedPrograms/CanonicalMiscellaneousFilesProjectProvider.cs:line 30
at Microsoft.CodeAnalysis.LanguageServer.FileBasedPrograms.FileBasedProgramsProjectSystem.TryLoadProjectInMSBuildHostAsync(BuildHostProcessManager buildHostProcessManager, String documentPath, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/FileBasedPrograms/FileBasedProgramsProjectSystem.cs:line 318
at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectLoader.ReloadProjectAsync(ProjectToLoad projectToLoad, ToastErrorReporter toastErrorReporter, BuildHostProcessManager buildHostProcessManager, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectLoader.cs:line 234
2026-07-01 11:07:12.655 [info] [textDocument/_vs_getProjectContexts] [LanguageServerProjectLoader] Completed (re)load of all projects in 00:00:01.0690998
----

Copilot has suggested numerous scripts to get this working, but it is claiming that Red Hat's dotnet packages are pointing to the same references as the Microsoft dotnet packages, whereby causing a conflict and then they fail to ACTUALLY "install hostfxr because /usr/share/dotnet/host/fxr is already owned by Red Hat’s dotnet-hostfxr package. This results in a corrupted dotnet root where the SDK is present but hostfxr is missing, causing hostfxr_resolve_sdk2 to fail with error -2147450725 (“No .NET SDKs were found”)." (Copilots words)

I know Copilot is wrong a lot. But- I've spent a good couple hours trying to resolve this, and I'm not sure it's the best use of my time.
Maybe you could point me in the right direction. I'll provide my installation script below so you can try and reproduce the issue.

- mcc85s

### Steps to reproduce

I'm still playing around with this script here.

# Launch Terminal
# Enter Super User
# Set SubscriptionInfo
subscription-manager register

# Install groupinstall workgroup
dnf groupinstall workstation -y

# Epel-release
subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -y

# PowerShell
curl https://packages.microsoft.com/config/rhel/9/prod.repo | tee /etc/yum.repos.d/microsoft.repo
dnf install powershell -y

# Remote Desktop Tools
dnf install tigervnc-server tigervnc -y
yum --enablerepo=epel install xrdp -y
systemctl enable xrdp
systemctl enable xrdp-sesman
systemctl enable xrdp.service
systemctl start xrdp
systemctl start xrdp-sesman
systemctl start xrdp.service

//
// getent passwd
// :x:1000:1000:...:/home/:/bin/bash", then...>
// sudo usermod -s /bin/bash
// sudo mkdir -p /home/
// sudo chown : /home/
//
// id
//
// sudo usermod -aG wheel
//
// echo " ALL=(ALL) ALL" | sudo tee /etc/sudoers.d/
// sudo chmod 440 /etc/sudoers.d/

# Force GNOME to Xorg
sudo tee /etc/gdm/custom.conf > /dev/null << EOF
[daemon]
WaylandEnable=false
EOF

sudo systemctl restart gdm

# secondary force Xorg
sudo sed -i 's/^#xorg$/xorg/' /etc/xrdp/xrdp.ini

# Firewall
firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --add-port=3389/tcp
firewall-cmd --reload

# Enter PowerShell
pwsh -i

# Prime repos for Visual Studio Code + dotnet + Edge
$Link = "https://packages.microsoft.com"
$Keys = "$Link/keys/microsoft.asc"

[Console]::WriteLine("Creating *.repo for Visual Studio Code")
$Repo = "$Link/yumrepos/vscode"
$Path = "/etc/yum.repos.d/vscode.repo"
$Content = @"
[code]
name=Visual Studio Code
baseurl=$Repo
enabled=1
gpgcheck=1
gpgkey=$Keys
"@
$Content | sudo tee $Path > $Null

[Console]::WriteLine("Creating *.repo for Dotnet")
$Repo = "$Link/rhel/9/prod/"
$Path = "/etc/yum.repos.d/microsoft-dotnet.repo"
$Content = @"
[packages-microsoft-com-dotnet]
name=Microsoft .NET Packages
baseurl=$Repo
enabled=1
gpgcheck=1
gpgkey=$Keys
"@
$Content | sudo tee $Path > $Null

[Console]::WriteLine("Creating *.repo for Edge")
$Repo = "$Link/yumrepos/edge"
$Path = "/etc/yum.repos.d/microsoft-edge-stable.repo"

$Content = @"
[microsoft-edge]
name=Microsoft Edge
baseurl=$Repo
enabled=1
gpgcheck=1
gpgkey=$Keys
"@
$Content | sudo tee $Path > $Null

# Exit PowerShell
exit

# Install VSCode + Dotnet + Edge
dnf install code dotnet-sdk-8.0 microsoft-edge-stable -y

# Exit Root
exit

# Install PowerShell Extension + BossMode
code --install-extension ms-vscode.powershell
code --install-extension SecureDigitsPlus.BossMode
code --install-extension ms-dotnettools.csharp
code --install-extension ms-dotnettools.csdevkit

# Stage Edge
xdg-settings set default-web-browser microsoft-edge.desktop

# Stage VSCode to use edge
xdg-mime default code.desktop x-scheme-handler/vscode
xdg-mime default code.desktop x-scheme-handler/vscode-insiders

# Install Cascadia Code
sudo curl -s https://api.github.com/repos/microsoft/cascadia-code/releases/latest | grep browser_download_url | grep zip | cut -d '"' -f 4 | xargs sudo curl -L -o /tmp/cascadia.zip
sudo unzip /tmp/cascadia.zip -d /usr/share/fonts/cascadia
sudo fc-cache -f -v
fc-list | grep -i cascadia

# Settings.json
curl -L -o ~/.config/Code/User/settings.json https://github.com/mcc85s/FightingEntropy/blob/main/Scripts/2026_0617-vscode-settings.json?raw=true

# Then, I can open a C# file, but then I get that error message about being unable to open the project.

### Expected behavior

That I would be able to use VSCode like I do on Windows, and compile the C# code and run it.

### Actual behavior

It just shows that popup, and the fxr folder is definitely there, but it's empty.

### Is this a regression?

I'm not sure, I just know that it's a Linux issue. Cause I can write, compile, and run stuff on Windows C# build process.

### Are there any workarounds?

Uh, I guess I could just ignore it? Pretty sure that if I don't figure out a solution though, then any linux side development won't actually compile with roslyn.

### dotnet --info output

```console
PS /home/mcook85> dotnet --info

Host:
Version: 8.0.28
Architecture: x64
Commit: 46295af582
RID: rhel.9-x64

.NET SDKs installed:
No SDKs were found.

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.28 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.28 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
DOTNET_ROOT [/usr/lib64/dotnet]

global.json file:
Not found

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

Download .NET:
https://aka.ms/dotnet/download
PS /home/mcook85>
```

### IDE version

VS Code 1.126.0 (Cybercommando edition)

### Other details

Uh, yeah dotnet --info may say that it's not installed.

But here is the "fix it" script that I told Copilot to make, and it successfully retrieves the packages from the repository, and then it installs everything, and then at the tail end of it, the fxr stuff is STILL missing.

----
Write-Host "=== .NET FULL SYSTEM FIX SCRIPT ===" -ForegroundColor Cyan

# 1. Ensure base directory exists
Write-Host "`n--- Creating /usr/share/dotnet if missing ---"
sudo mkdir -p /usr/share/dotnet
sudo chmod 755 /usr/share/dotnet

# 2. Fix SELinux labels (if SELinux is enforcing)
Write-Host "`n--- Fixing SELinux labels (if applicable) ---"
try {
sudo restorecon -R /usr/share/dotnet
Write-Host "[OK] SELinux labels restored" -ForegroundColor Green
} catch {
Write-Host "[WARN] SELinux restorecon failed (SELinux may be disabled)" -ForegroundColor Yellow
}

# 3. Ensure filesystem is writable
Write-Host "`n--- Checking filesystem writeability ---"
try {
sudo touch /usr/share/dotnet/testfile
Write-Host "[OK] /usr/share/dotnet is writable" -ForegroundColor Green
sudo rm /usr/share/dotnet/testfile
} catch {
Write-Host "[FAIL] Filesystem is NOT writable. Attempting remount..." -ForegroundColor Red
sudo mount -o remount,rw /
}

# 4. Rebuild Microsoft repo
Write-Host "`n--- Rebuilding Microsoft .NET repo ---"
$repoContent = @"
[packages-microsoft-com-dotnet]
name=Microsoft .NET Packages
baseurl=https://packages.microsoft.com/rhel/9/prod/
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
"@

$repoPath = "/etc/yum.repos.d/microsoft-dotnet.repo"
$repoContent | sudo tee $repoPath > $null
Write-Host "[OK] Repo rebuilt at $repoPath" -ForegroundColor Green

# 5. Clean DNF metadata
Write-Host "`n--- Cleaning DNF metadata ---"
sudo dnf clean all
sudo dnf makecache

# 6. Remove all dotnet packages
Write-Host "`n--- Removing all dotnet packages ---"
sudo dnf remove dotnet* aspnetcore* -y

# 7. Reinstall runtime + hostfxr + SDK
Write-Host "`n--- Installing runtime ---"
sudo dnf install dotnet-runtime-8.0 -y

Write-Host "`n--- Installing hostfxr ---"
sudo dnf install dotnet-hostfxr-8.0 -y

Write-Host "`n--- Installing SDK ---"
sudo dnf install dotnet-sdk-8.0 -y

# 8. Verify installation
Write-Host "`n--- Verifying installation ---"
Write-Host "dotnet binary:" -ForegroundColor Cyan
which dotnet

Write-Host "`nSDKs:" -ForegroundColor Cyan
dotnet --list-sdks

Write-Host "`nRuntimes:" -ForegroundColor Cyan
dotnet --list-runtimes

Write-Host "`n--- FIX COMPLETE ---" -ForegroundColor Cyan
----

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.