Category Archives: ASP.NET Core Pre-RC2

ASP.NET Core 1.0

Since my last post the name has been changed to ASP.NET Core 1.0.

Starting over to use the latest & greatest I uninstalled the previous packages in Ubuntu

I then Installed the Debian package from

https://github.com/dotnet/cli

I downloaded the latest samples from David Fowler

https://github.com/aspnet/cli-samples

Currently the HelloWeb code isn’t restoring for me (Unable to restore Microsoft.AspNetCore.Server.Kestrel), I assume this is because of as this moment the Ubuntu code isn’t building according to the CLI page above.

Instead, if I use my previous simple console app from here, and change the project.json to

{
    "version": "1.0.0-*",
    "compilationOptions": {
        "emitEntryPoint": true
    },
 
    "dependencies": {
        "NETStandard.Library": "1.0.0-*"
    },
 
    "frameworks": {
        "dnxcore50": { }
    }
}

And then change to the project directory and restore using the latest bits

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

It will build and run.

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

The next step is to try and run a web app.

There are samples under David Fowler’s (ASP.NET team member) github repository.

https://github.com/davidfowl/dotnetcli-aspnet5

I downloaded the .zip file, copied it to the Code folder from my previous post and extracted it.

I then switched to the HelloWeb sample folder in terminal

cd ~/Documents/Code/dotnetcli-aspnet5-master/HelloWeb

dotnet restore

(downloads 121 packages)

dotnet run

We get the following error

Screen Shot 2016-01-06 at 12.13.43 AM

So libuv needs to be installed as it is not present

install libuv per instructions

sudo apt-get install make automake libtool curl
curl -sSL https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | sudo tar zxfv - -C /usr/local/src
cd /usr/local/src/libuv-1.4.2
sudo sh autogen.sh
sudo ./configure
sudo make
sudo make install
sudo rm -rf /usr/local/src/libuv-1.4.2 && cd ~/
sudo ldconfig

Now we try again and success!

Screen Shot 2016-01-06 at 12.21.54 AM


Note that there looks like is a newer streamlined process for installing on Ubuntu here, but that doesn’t work for me, I reported it.

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

So now it is time to improve my development experience on this fresh Ubuntu VM. First step is to get a better code editor, and I select Visual Studio Code (VSCode) for the job.

To get VSCode visit:

https://code.visualstudio.com

I downloaded the .zip and then created a new folder under ‘Home’ called ‘Apps’

Using file explorer (Nautilus) I moved the zip from Downloads to Apps and extracted it.

capture_2

Then per the instructions, I created a link using the command

sudo ln -s ~/Apps/VSCode-linux-x64/Code /usr/local/bin/code

This allows us to start VSCode in the current folder by typing

code . 

in terminal.

Also, to create the UI shortcuts I browsed to the Code executable using Nautilus, right clicked Code, selected ‘make link’ and dragged it to the desktop and rename it to VSCode.

capture_3

I started code by clicking the shortcut and since it will be commonly used,
I right clicked the icon on Ubuntu’s side toolbar (Launcher) and selected “Lock To Launcher”.

All seemed fine but then I noticed a message in the lower right corner of VSCode, ‘failed to start OmniSharp’. Clicking on that reveals the message

Capture4

VSCode uses Omnisharp for intellisense so this is a problem.

In the end the solution for me was to install the latest development version of Mono (4.2.1), using the command

sudo apt-get install mono-devel

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!