ASP.NET 5 Pre-RC 2 On Linux – Part I

Now that I’ve dabbled with running RC1 (Release Candidate 1) on Linux, time to start using the pre-RC2 bits as they use the new ‘dotnet’ CLI (Command Line Interface).

I started by creating a new Ubuntu VM, just like I did before for RC1, so there would be no cross-contamination between dnvm/dnu/dnx and dotnet.

I then went to the dotnet CLI repository on github https://github.com/dotnet/cli, and since I am using Ubuntu I downloaded the Debian package per the instructions. The heavy lifting of installing was then handled by the Ubuntu Software Center.

Capture

Per the instructions, in Terminal I then executed

export DOTNET_HOME=/usr/share/dotnet/

I then created a directory for my project with the following commands

cd ~
cd Documents
mkdir Code
cd Code
mkdir ConsoleApp1
cd ConsoleApp1

I then executed

dotnet new

This creates a new empty console project, which conveniently creates a program.cs file that emits “Hello World” via the console. The files are as below

Program.cs:

using System;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

project.json:

{
    "version": "1.0.0-*",
    "compilationOptions": {
        "emitEntryPoint": true
    },

    "dependencies": {
        "NETStandard.Library": "1.0.0-rc2-23616"
    },

    "frameworks": {
        "dnxcore50": { }
    }
}

Note: Unlike in RC1, the “emitEntryPoint” compilation option is a requirement!

Now that we have a project.json file and a Program.cs file, we need to restore, just like we did with dnu, but instead we just issue the dotnet restore command.

Note that since we are using post RC1 tools, we need to set the source for our packages using the -s parameter to be the dotnet-core repository on MyGet, rather than the using the default NuGet repository. This most likely will not be necessary with RC2 and above.

dotnet restore -s https://myget.org/f/dotnet-core

Now we can run the program by executing

dotnet run

the result?

failed to locate CLR files at /usr/share/dotnet/runtime/coreclr

I did a little investigating and the issue is the files are being installed under /usr/share/dotnet-dev/, not /usr/share/dotnet/. I reported this as an issue on github.

I then set the DOTNET_HOME variable like so

export DOTNET_HOME=/usr/share/dotnet-dev/

I then tried the program again

dotnet run
Hello World!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

OR

LOGIN OR REGISTER

Registered users with one approved comment can comment without moderation