.NET Core: Cross Platform – Windows

The .NET Execution Environment (DNX) is a software development kit (SDK) and runtime environment that has everything you need to build and run .NET applications for Windows, Mac and Linux.

However, package managers are the key component that have completely changed the face of modern software development and they’re very tied together in the .NET Core main tools: DNVM, DNU and DNX.

.NET Version Manager (DNVM)

The .NET Version Manager helps retrieving versions of the DNX, using NuGet, and allowing you to switch between versions when you have multiple on your machine. DNVM is simply a way to manage and download NuGet packages and it is a set of command line utilities to update and configure which .NET Runtime to use.
You can use the PowerShell script below to install DNVM. It just downloads an executes the dnvminstall.p1 script from the ASPNET/Home repo.

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"

It just installs the dnmv.ps1 command line tool and adds it to the %PATH% environment variable. No version of DNX will be installed at this point. Also, it is recommended to check and upgrade to the latest version of DNVM using the following command:

dnvm upgrade



DNVM solves the bootstrapping problem of getting and selecting the correct version of the DNX to run. You’ll find that the NuGet gallery hosts cross platform versions of DNX:

.NET Execution Environment (DNX)

The .NET Execution Environment (DNX) contains the code required to bootstrap and run an application. This includes things like the compilation system, SDK tools, and the native CLR hosts.

DNX provides a consistent development and execution environment across multiple platforms (Windows, Mac and Linux) and across different .NET flavors (.NET Framework, .NET Core and Mono).

It is easy to install the .NET Core version of DNX, using the DNVM install command:

dnvm install -r coreclr latest


You can then use dnvm to list and select the active DNX version in your system (In my case, the latest version of DNX CoreCLR is 1.0.0-beta8)

dnvm use 1.0.0-beta8 -r coreclr

dnvm list


Hello world

A DNX project is simply a folder with a project.json file. The name of the project is the folder name.

Let’s first create a folder, set it as our current directory in command line:

mkdir HelloWorld && cd HelloWorld


Now create a new C# file HelloWorld.cs, and paste in the code below:

using System;
public class Program {
    public static void Main(string[] args){
        Console.WriteLine("Hello World from Core CLR!");


Next, we need to provide the project settings DNX will use. Create a new project.json file in the same folder, and edit it to match the listing shown here:


    "version": "1.0.0-*",
    "dependencies": {
    "frameworks" : {
        "dnx451" : { },
        "dnxcore50" : {
            "dependencies": {
                "System.Console": "4.0.0-beta-*"

.NET Development Utility (DNU)

DNU is a command line tool that helps with the development of applications using DNX. You can use DNU to build, package and publish DNX projects. Or, as in the following example, you can use DNU to install a new package into an existing project or to restore all package dependencies for an existing project.


The project.json file defines the app dependencies and target frameworks in addition to various metadata properties
about the app. See Working with DNX Projects for more details.

Because the .NET Core is completely factored we need to explicitly pull those libraries that our project depends on. We’ll  run the following command to download and install all packages that are listed in the project.json:

dnu restore


You’ll notice that even though our project only required System.Console, several dependant libraries have been downloaded and installed as a result.

DNX run the app

At this point, we’re ready to run the app. You can do this by simply entering dnx run from the command prompt. You should see a result like this one:

dnx run

Further reading





Intro to .NET Core

.NET Core: Cross Platform – OS X

One Comment

Leave a Reply