Friday, 27 May 2016

Installing .Net Core on Ubuntu 16.04 LTS

The recent development by Microsoft in the ASP.Net core space is fascinating. With the introduction of ASP.Net Core 1.0 at the start of the year and then the recently released ASP.Net Core 1.0 RC2, I thought it would be a good idea to try it out on a Linux box.

The installation proved to be a bit trickier than I thought, so sharing my experience so as to help other out. The flavour of Linux I used was Ubuntu 16.04 LTS.

At the time of writing this post, the instructions present on Microsoft .Net Core website are for Ubuntu 14.04. Tried to follow the steps described on the website. However, execute dotnet failed with the following error on my machine
Failed to initialize CoreCLR, HRESULT: 0x80131500

So tried to proceed with some other steps. In general, installing .Net on Ubuntu require the following steps

1) Add .net repo to trusty sources list
2) Add key for the newly added trusted source
3) Install dotnet

To do the above, open up a terminal on your Ubuntu machine.

To add repo, run the following command
sudo sh -c 'echo "deb [arch=amd64] trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
To add the key, run the following command
sudo apt-key adv --keyserver --recv-keys 417A0893
Once, the above done, it's bes to update everything by running
sudo apt-get update
 Now that everything is done, .Net can be installed by running
sudo apt-get install dotnet

The above command, however, didn't work for me. It failed with the following error

The following packages have unmet dependencies: dotnet : Depends: libicu52 (>= 52~m1-1~) but it is not installable E: Unable to correct problems, you have held broken packages.

The error is quite self-descriptive, and the answer is to install libicu package. Ran the commnad
sudo apt-get install libicu-dev

The above command installed the libicu55 on my machine, whilst .Net core has a dependency on libicu52. Fortunately, the package is available for download here.

Once downloaded, the package can be installed by running
sudo dpkg -i libicu52_52.1-3ubuntu0.4_amd64.deb 

Now that the pre-requisite is installed, installing dotnet is simply a matter of running the following
sudo apt-get install dotnet

The above worked for me this time around. To test that it installed correctly, just type dotnet new in a new folder. It will create files for your .net project.

Please Note: Make sure that you set permissions to execute downloaded files described in this post. 


paul_ogle said...

shouldn't it be sudo dpkg -i to install the .deb package? Other than that, great tutorial!

Hamid said...

Yes you are right Paul. Thanks for correcting. I will edit the post.

johnny serup said...

This did not work for me on Ubuntu 16.04 LTS 64bit
it resulted in multiple unhandled exceptions - even after trying uninstall of old

Why are you using trusty when, I think 16.04 is xenial ??

Dileep.M said...

I'm trying to install on 16.04, i386 .

Getting following exception Please help.

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package dotnet-dev-1.0.0-preview1-00270
E: Couldn't find any package by glob 'dotnet-dev-1.0.0-preview1-00270'
E: Couldn't find any package by regex 'dotnet-dev-1.0.0-preview1-00270'

isabellaJoseph said...

Thanks for this blog. Provided great information. All the details are explained clearly with the great explanation. Learn.. Dot Net Training in Chennai
Selenium Training in Chennai
Hadoop Training in Chennai

john stany said...

I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

Android App Development Company
Android App Development Company

Karthika Shree said...

Wonderful bloggers like yourself who would positively reply encouraged me to be more open and engaging in commenting.So know it's helpful.
Dot Net Training in Chennai

Sharon Sandy said...

I just want to say that all the information you have given here is awesome...great and nice blog thanks sharing..Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...
Web Design Development Company
Web design Company in Chennai
Web development Company in Chennai

isabella jacob said...

it is really amazing...thanks for sharing....provide more useful information...
Mobile app development company

john stany said...

Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.i am expecting more updated posts from your hands.
iOS App Development Company

Sharon Sandy said...

great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
web design Company
web development Company
web design Company in chennai
web development Company in chennai
web design Company in India
web development Company in India

ASO Services said...

There are so many useful information in your post, I like it all the time. And I want to share this boost app ranking with you, you can take a look. This is very useful.

Anandh Jose said...

Howdy a dedication of appreciation is all together for the splendid offer and it will be noteworthy for a couple of individuals who are pursuing down best site building connection or so far working with webpage page arranging company.We in like manner give quality Web Design and Web change advantage at sensible cost .

excellent web developer service in bangalore
experts of eCommerce Website developers company in bangalore

ram ramky said...

Hai admin, thanks for sharing your thoughts with us. Your article helped me to gain knowledge on dot net environment.
Best DOT NET Training institute in Chennai | DOT NET Training Chennai

blackkutty said...

A debt of gratitude is in order for this blog. Given extraordinary data. Every one of the points of interest are clarified unmistakably with the immense clarification.