Starting Dotnet aspnet core 1.1 on OSX in a Docker container

December 27th, 2016

Install Docker on OSX.

Prepare local drive

(This is strictly not necessary but if you skip this you have to remove the -v and following path from the docker run command further down. You will also have to mkdir the app folder in the container before cd to it.)

Go to you your local Documents folder. Create a Docker folder. Inside it create a dotnetcore folder. This results in /Users/myname/Documents/Docker/dotnetcore.

Start container

Open a terminal and execute (after exchanging “myname” to your user’s name)

docker run -p 80:80 \
-e "ASPNETCORE_URLS=http://+:80" \
-v "/Users/myname/Documents/Docker/dotnetcore:/app" \
-it --rm microsoft/dotnet

This will download the microsoft/dotnet image, start it, connect your host’s dotnetcore folder to an app folder inside the container, set an environment variable, publish the internal port 80 on port 80 and finally open a terminal inside the container; all in one go.

Start the web server

Now inside the container execute

cd app
dotnet new -t web
dotnet restore

Absolutely not necessary but if you

cat Program.cs

you will see something like

namespace WebApplication
public class Program
public static void Main(string[] args)
var host = new WebHostBuilder()
// .UseUrls("")

Start the web server through

dotnet run

This will also compile the code before starting the application.

See output

If you open


in your host’s web browser you should now see a page about Dotnet aspnet core.

That all there is to it!

Trouble shooting

If you don’t check that the web server is running and listening on port 80 locally. This is done by opening a new terminal and check the ContainerID through

docker sp

Then you attach a terminal to the running container.

docker exec -it d10988067ec8 bash

(but with proper id)

Now, inside the container, run

curl localhost

and you should get a boatload of HTML back. In the other terminal window you should see some reaction to the request.


More thourough but for version 1.0

Learn children to be a producer of content and not only a consumer on a tablet

November 30th, 2016

A tablet is not only for onsuming what other people have done. You can too. Also a kid can.


Create your own side scroller.

There is also hardware if you want.

Coda game

I have not tested

Daisy the dinosaur

There is not a clear goal, just fiddle around. For good and bad. It is like making movies in ScratchJr but only side scrolling and less effects.

The Foos

It is like Lightbot but side scrolling and with funnier characters. The goal is somewhat funnier compared to lightbot; getting a donut for a (US) police officer instead of just lighting a light bulb. To try it out there is an older? version on the web.


Like Scratch.

Hour of code

Lots of stuff.

Lego Minecraft

Hard to use computer interface.


Light bot

Make a little robot find her way around stairs and obstacles.

Light bot looking but with famous figures like angry birds

Minecraft (pocket edition)


Unlogical user interface.

Also see for using Scratch with Raspberrypi.

More mechanical than programming

Pettson and Findus


I have not tested



I have not tested.

Move the turtle

On a proper computer


Quit skype with alt-F4 (Autohotkey needed)

October 20th, 2016

Due to overzealous user interface design Skype does not close with alt-F4 but instead minimises. That is not considered good behaviour.

I have found no setting in Skype to restore it normal Windows behaviour.

So I found and copied a Authotkey script that restores makes alt-F4 properly close Skype.

#IfWinActive ahk_exe Skype.exe ahk_class tSkMainForm

Kudos to original article

When code reviewing – do not forget to give appraisal too

September 29th, 2016

Albeit code reviewing is for the greater good and we all adhere to the idea of common ownage of code we are still critisising someone else’s labour.

Psychologically we cannot neglect that.

Ergo: remember to tell about the good solutions and code you find.

Unfortunately TFS does not have a (good) solution for differentiating between comments and praise and critisism.

AutoMapper does not play well with multi tier architecture

September 27th, 2016

I have found out that Automapper needs to be set up once and only once.
This means that one place has to know of all the classes that have a mapping. In a multi tier application this is not possible without treading on someone’s toes.

I have seen a solution which loops through all loaded assemblies and maps once and for all. But this solution means we have one such point – like when a web app is loading. So if you have automatic tests, that setup has to be called from there. And any kind of automatic loading of assemblies cannot use Automapper. Well… if one reinitialises all mappings one can.

I might see another solution where one has one assembly that knows of all assemblies (with mapping) and makes sure Automapper is initialised. My experimentation with this lead to circular reference problem though.

