Publish ASP.NET 5 app and run on IIS 8.5 using cmd & VS2015 RC

In this article, I use the default Website template of ASP.NET 5 for the demo.

asp5_vs2015_publocal_error_4

 

I used Publish feature in VS2015 RC but it didn’t work as I expected, although I also created 2 sub-folders (approot & wwwroot).

asp5_vs2015_publocal_error_1

asp5_vs2015_publocal_error_3

So, I decided to try using cmd to make the deployment file.

Requirements: nodeJS, gulp installed on your machine.

First, open Command Prompt.

Choose dnx version you want to use for your ASP.NET 5 project by using this command.

To know which dnx versions are installed on your machine, you use this command dnvm list

In addition you don’t know what the * dnx is, you should read this article from ASP.NET wiki page on github (click here to learn about dnx).

asp5_publish_cmd_1

You can see, the default dnx using here is 1.0.0-beta4 (x86). To use other dnx, I will show you later in this post.

Next, navigate to the project folder you want to publish. Use this command to select default version of dnx to use for deploy the project.

asp5_publish_cmd_2

You can see the full path to the directory that stores the dnx. Now, we start to deploy the project by using this command: dnu publish –out [YOUR_DEPLOYED_FOLDER_PATH]

asp5_publish_cmd_3

Wait some seconds to complete the process.

asp5_publish_cmd_4

Open the folder to see what files were generated after the process. We have 2 folders (approot & wwwroot), and 3 command execute files.

asp5_publish_cmd_5

 

I will explain more about these files & folders in another post. In this post, I just want to show you the way to deploy, and run the ASP.NET 5 in IIS successfully. One thing I want to notice you here is, if you use the above command to deploy your project, you open the approot folder, you will see the source code of your project there. Holy *, do you want to publish your source code??? Huh.

asp5_publish_cmd_6

Don’t worry, I will show you the ‘magic’ command to make that folder never appear in the deployment package. Here it is: dnu publish –out [YOUR_DEPLOYED_FOLDER_PATH] –no-source

Let’s enter, and see the ‘magic’ now😀

asp5_publish_cmd_8

asp5_publish_cmd_9

“Hey, where is my source code, dude?”

“Ask Microsoft.” I said.😀

OK, let’s make it run on IIS now.

You create a folder in inetpub folder, and copy 2 folders (approot & wwwroot) in deployed folder to this folder. Open IIS, create a website, set a port for the website, and point the path to this folder.

asp5_publish_cmd_10

Browse this website and see what happens.

asp5_publish_cmd_11

* error. I hate seeing error screen like this😀. Don’t worry, I will show you another ‘magic’ to ‘kill’ this error.

Solution 1:

Let’s take back to the beginning, you knew that I use the default dnx (1.0.0-beta4 x86) for this deployment. But my machine is running on x64 architect. So, let’s delete the deployment folder, and do it again using another dnx version.

asp5_publish_cmd_13

You will ask me how I know exactly the name of the dnx.. The answer is simple, just type as I showed you, haha😀. Just kidding😛. When you installed VS 2015, it installed the dnx to your machine. You just locate to that folder, and you can see the list of dnxs. Copy the name, and paste to the command, done, easy?

asp5_publish_cmd_12

Let’s enter to make the deployment. Open the approot/packages folder, you will see the exactly dnx version you chose for your deployment was also deployed.

asp5_publish_cmd_14

Again, copy approot folder & wwwroot folder to the folder you created in inetpub. Restart the website, and browse it again.

asp5_publish_cmd_11

The 403.14 error screen appears again. What’s happened? Did I do something wrong, or did I miss something?…

Nothing’s wrong here. IIS will look for the default file (default.html, index.html…), or default config file (web.config) to execute. In this case, there’s nothing except 2 folders. I will do a trick here to make it works.

1. Copy all the files & folders inside wwwroot folder to the main folder.

2. Open web.config file to adjust the location of approot folder, and save it.

asp5_publish_cmd_15

3. Refresh the website again, and bump, the ‘magic’ happens😀

asp5_publish_cmd_16

Now you have your ASP.NET 5 app up and running on IIS😀.

Solution 2:

This solution is easier😀. You do the same steps as above, except deploying again with x64 dnx version, keep using x86 dnx version. In Application Pools section in IIS, select your website’s application pool -> Advanced Settings -> select True for Enable 32-Bit Applications.

asp5_publish_cmd_17

Click OK, restart Application Pool, and Website to see ‘the magic’😀. Happy coding!

4 thoughts on “Publish ASP.NET 5 app and run on IIS 8.5 using cmd & VS2015 RC

  1. Pingback: 如何部屬 ASP.NET 5 網站到 IIS « Coding 之路,不由分說
  2. Pingback: Publish ASP.NET 5 | Osen Kusnadi Weblog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s