How to run ASP.NET MVC 5 on a Chromebook and how to install Visual Studio Code on a Chromebook

May 5 2015

This is amazing really. Not only can you install ASP.NET MVC 5 on a Chromebook, but you can also get Microsoft’s new open source code editor called Visual Studio Code running as well. Seeing Microsoft embrace cross platform editors, open sourcing code and supporting Mono is somewhat disconcerting. Not that it’s a bad thing. Just…well…it’s not the Microsoft of old, that’s for sure.

Installing ASP.NET on the Chromebook is fairly simple. You need to have crouton installed obviously, because this allows you to run a full desktop Linux install on your Chromebook. I’ve also got the crouton extension which basically allows the Linux desktop to run in a browser window!

Once that’s out of the way, run crouton (the default puts you into xfce) and install Visual Studio Code - download the .zip file and unzip it into a location of your choice. I had to install libnss3 to get the editor to run - this is a simple:

sudo apt-get install libnss3

from a terminal in xfce (YMMV):

ASP.NET 5 on a chromebook {: .center-block}

If you’re hitting problems, or Visual Studio Code just isn’t running, try running it from the terminal to see if you are missig any dependencies.

Then follow the instructions to install Mono on Linux. I had to manually create ~/.config/NuGet/NuGet.config, but I just pasted the suggested default in there and off I went.

Then simply continue following the Linux instructions for ASP.NET. This boils down to upgrading DNVM:

dnvm upgrade

Now clone the samples:

https://github.com/aspnet/home

This will create a home directory for you. Now you need to change into the samples directory:

cd home/samples/latest/HelloMvc

At last you’re ready to run the sample and as per the docs, you need to do the following:

dnx . kestrel

Which will fire up the kestrel web server for you and serve your ASP.NET MVC 5 sample application on your Chromebook on port 5004. Exit the full screen xfce and come back into your chrome browser, pull up a new tab and enter the address of http://localhost:5004 and you’ll see the default ASP.NET MVC 5 Hello World application. I’ve changed my view just a little:

ASP.NET 5 on a chromebook {: .center-block}


Connecting to a LocalDb instance from Visual Studio

May 1 2015

Visual Studio allows you to connect to a database server through the “Server Explorer” tab. However, I always forget how to connect to the LocalDb instance when I’m just prototyping in ASP.NET MVC. Here’s a small reminder.

Open the Server Explorer Tab

From within Visual Studio, click View -> Server Explorer or just Ctrl-Alt-s

Server explorer {: .center-block}

Pull up the add new connection modal

Click the little plug with a plus next to it to bring up the Add Connection modal

New database connection {: .center-block}

Connect

The server name drop down doesn’t usually display your local db instance, so typing is your best option. Put the following into your Server name text box:

(LocalDb)\V11.0

New database connection {: .center-block}

Then choose your database and click Ok.

An elephant never forgets

This is annoying to remember, so take a quick glance at your web.config file and simply copy the (LocalDb)\V11.0 from your connectionString.


Setting up powershell terminal with the solarized colour pallete

Dec 21 2014

The default Powershell terminal brutal blue colour scheme is just wrong.

Solarized is designed with readability in mind. Powershell is quietly becoming a rather powerul terminal with a very good scripting language. Mostly, I use Powershell for Git, and I want my terminal to embrace the Solaried colours. How hard can this be?

You might be surprised. Trying to customise Powershell is just as frustrating as having to look at that default brutal blue all day. Perhaps I just haven’t happened upon the right google terms yet, but really, I feel like it should be a simple matter of tweaking some settings in my Powershell profile to get it all to hang together.

You can, of course, set the colours through the Properties menu of Powershell. That’s clearly archaic, to say the least. It’s also not very portable - if I could tweak my profile then I would have a simple git repository I could clone onto any new machine and have Powershell set up just righ. But no. I’m clearly missing something somewhere, because although I found some docs on the subject and had some minor success, I failed miserably in finding out how to fine tune everything; replacing the entire terminal background colour, for example eluded me.

Until I find a better way, here’s what I’ve fallen back on….and what I’ve discovered about the Powershell Terminal in my travels. It relies on a Powershell Shortcut’s propensity to take it’s initial settings from the registry, with colours being set by the brilliantly named ColorTable00 to ColorTabel15 DWORDs. Once internalised, the registry setting can safely be deleted.

Let’s get to it.

Create the registry entries

Adding items to the registry in Windows is pretty simple. Create a .reg file and include the info you need in it. The registry path you want is HKEY_CURRENT_USER\Console\ShortcutName. So, for the purposes of this demo, we’ll put the following in our registry file:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Console\SolarizedPShell]
"ColorTable00"=dword:00362b00
"ColorTable01"=dword:00969483
"ColorTable02"=dword:00756e58
"ColorTable03"=dword:00a1a193
"ColorTable04"=dword:00164bcb
"ColorTable05"=dword:00c4716c
"ColorTable06"=dword:00837b65
"ColorTable07"=dword:00d5e8ee
"ColorTable08"=dword:00423607
"ColorTable09"=dword:00d28b26
"ColorTable10"=dword:00009985
"ColorTable11"=dword:0098a12a
"ColorTable12"=dword:002f32dc
"ColorTable13"=dword:008236d3
"ColorTable14"=dword:000089b5
"ColorTable15"=dword:00e3f6fd
"ScreenColors"=dword:00000001
"PopupColors"=dword:000000f6

Save this and name it solarizedPShell.reg. You can include more info like font size and window size, but this is an exercise in the Solarized Powershell terminal so we’re going with the colours and nothing else.

Double click your .reg file to add the contents to the registry.

Create your shortcut

On your desktop, right mouse button and select New > Shortcut.

Create shortcut { .center-block}

In the wizard that pops up, type powershell.exe into the first textbox when prompted to “Type in the location of the item:“.

powershell.exe { .center-block}

Click Next and then give the shortcut the same name that you gave to your registry entry above (SolarizedPShell).

Naming the shortcut { .center-block}

Click Finish

Launch Powershell from your newly created shortcut and you’ll have a Solarized Terminal! Yay! Success!!

Internalizing the settings and getting rid of the registry cruft

To internalize the settings, click on the icon in the top left of your Powershell window. Select Edit->Properties and change some settings - the font perhaps - Consolas is nice!

Powershell properties {.center-block}

Once you click Ok to save your settings, your registry entry basically becomes obsolete. Don’t ask me where Windows puts the settings, but you should be able to remove the registry entry you made earlier without any ill effect.

Kudos

High praise to Neil for his original .reg file with the Solarized colour scheme.


Previous Page