Issue
I have a new Ubuntu 20.04.2 LTS install.
I have installed:
- Visual Studio Code 1.73.0
- .net 3.1 using this link here href="https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#install-the-sdk" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#install-the-sdk
- mono 6.12.0.182
For my project, I need to use .net 3.1. To do this in visual studio code, I have to use Mono (from what I read).
When I try to run the project, it does not show .net 3.1 or mono in the select box.
Anyone know how to fix this so VS code will allow me to use .net 3.1 or mono to run my .net 3.1 app?
one@work ...IS.custom-forms/frontend/widgets (core/EFB-1931/address-widget)
% which dotnet
/usr/bin/dotnet
one@work ...IS.custom-forms/frontend/widgets (core/EFB-1931/address-widget)
% dotnet --version
3.1.424
Solution
I verified the following workflow on a fresh VM with Ubuntu 20.04 LTS and with VS Code installed from Ubuntu Software (GUI).
Installing the .NET 3.1 SDK
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-3.1
Sanity check
dotnet --info
Output
.NET Core SDK (reflecting any global.json): Version: 3.1.425 Commit: ca553b8af8
Runtime Environment: OS Name: ubuntu OS Version: 20.04 OS Platform: Linux RID: ubuntu.20.04-x64 Base Path:
/usr/share/dotnet/sdk/3.1.425/Host (useful for support): Version: 3.1.31 Commit: 0e404aa9b8
.NET Core SDKs installed: 3.1.425 [/usr/share/dotnet/sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.App 3.1.31 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.31 [/usr/share/dotnet/shared/Microsoft.NETCore.App]To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Installing Mono
Ref https://www.mono-project.com/download/stable/.
sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-devel
Creating test app and launching VS Code
dotnet new mvc -n "TestProject" -au None
cd TestProject
code .
From the Extensions tab, install: C# for Visual Studio Code (powered by OmniSharp).
Go to settings (Ctrl+,). Search for "use modern net", uncheck the checkbox.
Open a terminal window (Ctrl+`) and close VS Code.
Open project again (from Ubuntu terminal):
code .
You should see the following output in the terminal window.
You can either select "Yes" on the notification or click "Generate C# Assets for Build and Debug" from the debug tab.
Select ".NET 5+ and .NET core" from the debugger dropdown.
Open Startup.cs from the Explorer tab and add a breakpoint.
Hit F5.
Q&A
When I try to run the project, it does not show .net 3.1 or mono in the select box.
Anyone know how to fix this so VS code will allow me to use .net 3.1 or mono to run my .net 3.1 app?
.NET 3.1 is included under the .NET core part of ".NET 5+ and .NET core". Chances are the C# dependencies and/or the package for Mono (ref screenshot) were not set up correctly. If you follow the workflow on a fresh install, you should be able to set the dependencies straight before attempting your actual project.
Answered By - Funk Answer Checked By - Clifford M. (WPSolving Volunteer)