When I am at it – the documentation is short and straight to the point (good) but misses the point that the code in the documentation should be usable (not good).

The API was not explorable, which means that there is no natural way to start mapping and find out how the API works as one goes. Instead I had to google and find a bit here and a bit there.

With that said – it still solved a problem for me. And that is considered good.

Resharper and Visual studio short cuts

August 30th, 2016

There are some I use that might be useful for my readers too:

Resharper has 3 main combinations.
shift-alt-enter – Somewhat resembles Visual studio’s ctrl-..
ctrl-shift-r – Refactoring. Resharper’s raison d’être.
alt-ins – Inserting stuff by templates. E.g. a constructor taking all properties as arguments or Equal and GetHashCode methods.

ctrl-alt-q – Quickview instead of shift-f9

ctrl-w – Mark whatever you’re at. It can be set to recognise Pascal/camel cased words too as one often wants to edit just a part of a variable name.
Here’s a nice touch: continue press ctrl-w and the mark extends. A super way to mark a method.

ctrl-f12 – Go to implementation (instead of declaration). Often ctrl-f12 is enough.

alt-f12 – Sneak peak of whatever you are standing on. A good way to look at a called method body without having to  open yet a window, or move in an existing.
Here’s a nice touch: the opened sneak peak is a full fledged editor so go ahead and navigate, edit, debug and edit-and-continue as you are used to.

Above the method name (VS2015) there is a row with information about callers, editors, tests and whatnot. Hover over them with the mouse pointer and you get the shortcuts. They are typically ctrl-alt-1, ctrl-alt-2 und so weiter.

ctrl– and ctrl-+ – Navigate back and forward in history. On pre VS2015 this did not necessarily work with a non-us keyboard layout.

ctr-esc – Close the active tool window.

ctrl-shift-f12 – Go to the next item in a list, typically compile error but some other lists work too. Try compile with some errors. Then you can step through the errors with this shortcut.
TODO:Check it really is shift-alt-f12 as my muscle memory seems to elude me.

ctrl-shift-l – Delete current row. This is not as good as can be. Ctrl-l should be shorter but it is bound to cutting the row. Unnecessary really since ctrl-x does this if nothing is marked. I have earlier bound deleting a row to ctrl-l but nowadays don’t bother; i press ctrl-shift instead.

ctrl-x and ctrl-c – When nothing is marked they cut respectively copy the current row.

ctrl-shift-v – Cycle through Visual studio’s multi clipboard. A multi clipboard is a must. I use Ditto instead so I get a system wide multi clipboard with search capability and power off persistance.

shift-alt-enter – Maximises the window even more. There is no need for the top bar which says “Your project name – Microsoft Visual studio” and takes up the whole top of the screen. In the VB6 IDE one could even get rid of the menu; it is seldom needed to be visible – one just pressed alt or moved the mouse to the top and it showed again.

