Describe the bug.
The VS Code .NET SDK installer fails on Linux if the mono-mcs package is installed because it incorrectly thinks there is a conflicting dotnet installation.
Root cause: The Debian/Ubuntu package "mono-runtime-common" (a dependency of mono-mcs) installs an empty directory /usr/share/dotnet. The detection code here incorrectly concludes that there is a dotnet installation from the Microsoft package feeds.
Suggested fix: Improve that detection logic so it does not complain in this case, e.g. by checking for the file microsoftFeedDir + "/dotnet" instead of just checking that the directory exists. Note that there is similar code a few lines down, it would probably be a good idea to make a similar change there.
Some other minor feedback:
- It would be much more helpful if the path of the existing installation was shown at the start of the error message rather than being buried at the end.
- There are some typos in the error message -- lowercase "microsoft", extra "to continue".
Workaround: Install the .NET SDK manually (https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install).
Please attach log file(s) here if you have any.
N/A
Reproduction Steps
Steps to install VS Code and mono-mcs in Ubuntu 26.04 using Docker
docker build -t code - <<"EOF"
FROM ubuntu:26.04
# VNC server and misc dependencies
RUN apt-get update && apt-get install -y --no-install-recommends wget ca-certificates xvfb x11vnc
# Install VS Code (https://code.visualstudio.com/docs/setup/linux)
RUN wget -nv -O code.deb 'https://go.microsoft.com/fwlink/?LinkID=760868' && apt-get install -y ./code.deb
# Install Mono
RUN apt-get install -y --no-install-recommends mono-mcs
EOF
docker run --rm -it -p 5900:5900 code
useradd -m user
su - user
xvfb-run bash
x11vnc -safer -forever -rfbport 5900 -nopw 2>>~/.vnclog &
code --version # 1.133.0, a5b500951314efd502d07465bd138dfbd714a960, x64
code --verbose --no-sandbox # (sandboxing disabled because it fails in Docker)
Steps after launching VS Code:
When asked to sign in, click "x".
File > New File... > Program.cs > Save.
When prompted to install 'C# Dev Kit', click Install and wait for it to complete.
In the popup "The .NET SDK cannot be located: ... dotnet: not found ...", click "Get the SDK" then click "Install .NET SDK (10.0.1xx)".
Expected Behavior
Successful installation.
Exceptions & Errors (if any)
Error: "An error occurred while installing .NET: A dotnet installation was found which indicates dotnet was installed via Microsoft package feeds. ... You should not mix distro feed and microsoft feed installations. To continue, please completely remove this version of dotnet to continue by following https://learn.microsoft.com/dotnet/core/install/remove-runtime-sdk-versions?pivots=os-linux. Your install location: /usr/share/dotnet"
The directory /usr/share/dotnet indeed exists but it is empty; it's created by the Debian/Ubuntu package mono-runtime-common (as indicated by dpkg -S /usr/share/dotnet), a dependency of mono-mcs.
.NET Install Tool Version
v3.1.0
Your operating system? Please provide more detail, such as the version and or distro above.
Linux
VS Code Version
1.133.0
Describe the bug.
The VS Code .NET SDK installer fails on Linux if the mono-mcs package is installed because it incorrectly thinks there is a conflicting dotnet installation.
Root cause: The Debian/Ubuntu package "mono-runtime-common" (a dependency of mono-mcs) installs an empty directory /usr/share/dotnet. The detection code here incorrectly concludes that there is a dotnet installation from the Microsoft package feeds.
Suggested fix: Improve that detection logic so it does not complain in this case, e.g. by checking for the file
microsoftFeedDir + "/dotnet"instead of just checking that the directory exists. Note that there is similar code a few lines down, it would probably be a good idea to make a similar change there.Some other minor feedback:
Workaround: Install the .NET SDK manually (https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install).
Please attach log file(s) here if you have any.
N/A
Reproduction Steps
Steps to install VS Code and mono-mcs in Ubuntu 26.04 using Docker
Steps after launching VS Code:
When asked to sign in, click "x".
File > New File... > Program.cs > Save.
When prompted to install 'C# Dev Kit', click Install and wait for it to complete.
In the popup "The .NET SDK cannot be located: ... dotnet: not found ...", click "Get the SDK" then click "Install .NET SDK (10.0.1xx)".
Expected Behavior
Successful installation.
Exceptions & Errors (if any)
Error: "An error occurred while installing .NET: A dotnet installation was found which indicates dotnet was installed via Microsoft package feeds. ... You should not mix distro feed and microsoft feed installations. To continue, please completely remove this version of dotnet to continue by following https://learn.microsoft.com/dotnet/core/install/remove-runtime-sdk-versions?pivots=os-linux. Your install location: /usr/share/dotnet"
The directory /usr/share/dotnet indeed exists but it is empty; it's created by the Debian/Ubuntu package mono-runtime-common (as indicated by
dpkg -S /usr/share/dotnet), a dependency of mono-mcs..NET Install Tool Version
v3.1.0
Your operating system? Please provide more detail, such as the version and or distro above.
Linux
VS Code Version
1.133.0