.NET Core notes to self

May 26, 2016 · Follow on Twitter and Mastodon archive

I have been playing around with .NET Core since the early betas, but since I do so with rather long times in between, things break each time I pick up from where I left it. Here are some notes to self.

The many breaking changes in .NET Core means that I often have to start from scratch when I return to .NET, since the different versions have conflicts, old versions aren’t being properly unlinked etc. This can cause really frustrating problems, since new versions may not be used, or worse, be partially used.

So, here is a quick brain dump of what I often have to do when I upgrade my .NET Core environment.

First, some useful links:

Gettings Started

Before getting started, keep the following in mind:

  • Make sure to completely remove dnx and dnvm
  • Remove any previous versions of .NET Core, using the scripts Microsoft provides
  • Ensure that the dnx, dnvm, and dotnet are completely removed

Once this is done, do the following:

  • Install the latest .NET Core release
  • Install the latest Visual Studio Code release
  • Install the C# plugin for Visual Studio Code (cmd+p then search for c#)

The fact that C# is a plugin to Visual Studio Code always escapes me, causing me to have a full .NET Core environment, but no IntelliSense. This is (at the time of writing) nowhere to be found in the getting started guides (correct me if I’m wrong).

Unit Test

To setup your project to use XUnit as a test runner, add these dependencies:

  • “xunit”: “2.1.0”
  • “dotnet-test-xunit”: “1.0.0-rc2-build10015”

Add XUnit as a test runner by adding this below the dependencies node:

  • “testRunner”: “xunit”

Then, finally add the following import for netcoreapp1.0:

  • “portable-net45+win8”

Now, you should be able to run unit tests, using the dotnet test command.


If you don’t want to have to manually run the dotnet run and the dotnet test commands each time you make a code change, you can add DotNet Watcher to your project.

To add it, add a new tools node, or add the watcher tool to the tools node if you already have it:

"tools": {
   "Microsoft.DotNet.Watcher.Tools": {
      "version": "1.0.0-*",
      "imports": "portable-net451+win8"

You should now be able to run dotnet watch run and dotnet watch test to automatically restart your application or re-run your tests as soon as any code in your project changes.

Discussions & More

Please share any ideas, feedback or comments you may have in the Disqus section below, or by replying on Twitter or Mastodon..

If you found this text interesting, make sure to follow me on Twitter and Mastodon for more content like this, and to be notified when new content is published.

If you like & want to support my work, please consider sponsoring me on GitHub Sponsors.