.Net Core On Ubuntu 18.04

As a Microsoft’s open source development initiative “.Net Core” is growing leaps and bounds, I decided to give it a try on Ubuntu 18.04 environment. Online guide for .Net Core is really rich and well defined but at a time it may become overwhelming following it for particular platform, especially on Linux (Ubuntu here). My goal is to follow same guide in context of Ubuntu system here.

.Net Core SDK Installation / Upgrade:

First step in setting up development environment is install .Net Core SDK that contains everything you need to develop and run .Net Core application on Ubuntu. To install .Net Core SDK is 2.2 (current stable version), please run below commands in terminal.

No need to run following command while upgrading .Net Core SDK.

wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb

sudo dpkg -i packages-microsoft-prod.deb

sudo add-apt-repository universe

Run following commands to install / upgrade existing .Net Core SDK.

sudo apt-get install apt-transport-https

sudo apt-get update

apt-get install dotnet-sdk-2.2

Verify sdk installation / upgrade by running following command

dotnet –version

Installation / upgrade is same process except initial steps need to be run only for first time installation. Screenshot shown here might show different text on fresh installation as I tried to take those after installation.

Upgrading to particular version may require to change version number while running command. In addition to that please make sure you change your existing project files to refer to new version. ASP.NET Core project may require quite a few modifications (well mentioned on .net guide) but for small simple .Net Core project please make sure to change TargetFramwork in csproj, vbproj or fsproj file depending on a language you are using for developement.

Migration from version 2.1 to 2.2 requires removing <DotNetCliToolReference> entry from project file as it is no longer required.

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>

 ...
...

Please let me know if you have any question while following particular step.

Windows 10 clock sync issue. It shows wrong time every time you boot in windows.

I had a weird issue that every time I start my PC I had to manually sync my clock as if it was not updating time automatically. I tried to change all possible system setting but issue was same.

But, next thing I noticed that clock was always right on booting into Ubuntu OS on same machine. So after little research I found out that Ubuntu sets hardware clock to UTC mode whereas Windows set it to local time and that conflict was causing clock on windows go out of whack.

So there were two ways I could fix the clock right, one is to change windows setting to make it refer hardware clock as UTC which Ubuntu sets but it required messing with windows registry and as you know it is not advisable to mess with registry unless you really know what you are doing! so I preferred second way which is to change setting on Ubuntu to make it set RTC in local time zone and it was relatively easy to follow.

So if you are facing same issue please try to run following commands and restart you pc and it will put end to this annoying issue.

First of all check if RTC in local TZ is set to no by running following command

timedatectl

Then run following command to set RTC in local TZ to yes.

timedatectl set-local-rtc 1 –adjust-system-clock

Verify that it set RTC in local time zone and restart pc. You may need to set clock final time after you boot into Windows.

Voila! you got rid of one annoying issue. By the way this might also help in other windows update issues you are facing because of clock mismatch.