Blog Archives

There’s been quiet a few announcements throughout Build 2015. One of the many aspects that I am excited about is the new cross platform runtime environment called DNX, or the .NET Execution Environment.

There has been a lot of talk about how we can run more and more cross-platform during the conference and that’s what DNX is all about. There are several different pieces to DNX, including:

DNX (distribution): A NuGet package containing the implementation of the new environment. The .NET Core DNX distribution includes CoreCLR and the base parts of CoreFX. The .NET Framework and Mono DNX distribution only contain the DNX components.

Interestingly, when you install each of the runtimes, the installer generates native images for the target machine which improves the start up performance.

Switching between DNX runtimes

If you have the need to switch between different versions of DNX, you can use the dnvm use command which has the following format:

dnvm use -r coreclr -arch <arch> <version>

Where <arch> is, replace with the architecture that you would like to have; eg: x86, x64. With <version> replace with the version number that is shown in dnvm list:

dnvm use -r coreclr -arch x86 1.0.0-beta5-11682

The above is used to switch the current runtime to the x86 version of the 1.0.0-beta5-11682 build of DNX. To switch to the x64 version, simply switch out x86 for x64:

dnvm use -r coreclr -arch x64 1.0.0-beta5-11682

This only makes the DNX runtime apply to the current terminal session. We do have options of adding it to the user profile or the system profile (the system profile is not recommend). Usually, when we run dnvm use we get something along the lines of:

This time you see DNVM has added the run time to the user path, so the next time you start a terminal session, that will be the selected runtime.

Aliasing DNX runtimes

Aliasing is useful so you don’t have to remember those lovely version strings. To see the current aliases setup in your environment use, dnvm alias. This acts the exact same as the dnvm list command. Here is a sample output:

Alias Name
----- ----
Beta5 dnx-coreclr-win-x86.1.0.0-beta5-11682

You can create aliases in a few ways. The first is to specify the name and the version:

dnvm alias Beta5 -Version 1.0.0-beta5-11682 -Runtime coreclr

Using the above command, DNVM will create an alias for version 1.0.0-beta5-11682 with the x86 architecture on coreclr. Given that I have both x86 and x64 runtimes installed, I would suggest that the order of preference for the runtimes is x86, x64, arm, mono, everything else. However, we can specify a specific architecture with the command:

By specifying the architecture and using the same alias name, the DNVM has updated the alias to use the correct runtime. -Version, -Runtime and -Architecture can be shortened to -v, -r and -a respectively. If no runtime is specified, DNVM will default to the clr runtime.

When you have aliasing setup, you can use the alias within the dnvm use command. Note that you have to specify the runtime if you are not selecting the clr option:

Starting a DNX application

Before you can run your program, you need to ensure that your packages are restored. So enter dnu:

dnu restore

As mentioned earlier, dnu is all the other tools. It does builds, package restore and alot more. It can be thought of as a NuGet client plus more. Once the packages are restored, you can run your application:

dnx <path> run

All you need to do is specify a path, or use . as the path. The dot signifies the current working directory. If I build a quick console application and run the commands above, I get the following output:

One day, a poor boy who was selling goods from door to door to pay his way through school, found he had only one thin dime left, and he was hungry. He decided he would ask for a meal at the next house. However, he lost his nerve when a lovely young woman opened the door.Instead of a meal he asked for a drink of water. She thought he looked hungry so brought him a large glass of milk. He drank it so slowly, and then asked, How much do I owe you?”You don’t owe me anything,” she replied. “Mother has taught us never to accept pay for a kindness.”He said … “Then I thank you from my heart.”As Howard Kelly left that house, he not only felt stronger physically, but his faith in God and man was strong also. He had been ready to give up and quit.Many year’s later that same young woman became critically ill. The local doctors were baffled. They finally sent her to the big city, where they called in specialists to study her rare disease.Dr. Howard Kelly was called in for the consultation. When he heard the name of the town she came from, a strange light filled his eyes.Immediately he rose and went down the hall of the hospital to her room.Dressed in his doctor’s gown he went in to see her. He recognized her at once.He went back to the consultation room determined to do his best to save her life. From that day he gave special attention to her case.After a long struggle, the battle was won.

Dr. Kelly requested the business office to pass the final bill to him for approval. He looked at it, then wrote something on the edge and the bill was sent to her room. She feared to open it, for she was sure it would take the rest of her life to pay for it all. Finally she looked, and something caught her attention on the side of the bill. She read these words …

“Paid in full with one glass of milk”

(Signed) Dr. Howard Kelly.

Tears of joy flooded her eyes as her happy heart prayed: “Thank You, God, that Your love has spread broad through human hearts and hands.”