I follow these instructions to install dotnet on Ubuntu 20.04.
Install the sdk Ubuntu 20.04
These instruction is at this time:
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb
sudo apt-get update && sudo apt-get install -y dotnet-sdk-6.0
Now I can build net6.0 projects.
I then install 7
sudo apt install dotnet-sdk-7.0
Then when I try to build my net6.0 project I get:
CSC : warning CS8034: Unable to load Analyzer assembly /usr/share/dotnet/sdk/7.0.200/Sdks/Microsoft.NET.Sdk.Web/analyzers/cs/Microsoft.AspNetCore.Analyzers.dll : Could not load file or assembly 'Microsoft.AspNetCore.Analyzers, Version=7.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Access is denied.
And the same error on a bunch of other assemblies.
I should not get an error about a net7.0 assembly when I try to build my net6.0 project.
If I change the target framework in csproj to net7.0, I get the same error.
I can however still build my project both as net6.0 and as net7.0 if I add sudo.
The permissions are what you would expect:
ls -l /usr/share/dotnet/sdk/7.0.200/Sdks/Microsoft.NET.Sdk.Web/analyzers/cs/Microsoft.AspNetCore.Analyzers.dll
-rw-r--r-- 1 root root 42664 jan 30 23:01 /usr/share/dotnet/sdk/7.0.200/Sdks/Microsoft.NET.Sdk.Web/analyzers/cs/Microsoft.AspNetCore.Analyzers.dll
It is the same permissions as the corresponding net6.0 file.
I tried this:
- I uninstalled everything dotnet.
sudo apt remove dotnet-sdk-6.0 dotnet-sdk-7.0 dotnet sudo apt clean autoclean autoremove
- And there was nothing left under /usr/shar/dotnet
- Reinstalled
- Tried adding:
export DOTNET_ROOT=/usr/share/dotnet
export PATH=$PATH:$DOTNET_ROOT
This made no difference.
My colleague found that the installation of dotnet-sdk-7.0 on Ubuntu 22.04 also destroyed the possibility to build net6.0 projects. However I don’t have all the details on that.
Some of the output from dotnet –info
.NET SDK:
Version: 7.0.200
.NET SDKs installed:
6.0.406
7.0.200
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.14
Microsoft.AspNetCore.App 7.0.3
Microsoft.NETCore.App 6.0.14
Microsoft.NETCore.App 7.0.3
Environment variables:
Not set
global.json file:
Not found
2
Answers
I took a new stab at this problem. I followed the instructions here: https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#troubleshooting
The two bash instructions, first this:
and then this:
Then it suddenly worked
It’s a horrible workaround but I’ve been having the same issue and I found that running
dotnet build
as root (i.e.sudo dotnet build
) allowed the build to succeed.Like yours, my permissions on the reference files look fine. I suspect there is some internal tooling in the 7.0 SDK that is being installed with incorrect permissions.
My
dotnet --info
, for reference: