Asp.Net Core: How to configure your development environment on Linux

linuxVsCode

In this post I explain how to setup an ASP.NET 5 RC1 development environment on Linux Ubuntu 14.04 using vagrant.

Here you’ll find the vagrantfile and the provisioning script used to setup your vagrant box.

You can also use the provision.sh script to configure an Ubuntu 14.04 VM without using vagrant. Nevertheless I strongly recommend to use vagrant and to follow the steps depicted here.

Install Vagrant on your windows host

  • First download and install chocolatey: https://chocolatey.org/
  • Install Cygwin and add the openssh through cyg-get, open a command or powershell pompt and type following commands:

choco install Cygwin

choco install cyg-get

cyg-get openssh 

  • Setup Vagrant and virtualbox:

choco install virtualbox

choco install vagrant

  • Test vagrant is installed correctly, Open a Cygwin terminal and type:vagrant –v

The console should output your vagrant version.  If this isn’t working check your path variable, the bin directory of vagrant should be added, if this is not found, add the vagrant bin dir to your Path.  (It’s usually: C:\HashiCorp\Vagrant\bin)

 

Download and setup your Linux base box with Vagrant

  1. Open a Cygwin terminal and type:

$ mkdir data

$ mkdir netCoreRC1

$ cd netCoreRC1

 

  1. Configure and launch your vagrant box
    Copy the ”Vagrantfile” and “provision.sh” into the directory netCoreRC1 – you’ll find these files here: https://github.com/geobarteam/vagrant/tree/master/netCoreRC1

Now run:

$ vagrant up

This will start your vm and start the provisioning process.

To stop or reboot your vm:

$vagrant halt

To login into your box through ssh:

$ vagrant ssh

If you need to reconfigure your keyboard for your country type:

sudo dpkg-reconfigure keyboard-configuration

It’s also recommended to create your own user with:
sudo adduser [your user name]
and add it to the sudo group:
sudo adduser [your user name] sudo

You can login in the gui interface with user: vagrant and password: vagrant.

To complete the install you’ll need to reboot your vm: vagrant reload
To test that .net core and mono are installed open a terminal or ssh session and type:

dnvm list

You should see something like:
Active Version              Runtime Architecture OperatingSystem Alias

—— ——-              ——- ———— ————— —–

1.0.0-rc1-update1    coreclr x64          linux             *

1.0.0-rc1-update1    mono                 linux/osx       default

If something went wrong or you want to use another user than vagrant, open an ssh session under the new user account:

ssh -p 2222 [username]@localhost

Copy paste following commands into the ssh window:

curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh

dnvm upgrade -r coreclr

dnvm upgrade -r mono

This should install .net core & mono and fix your box, if you still encounter errors you can find the detailed install procedure of .net core under:
https://docs.asp.net/en/latest/getting-started/installing-on-linux.html

Install Visual Studio Code

Go to: https://code.visualstudio.com/ and download Vs Code.
You’ll find the install instructions under: https://code.visualstudio.com/

Once you’ve rebooted your dev box you can start experimenting with asp.net 5.

A good point to get started is to use yo men (it was already installed through the provisioning step) to create an empty Asp.Net 5 app as explained here: https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-app-using-vscode/

Have fun!

 

Leave a Reply