In this post I will show you how to set up an Ubuntu desktop that you can use for .NET Core Development.
Why?
Maybe because you want to do Microsoft development on older hardware or because you think Windows is too bloated.
Install the OS
In this example I use the latest Ubuntu version. Mind you, in April another LTS version will be out but I can't wait and will probably update this article.
Update and essentials
Once installed, open up your terminal and enter:
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install -y wget curl git gitk \
vim build-essential linux-headers-$(uname -r) zsh
This the essentials you will want, build tools and zsh.
Oh My Zsh
I prefer the zsh and Oh My Zsh over Bash because of its auto complete features and eye candy.
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
And the Powerline fonts for a lovely prompt:
cd ~/Downloads git clone https://github.com/powerline/fonts.git cd fonts ./install.sh
Set the default shell to zsh:
chsh -s `which zsh`
Now log out and log back in.
You can then set your favorite theme by editing ~/.zshrc
.
Node.js
Next we will install Node.js and fix npm so we can run it without sudo:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs mkdir ~/npm-global -p sudo chown -R $USER:$USER ~/npm-global npm config set prefix '~/npm-global' #add to path: echo "export PATH=~/npm-global/bin:$PATH" >> ~/.zshrc
Trust the Microsoft sources
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
Add the repo's for the .Net Core SDK, Powershell, Visual Studio Code, SQL Server at once
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-artful-prod artful main" > /etc/apt/sources.list.d/dotnetdev.list' curl https://packages.microsoft.com/config/ubuntu/17.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list' sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)" sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/prod.list)"
Now install the software:
sudo apt-get update sudo apt-get install dotnet-sdk-2.1.3 powershell code mssql-server mssql-tools unixodbc-dev
Configure Sql Server
You will need to run setup to choose the correct Sql Server version and to set the SA password.
sudo /opt/mssql/bin/mssql-conf setup # Verify systemctl status mssql-server
Install Sql Server Tools
Next we need to instal sqlcmd:
wget http://download.microsoft.com/download/B/2/0/B20D3C84-C82A-4638-8E8C-164E09B96F71/sqlops-linux-0.25.4.deb sudo dpkg -i sqlops-linux-0.25.4.deb # Now login: sqlcmd -S localhost -U SA -P ''
And we're done
We now have an Ubuntu desktop for .NET Core development, including Sql Server. Now go ahead and do
dotnet new webapi
Next, install the Entity Framework Core package, create a full fledged backend and enjoy the fact that Microsoft has gone out of its way to make this all possible!
Script
For your convenience: here is a Gist that contains this script.
Links
https://github.com/PowerShell/PowerShell/blob/master/docs/installation/linux.md
https://code.visualstudio.com/docs/setup/linux
https://docs.microsoft.com/en-us/sql/sql-operations-studio/download
https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu