In this article, I use the default Website template of ASP.NET 5 for the demo.
I used Publish feature in VS2015 RC but it didn’t work as I expected, although I also created 2 sub-folders (approot & wwwroot).
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).
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.
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]
Wait some seconds to complete the process.
Open the folder to see what files were generated after the process. We have 2 folders (approot & wwwroot), and 3 command execute files.
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.
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 😀
“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.
Browse this website and see what happens.
* error. I hate seeing error screen like this :D. Don’t worry, I will show you another ‘magic’ to ‘kill’ this error.
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.
You will ask me how I know exactly the name of the dnx.. The answer is simple, just type as I showed you, haha :D. Just kidding :P. 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?
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.
Again, copy approot folder & wwwroot folder to the folder you created in inetpub. Restart the website, and browse it again.
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.
3. Refresh the website again, and bump, the ‘magic’ happens 😀
Now you have your ASP.NET 5 app up and running on IIS :D.
This solution is easier :D. 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.
Click OK, restart Application Pool, and Website to see ‘the magic’ :D. Happy coding!