dnvm command

Installing ASP.NET 5 using DNVM (.NET Version Manager)

The starting point to start developing ASP.NET 5 application is how to install it. It is also important to be with the latest environment. There are two ways to install ASP.NET 5.

  1. Install ASP.NET 5 interactively
  2. Install ASP.NET 5 using DNVM Command (.NET Version Manager Command)

the easiest way to start is installing ASP.NET 5 is interactive. If you are interested into What is new in ASP.NET 5 beta8 read my previous blog post.

Install ASP.NET 5 interactively

An easy way to installing ASP.NET 5 interactive is as easy as you install any application in your window machine. You can download ASP.NET 5 beta8 installer from here. To develop ASP.NET 5 application, your should have Visual Studio 2015 installed from here. While installing Visual Studio 2015 you can also specify to install Microsoft Web Developer Tools or as specified earlier you can install standalone installer. The standalone installer is a just wizard, and you need to follow steps.

Install ASP.NET 5 using DNVM Command (.NET Version Manager Command)

To install ASP.NET 5 using DNVM, you need to have DNVM installed already. If you don’t have DNVM installed, you can install DNVM using the following command of PowerShell.

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

Alternatively, you can download PowerShell script dnvminstall.ps1 from GitHub.

After you install DNVM Command(.NET Version Manager Command) you can run dnvm on the command prompt. It will display you about dnvm command, version information, usages information, current feed settings, and commands of dnvm. If you are only interested into the version of DNVM Command, you can type dnvm version command.

about dnvm command
about dnvm command

While writing this blog post .NET Version Manager v1.0.0-rc2 has been released, but for now I am using .NET Version Manager v1.0.0-beta5, and I am going to demonstrate you about how to update dnvm command to latest version.
You can also update dnvm using dnvm update-self command

dnvm update-self command
dnvm update-self command

Run dnvm setup command to install the version manager into your profile directory. To skip configuring the user-level DNX_HOME and PATH environment variables use -SkipUserEnvironmentInstall optional switch with the dnvm setup.

The dnvm command is used to manage your .NET runtime. You can install a version of runtime, set default runtime, give the alias to installed runtime, list installed runtime, upgrade, and uninstall them. The Syntax to install .NET framework runtime is as follow

dnvm install [] [-a ] [-r ] [-OS ] [-Alias ] [-f] [-Proxy ] [-NoNative] [-Ngen] [-p] [-u] [-g]

To get a help on dnvm install command just type dnvm install. Alternatively, you can also type dnvm help to get help on particular command like dnvm help install, it will display the following output.

A version, nupkg path, or the string 'latest' must be provided.
dnvm install
  Installs a version of the runtime

usage:
  dnvm install [<VersionNuPkgOrAlias>] [-a <Architecture>] [-r <Runtime>] [-OS <OS>] [-Alias <Alias>] [-f] [-Proxy <Proxy>] [-NoNative] [-Ngen] [-p] [-u] [-g]

options:
  <VersionNuPkgOrAlias> The version to install from the current channel, the path to a '.nupkg' file to install, 'latest' to
install the latest available version from the current channel, or an alias value to install an alternate
runtime or architecture flavor of the specified alias.
  -a                   The processor architecture of the runtime to install (default: x86)
  -r                   The runtime flavor to install (default: clr)
  -OS                  The operating system that the runtime targets (default: win)
  -Alias               Set alias <Alias> to the installed runtime
  -f                   Overwrite an existing runtime if it already exists
  -Proxy               Use the given address as a proxy when accessing remote server
  -NoNative            Skip generation of native images
  -Ngen                For CLR flavor only. Generate native images for runtime libraries on Desktop CLR to improve startup time. This option requires elevated privilege and will be automatically turned on if the script is running in administrative mode. To opt-out in administrative mode, use -NoNative switch.
  -p                   Make the installed runtime useable across all processes run by the current user
  -u                   Upgrade from the unstable dev feed. This will give you the latest development version of the runtime.
  -g                   Installs to configured global dnx file location (default: C:\ProgramData)

remarks:
  A proxy can also be specified by using the 'http_proxy' environment variable

To uninstall .NET runtime type dnvm uninstall in Developer Command Prompt for VS2015.

You can use dnvm upgrade command to upgrade your .NET runtime. It will display progress on Developer command prompt like

