The information on this post might be outdated because of updates and fixes released after I wrote it. After trying the latest setup instructions, if you are still having trouble installing .Net Core on Ubuntu, then the following text might help.
At the time of this writing (August 7, 2017), when I was trying to install .Net Core on Ubuntu, I found that it’s not supported on the latest Ubuntu 17.04. The setup instructions mentioned for earlier versions of Ubuntu didn’t work and gave errors related to missing dependencies.
$ sudo apt-get install dotnet-dev-1.0.4Reading package lists... DoneBuilding dependency tree Reading state information... DoneSome packages could not be installed. This may mean that you haverequested an impossible situation or if you are using the unstabledistribution that some required packages have not yet been createdor been moved out of Incoming. The following information may help to resolve the situation:The following packages have unmet dependencies: dotnet-dev-1.0.4 : Depends: dotnet-sharedframework-microsoft.netcore.app-1.1.2 but it is not installable>: Unable to correct problems, you have held broken packages.
After a bit of looking around, I found a GitHub issue on the .Net core repository related to this installation error. The solution provided there did the trick for me after trying a couple of things. The contents of this post are mostly just a concise version of the said GitHub issue thread.
Following steps are generalized to support installation of any version of .Net Core on any version of Ubuntu.
Step 1: Download the .Net Core binaries for Ubuntu/Debian from the downloads section of the official website. This will be a .tar.gz archive. I downloaded the SDK as I needed both the SDK and the runtime.
Step 2: Follow the setup instructions mentioned here. As you’ve already downloaded the archive(in step 1), you only need the last 2 commands where you extract the archive and then create a symlink to the
dotnet binary in the bin directory.
sudo mkdir -p /opt/dotnet && sudo tar zxf <downloaded\_archive>.tar.gz -C /opt/dotnet sudo ln -s /opt/dotnet/dotnet /usr/local/bin
That’s it. You have installed .Net Core on Ubuntu. You can test the installation by creating a simple console app, by following the instructions on the same page.
Visual Studio Code and the .Net core debugger problem
Ok, so to edit the console app and write some serious .Net code, I installed my favorite code editor, Visual Studio Code on the same Ubuntu machine. Guess what, when I tried debugging the same console app, it gave me another error saying,
The .NET Core Debugger is still being downloaded. See the C# Output Window for more information.
After some more digging, I found the solution for this too. I had to set the fallback version for Ubuntu runtime for the debugger in the Visual Studio Code editor, like this,
I’m not sure if it made a difference, but I selected the same Ubuntu version (16.10) in both the cases — for the archive and for the editor settings.
Et voila, we now have the .Net core runtime and the Visual studio code editor running in sync on a Ubuntu machine.
Loaded '/home/gautam/dotnet/shared/Microsoft.NETCore.App/1.1.2/System.Threading.Tasks.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. **Hello World!** The program '\[6329\] console1.dll' has exited with code 0 (0x0).
Happy .Net programming!