Visual Studio and .NET for Linux

Hello everyone.
I’m having a blast with this course, but I use Linux and this is to help get Visual Studio working on Linux.
I use Linux Arch and after installing Unity 3D you will need to download Visual Studio Code.
If you are using Linux, then you should know how to download.
Download Visual Studio Code NOT Windows Visual Studio.

If you have successfully downloaded and Linux will automatically install it, when you double click the .cs file inside Unity and Visual Studio Code opens up, you may get a message that it needs .NET installed.
Now. as I use Linux Arch I just needed to install dotnet-runtime and dotnet-sdk
If you are using other Linux distributions, such as Ubuntu, Debian, SuSE then follow these instructions.
.NET core 3.1 Ubuntu 20.04 -

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

Install the SDK

.NET Core SDK allows you to develop apps with .NET Core. If you install .NET Core SDK, you don’t need to install the corresponding runtime. To install .NET Core SDK, run the following commands:

sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-3.1

Install the runtime
The .NET Core Runtime allows you to run apps that were made with .NET Core that didn’t include the runtime. The commands below install the ASP.NET Core Runtime, which is the most compatible runtime for .NET Core. In your terminal, run the following commands.

sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y aspnetcore-runtime-3.1

As an alternative to the ASP.NET Core Runtime, you can install the .NET Core Runtime that doesn’t include ASP.NET Core support: replace aspnetcore-runtime-3.1 in the command above with dotnet-runtime-3.1 .

sudo apt-get install -y dotnet-runtime-3.1

If you get errors then see APT troubleshooting -

For Ubuntu 19.10 change 20.04 to 19.10 in the wget htpps://…

For Debian 10 it’s

wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb

then the rest of the commands in Ubuntu are the same.
Debian 9 is a little different

wget -O - https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget https://packages.microsoft.com/config/debian/9/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list

the rest of the code install is the same as Ubuntu.

OpenSuse as far as I know only 15 will work.

sudo zypper install libicu
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
wget https://packages.microsoft.com/config/opensuse/15/prod.repo
sudo mv prod.repo /etc/zypp/repos.d/microsoft-prod.repo
sudo chown root:root /etc/zypp/repos.d/microsoft-prod.repo

Install SDK

sudo zypper install dotnet-sdk-3.1

Install runtime

sudo zypper install aspnetcore-runtime-3.1

Alternative to ASP.NET Core Runtime

sudo zypper install dotnet-runtime-3.1

I hope that helps.
Probably not many people are using Linux for Unity 3D and Visual Studio, but just in-case you are…
Have fun!

By now, the separate “apt-transport-https” is obsolete (at least for Ubuntu 20.04).

I had some issues with dotnet 5.0.5 which my machine offered today so I downgraded to 5.0.4.

As a reference, these are the packages currently installed on my machine:

aspnetcore-runtime-5.0/focal,now 5.0.4-1 amd64 [installed,upgradable to: 5.0.5-1]
aspnetcore-targeting-pack-5.0/focal,now 5.0.0-1 amd64 [installed,automatic]
code/stable,now 1.55.0-1617120720 amd64 [installed]
dotnet-apphost-pack-5.0/focal,now 5.0.4-1 amd64 [installed,upgradable to: 5.0.5-1]
dotnet-host/focal,now 5.0.4-1 amd64 [installed,upgradable to: 5.0.5-1]
dotnet-hostfxr-5.0/focal,now 5.0.4-1 amd64 [installed,upgradable to: 5.0.5-1]
dotnet-runtime-5.0/focal,now 5.0.4-1 amd64 [installed,upgradable to: 5.0.5-1]
dotnet-runtime-deps-5.0/focal,now 5.0.4-1 amd64 [installed,upgradable to: 5.0.5-1]
dotnet-sdk-5.0/focal,now 5.0.104-1 amd64 [installed,upgradable to: 5.0.202-1]
dotnet-targeting-pack-5.0/focal,now 5.0.0-1 amd64 [installed,automatic]

This VS-Code extensions appears to be a simple way to get what you need:
ext install JasonBouKheir.minimal-unity-extensions

It depends on

  • C#
  • C# XML Documentation
  • Debugger for Unity
  • Unity Code Snippets

Omnisharp is set to “Use global Mono: always” with
mono-complete/focal,now 6.8.0.105+dfsg-2 amd64 [installed]

Sounds like you’re diving into some exciting stuff with Visual Studio and .NET on Linux! It’s great to see tools like Visual Studio Code being utilized in Linux environments. Thanks for sharing your experience and the steps for getting everything set up. By the way, if you’re ever curious about exploring different development environments, maybe considering upgrading to Windows 11 Professional edition could offer some interesting insights into your coding journey!

Well, some time has passed since I posted that list… :grinning_face_with_smiling_eyes:

By now I’ve got another machine running with Kubuntu 22.04 and there had been some changes on the VS-Code and Unity side as well.

/etc/apt/sources.list.d$ cat mono-official-stable.list 
deb [arch=amd64] https://download.mono-project.com/repo/debian stable-focal main

And installed are dotnet-sdk-6.0, dotnet-sdk-7.0, mono-complete (which is version 6.12.0.200 right now).

Unity-Hub is in a repo now:

/etc/apt/sources.list.d$ cat unityhub-jammy.list 
deb https://hub.unity3d.com/linux/repos/deb stable main

Privacy & Terms