Step-by-step installation instructions for getting DNX on your Windows machine


Steps to install DNX (.NET Execution environment) 

The original instructions are here, but the steps below are organized better and fill some gaps. Except for the .NET 4.5.2, PowerShell 4.0 and VC++ redistributable, you don't need admin access for DNX itself as it deploys to your user folder.

Upgrade to .NET 4.5.2 (or higher) if you don't have it - Note needs about 3GB on C drive so you may have to make room first. This is a pre-requisite for PowerShell.
Reboot!

Upgrade PowerShell to latest version (4.0) if you don't have it already
 http://www.microsoft.com/en-us/download/details.aspx?id=40855&WT.mc_id=rss_alldownloads_all
(Select x64 version)
Reboot!

Install the Visual C++ 2013 redistributable package from here (in case you don't have it already). Install both the x86 and x64 packages. This is pre-requisite for Kestrel (the development web server).

Run PowerShell

Check powershell version:
 $PSVersionTable.PSVersion (should be 4.0)

Exit PowerShell

 

Issue the following command:

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

This will install DNVM (.NET Version Manager) to your user folder.

Close command prompt window.

 

Open new Command Prompt

dnvm

You should see help information for the DNVM command

 

If you use a Proxy Server within your environment (at work for example), pay attention to the next 2 lines, otherwise skip over it.
 setx http_proxy http://proxy.server.com:1234

Close prompt and open a new one - check that http_proxy environment variable has been set correctly.

 

dnvm install latest -Unstable -Persistent (this will pull the latest runtime bits and install to your user folder) 

dnvm list (this will show you all the installed runtimes and a * will be next to the current default)

Close prompt and open a new one

Type the following command:

dnx

You should see help information for DNX

 

Occasionally you can run the following command to get the latest DNX and DNVM bits:

dnvm upgrade

dnvm update-self

Finally we need to tell the package management system to get packages from the DEV package server.

Update c:\users\<user>\AppData\Roaming\Nuget\NuGet.config (this determines which source DNU RESTORE will use) with these contents. You can merge the existing contents.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="AspNetVNext" value="
https://www.myget.org/F/aspnetvnext/api/v2/" />
    <add key="nuget.org" value="
https://www.nuget.org/api/v2/" />
  </packageSources>
  <disabledPackageSources />
  <activePackageSource>
    <add key="AspNetVNext" value="
https://www.myget.org/F/aspnetvnext/api/v2/" />
  </activePackageSource>
</configuration>

 

Another option is use this DNU command instead of 'dnu restore':

 dnu restore -s https://www.myget.org/F/aspnetvnext

Note DNU is the .NET Utility which includes functionality to restore packages, build packages, compile code etc.

 

To test the installation:

Create a folder c:\temp\ConsoleApp
In this folder, create a file Program.cs with these contents:

using System;
public class Program
{
    public static void Main()
    {
        Console.WriteLine("Hello World");
    }
}

Also create a file project.json with these contents:

{
    "dependencies": {

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

Now using a Command Prompt, go to the folder containing the files and execute the following command:

dnu restore (this will pull all the required packages into your user folder)
dnx ConsoleApp

It should print Hello World!

 

You can also try the simple CookieSample web app from here.

Note for web apps you have to use the following command to run the development web server (kestrel):

dnx kestrel (assuming you are currently in the folder containing the project.json file)

 

Optional Step

If you would like to have a convenient way of editing your source files without installing Visual Studio, then check out OmniSharp. It is a free plug-in to some popular source editors that supports ASP.NET 5 development. The Atom editor works pretty well on Windows, is lightweight and deploys to the user folder (no admin permissions required). Also install the OmniSharp plugs for Atom. 

After you install Atom, close the editor and open a new command prompt and type this command if you use a Proxy Server in your environment: 

apm config set https-proxy http://proxy.server.com:1234

Then issue these commands to install the Atom plug-ins:

apm install autocomplete-plus
apm install linter
apm install omnisharp-atom

Then run Atom and follow the instructions here to use the intellisense etc.

Comments (10)

  1. xpy0928 says:

    so perfect ! but my OS is win 8.1 ,you give the link for powershell only support  win 8,so don't fix dvnm!!!  

    Do you any idea????finally,thakns for your help!

  2. xpy0928 says:

    so perfect ! but my OS is win 8.1 ,you give the link for powershell 4.0 version only support  win 8,so don't fix dvnm!!!  

    Do you have any idea????finally,thanks  for your help!

  3. Sujit DMello says:

    PowerShell 4.0 is already included in Win8.1 so you should be able to skip this step.

  4. xpy0928 says:

    yeah,I solve the problem !! you are right , My idea is fault,thanks !

  5. nettech says:

    Epic instructions!!!

    I think you have a typo error at end of article where the command is issued to run the code: `dnx . ConsoleApp`

    Removing the dot and the code ran as expected.

    Great work.  Thank you.

  6. Sujit DMello says:

    The '.' is required – it is the path of the application and '.' means current folder.

  7. Ja says:

    Has anyone got this to work? Docker run –rm -it windowsservercore cmd

    follow the instructions and when I get to typing dnx, it is telling me it cant load dnx win32 dll.

  8. Jonathan Gardner says:

    I am running Windows 10 and VS 2015 and ended up with Missing References in a new ASP.NET 5 MVC project.

  9. Curtis Hanner says:

    I am running Windows 7 and VS 2015.  I had to remove the "required" period to get the Hello World application to run.

    dnx ConsoleApp

  10. Sujit DMello says:

    Thanks – that was due to a recent RC1 update change. I've fixed the blog post.

Skip to main content