Deploying ASP.NET 5 on OS X - Getting Started with ASP.NET 5 for OS X, Linux, and Windows (2015)

Getting Started with ASP.NET 5 for OS X, Linux, and Windows (2015)

2 Deploying ASP.NET 5 on OS X

In this chapter we will learn how to deploy ASP.NET 5 on OS X.

2.1 Getting Started

In this section we start to deploy ASP.NET 5 on OS X. In this book I use ASP.NET 5 preview, beta4. Please follow installation steps on next section.

2.2 Deploying ASP.NET 5

To install ASP.NET on OS X, you can use brew, http://brew.sh/ . Type these commands to install ASP.NET 5.

$ brew tap aspnet/dnx

$ brew update

$ brew install dnvm

mc1

If success, you can see a task which you should do. We must add dnvm on our profile.

mc3

Type this command.

$ nano ~/.bash_profile

Then, you get nano editor. You can use another text editor. Add this script on ~/.bash_profile.

source dnvm.sh

mc4

If done, save this file. After that, close your Terminal and then open again so Terminal will load profile script.

The next step is to upgrade. Type this command.

$ dnvm upgrade

mc5

Now you already installed dnvm. It will be used to manage ASP.NET 5 runtime on OS X. You can verify dnvm by typing this command.

$ dnvm help

So you see a list of dnvm parameter.

mc6

You can also see a list of your DNX runtime by typing this command.

$ dnvm list

mc7

2.3 Testing

To test our ASP.NET 5, we use code samples from https://github.com/aspnet/Home . We clone this code samples and then restore all required libraries using dnu command.

Type these commands.

$ git clone https://github.com/aspnet/Home

$ cd Home

$ dnu restore

If you don't git on your OS X, you can install it via brew.

$ brew install git

mc9

Now you are ready to run code samples.

2.3.1 ASP.NET Console

To run ASP.NET Console, we can use dnx. Firstly, navigate to ConsoleApp project.

Type these commands.

$ cd samples/latest/ConsoleApp/

$ dnx . run .

If success, you can see a message "Hello World" on Terminal.

mc10

2.3.2 ASP.NET 5

To run ASP.NET 5 app, we can use dnx with kestrel. Firstly, navigate to HelloWeb project.

Type these commands.

$ cd samples/latest/HelloWeb/

$ dnx . kestrel

Now open a browser and then navigate to http://localhost:5004/ . You should see ASP.NET 5 app.

mc11

To stop kestrel, you can type exit.

exit

mc13

2.3.3 ASP.NET MVC

To run ASP.NET MVC, we can use dnx. Firstly, navigate to HelloMvc project.

Type these commands.

$ cd samples/latest/HelloMvc/

$ dnx . kestrel

Now open a browser and then navigate to http://localhost:5004/ . You should see ASP.NET MVC app.

mc12

To stop kestrel, you can type exit.

mc13

2.4 Development Tools

The next step is to build program. To write a program, you can use any text editor. Microsoft also provides Visual Studio Code. It runs on Windows, Linux and Mac. You can download it on https://code.visualstudio.com/ .

p2-1