dnvm upgrade command
dnvm upgrade command

You can use .NET Version Manager to install different versions of the DNX (.NET Execution Environment) to run and build the project. You can run the following command to install DNX for .NET core.

dnvm upgrade -r coreclr

You can also run the following command to install full .NET framework.

dnvm upgrade -r clr

To install x64 bit .NET framework use

dnvm upgrade -r coreclr -arch x64

After installing .NET framework, You can also view the installed framework. To view the installed. NET framework you can run following command in Developer Command Prompt for VS2015.

dnvm list

and, it will display Active Version, runtime, architecture, location, and alias of .NET framework as shown in the following image.

dnvm list command
dnvm list command

Alias is an easy way to refer .NET framework while executing dnvm commands. You can set alias name of .NET execution environment using following command.

dnvm alias full_default 1.0.0-beta8 -r clr -arch x86

and, to view and manage alias run

dnvm alias

to use or change .NET execution framework type following command

dnvm use full_default

ASP.NET 5 beta8

ASP.NET 5 beta8 announced

ASP.NET team has announced ASP.NET 5 beta8. You can download ASP.NET 5 beta8 using NuGet Packages and ASP.NET tooling for Visual Studio. You can find installation instruction for ASP.NET 5 beta8 for Windows, Linux, and Mac.

Document and samples of ASP.NET 5 beta8 can be found at http://docs.asp.net

What is an announcement in ASP.NET 5 beta8?

There would be changes like

DNX Watch Command
DNX Watch has file watcher. Your application will be restarted when you change any file in your application. To install DNX-watch use following command

dnu commands install Microsoft.Dnx.Watcher

You can use watch command like dnx-watch . You can start to watch command from the same directory of Project.json

While publishing your application, you can Specify target frameworks
You can specify target framework of application at the time of publishing your application using the following command

dnu publish -framework dnx45

and it will only trim publish package and include only those set of packages that required for your application and
resulting in smaller deployed package.

Targeting old frameworks
Now, you can target .NET 2.0 and .NET 3.5 frameworks in your DNX projects. You just need to specify net20 and net35 into target framework of Project.json file.

Clear HTTP Response Cache used for package response
When restoring packages dnu do HTTP caching for any request send. You can use the following command to clear the cache.

dnu clear-http-cache

DNVM uninstall
Whenever you are keeping updated with your latest DNX releases, you might be in a situation like DNX hanging out your machine. You can find ~/.dnx/runtimes folder into your user profile directory and delete older versions anytime. This is a just tedious task. So now, you can run dnvm uninstall to remove or uninstall specified runtime.

Add additional files to a package
DNX generating NuGet Packages for your projects, but, in that case, you are in a need to add additional files to your package. You can now add additional files to NuGet packages by specifying in project.json using new packInclude property.

"packInclude": {
    "destination1Directory/": "source1Directory/**",
    "destination2Directory/": "source2Directory/**",
    "destination2Directory/some_additional_file.txt": "source2a/somefile.txt",
    "destination3Directory/": ["source3Directory/file1.txt", "source3Directory/file2.txt"]
}

You can specify the set of source and destination directory to include into the package. You can also add files using pattern and array of files.

Run script for each specified framework and creating the package.
With DNX, you can handle multiple framework(like net45,net46 or dnxcore50), and multiple build configuration like debug and release). In project.json you can specify the script that run on before and after each package creation and build. before ASP.NET 5 beta8 script was run twice.

Consider you have two dotnet frameworks and two build configuration say release and debug. Now, your script can run four times once for each framework and once for each build configuration. The prepack and postpack script run twice once for each build configuration.

Change in IIS Hosting model
Up to ASP.NET 5 beta8 application runs in IIS have been hosted by the component called “Helios”, contained in the Microsoft.AspNet.Server.IIS. This component facilitated the bootstrapping of the DNX and subsequently the .NET CLR or Core CLR by way of utilizing a hook in the existing System.Web hosting model to replace the runtime after the application had started.

In ASP.NET 5 beta8, they have discontinued the “Helios” IIS host to reduce complexity and manageability of two hosting environments. Now, Hosting ASP.NET 5 applications in IIS will now be achieved using the IIS HttpPlatformHandler configured to forward through to the ASP.NET 5 Kestrel server. HttpPlatformHandler module is native IIS module hence it needs to be install by Administrator.