'Ubuntu - Segmentation Fault Error upon running dotnet new console

When I try to run 'dotnet new console' in either the Ubuntu or VS Code Terminal, I get the following error

Segmentation fault (core dumped)

Running it in the Ubuntu Terminal seems to give more information, looks like it's failing to do the 'dotnet restore' that automatically runs when you do 'dotnet new console'

Getting ready...
The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /home/max/Programming/C Sharp/Hello World/Hello World.csproj...
  Determining projects to restore...
Restore failed.
Post action failed.
Description: Restore NuGet packages required by this project.
Manual instructions: Run 'dotnet restore'

Segmentation fault (core dumped)

Running dotnet restore manually just gives the segfault error

Version of Ubuntu is 21.04, I have already installed everything as per https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2104-

Another thing to note is that I can build and run C Sharp applications fine in Monodevelop, and I can run non .NET languages such as Python fine in VS Code

Any ideas / assistance would be appreciated, thanks



Solution 1:[1]

I seem to have fixed this by uninstalling both .Net and VS Code via the instructions on Microsofts website, then installing again via the terminal commands / .deb file from Microsofts website

I had previously installed VS Code from the Ubuntu App Store, rather than via the .Deb from Microsoft

Solution 2:[2]

most likely, you installed dotnet-sdk by snap. You make unistall by snap and install by microsoft website.

https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2110-

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 max2015
Solution 2 Denisio Rodrigues