ctrl-r-t – Run the test method the caret is positioned in. If the caret is outside of a method is runs the whole class. If it is outside the class… – I haven’t checked, you tell me. Both Visual studio and resharper lacks some basic functionality like debug last method; as it stands now there is only run last method. I have the need to switch back and forth between running and debugging. If you are deep into writing tests – check Ncrunch which does a fantastic job of running tests and visualising what is tested and what is not. It also has the handy tool run any test that brings me to where the caret presently is. (r#)

ctrl-r-ctrl-t – Debug the test method… see ctrl-r-t. (r#)

One can have two windows side by side. Tests on the left and testee on the right. Or HTML on the left and Javascript on the right. Or client code on the left and server code on the right. One can have three windows side by side. Four.

Trick of the trade – set enum to not zero

July 5th, 2016

When defining enums set the first of the items to a non-zero value.
This way one knows whether one has forgotten to set the value.

using System;
public class Program
    private static int SomeNonInitiatedValueFromSomewhere = 0;
    public enum MyEnum
        AnItem = 1,
    public static void Main()
        var myEnum = MyEnum.AnotherItem;
        MyEnum myForgottenEnum = (MyEnum)SomeNonInitiatedValueFromSomewhere;
        Console.WriteLine("Now={0}", DateTime.Now.ToString("HH:mm"));
        Console.WriteLine("myEnum={0}", myEnum); // This enum is set.
        Console.WriteLine("myForgottenEnum={0}", myForgottenEnum); // This enum is not set.


Where the business logic resides in an application with O/RM

May 2nd, 2016

In an O/RM solution the business logic often ends up in the very queries. Don’t mock them if you want to test business logic.


Some hundred years ago when Microsoft was pushing their first Entity framework and all examples were PresentationLayer<->DataAccessLayer someone asked “When one is using an O/RM; where is the business logic?”

After all this time I have finally found out. In the very queries.

This effects the unit tests.
Because what you often want to test with unit tests is business logic and mock out everything else. The call to the O/RM is often quite simple. Then comes some hefty Linq statement that translates to EF or nHibernate. Then follows some simple handling of the result. The main logic is in the O/RM call.
So when one mocks out the O/RM one mocks out a big part of the logic.

One solution is to not mock out the O/RM but instead mock the data retrieval beneath. I have not figured out how to do this.

Another solution is to do an integration test all the way to the database. My first try at this was messy but worked out. My second try was equally messy but also worked out and has returned the investment many times. My third, and present, try uses helper methods to set up the data and contrary to the earlier tries it doesn’t look messy any more.
This is inspired by my present gig where the QA guy wrote a simple DSL with fluent syntax to set up test data. I have not managed to replicate his library but am, presently, happy with helper methods.

Change the font in the IDE

April 7th, 2016

I don’t think the standard type in Visual studio is the best one just because it is what is shipped.

Instead I test different and from 10+ years I have come to the conclusions:
1) Sans serif is better than serif.
2) Fixed width is not important – it is very seldom I need anything aligned by the count of characters.
3) Proportional width packs more characters per cm without losing readability.

Of all the fonts I have tested I still believe Arial is the best compromise.
Its drawbacks are that parenthesises are to narrow and that exclamation mark is too narrow and hard to read. I write mainly C# and Javascript and then ! is very important.
When I started out I believed that capital letter O looking similar to digit 0 would be a problem but have come to the conclusion that in reality it is not.

Fonts tested: (I have tested way more but just recently decided to write them down and cannot remember all)
Arial // yes
Arial narrow // Too dense to be readable on screen; for me at least.
Comics // Did not work for programming – too hard to read.
Consolas // Nope, too stiff.
Courier // Serif, does not work, too slow to read.
Leelawade UI // Works alrigh.
Malgun Gothic // A bit to wide for my taste. Also a bit “squarish”.
Microsoft new Tai Lue // Nice. A tad to wide for my taste.
Microsoft MHei // Lighter than Microsoft new Tai Lue. Maybe too light. About as wide.
Microsoft YaHei // Could be more narrow. Easy to read.
Nirmala UI Semilight //  Pixly.
Segoe UI // Currently testing.

Virtual machine – developing on a VM

April 6th, 2016

I have the host OSX for administrative tasks
and then one VM per Windows OS.

I would prefer to have one VM per customer but have not come around to it.
Setting up a new VM does not take that much time but installing Visual studio, Sqlserver, Chocolatey and configuring everything does. When Windows updates 7->8->8.1->10 I create new machine and copy stuff I need as I go; instead of updating the VM. This is my way of continuously cleaning my work space.

The only issue I have run into is multi monitor support that sometimes is a bit shaky to set up but it has stabilised every time. (as I write this my second monitor switches to green every time my screen saver has kicked in and I have to replug it)

I run Parallels which is not gratis and not even cheap. To add insult to injury they make sure to not support newer OSX and Windows versions as they come out. This means that the one time price (presently upgrade is 50€) has to be paid several times, like every other year or so.

I have not compared Parallels to their competitors Fusion and Virtualbox. AFAIK Fusion is about the same in both functionality and price. Virtualbox is free as in F/OSS.

The reason I started with Parallels instead of Virtualbox is twofold:
1) I was new to the host:OSX/vm:Win arena and wanted something someone said worked. (I did not want to buy a fancy pansy mac just to install windows on it)
2) By that time Virtualbox could not handle bootcamp.
My plan was to test to run Windows as a VM and if it wasn’t performant enough switch to bootcamp. Then I learned that to be able to run the vm as bootcamp it has to be configured as bootcamp to start with. I never did and I have never had the need.

(I would love to try to have the dev machine totally remote. Then I could have a phat machine without the fan noise.)