/ ASP.NET Core

ASP.NET Core 2.0 on Mac

In case you you didn't know, you can develop an ASP.NET web application on Mac, Linux as well as Windows these days. Not just that, you even can host your .NET web application on Linux.

So, lets start with how to prepare you Mac.

What you will need?

First, you need the latest version of OpenSSL because the one that comes pre-installed on your shiny mac is old and has a lot of issues.

Go ahead and install Homebrew then open a new terminal and write the following:

brew update
brew install openssl
mkdir -p /usr/local/lib
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/

Thats it.

Now download .NET Core 2.0 (which is in preview 2 just now). This require macOS 10.12 or higher (64 bit)

Done. Your are ready for the new .NET world.

What? wait, where is Visual Studio?

Don't worry, Microsoft didn't forget you. With Mac, you have two options:

  1. The light version (I recommend it) is to use Visual Studio Code.
  2. Or, you can download the Visual Studio IDE for Mac.

Build your first web application

OK, you have .NET SDK installed and your preferred version of Visual Studio. Open a terminal window and write the following to start a web application called Blog:

cd your-sourcode-directory
dotnet new web -n Blog -o blog
cd blog
dotnet run

Open a new browser window and navigate to http://localhost:5000

Walla, your brand new Hello World! web application is running.

Wait what is dotnet new web -n Blog -o blog? Sure, lets explain it.

dotnet is your command line cli, most of what you will do in the terminal connected to .NET will start with dotnet.

new is a way to tell dotnet that we want to Initialize .NET projects. for a full list of all other SDK commands, you can type in the terminal dotnet -h.

web is the template we want to create, web is Empty ASP.NET Core template, you can use other templates such as mvc, razor or console. For a full list of the available templates type dotnet new -h

-n Blog is the name for the main namespace. If no name is specified, the name of the current directory is used.

-o blog is the name of the directory the dotnet command will create and add the code to.

This is a Preview version, when the final will be released?

According to the roadmap page, .NET Core 2.0 has a release date of Q3 2017. So in a month or two from now I would say.