How To Publish And Deploy NET Core Website On IIS

Hello Readers, in this post I am going to discuss the publishing and deployment process of a .NET Core 1.0 website on IIS.

Getting the required files for hosting on IIS

  1. First thing we need to make sure that we are including all required folders in our publish. If you have your application using the blank .NET Core template then go to project.json. You will see settings for publish options like below
    1. "publishOptions": {  
    2.     "include": [  
    3.       "wwwroot",  
    4.       "web.config"  
    5.     ]  
    6.   }  

    Replace the above publish options with the following

    1. "publishOptions": {  
    2.     "include": [  
    3.       "wwwroot",  
    4.       "Views",  
    5.       "Areas/**/Views",  
    6.       "appsettings.json",  
    7.       "web.config"  
    8.     ]  
    9.   }  

    Please note that you need to include the your .json files with correct name. So our necessary folders are now included for publishing.

  2. Now the next step is to publish the website. Please follow the screenshots along with instructions
    Select Publish on .NET Core App
    Select Publish
    1. Go to your application under src folder.
    2. Right click and select Publish option.
  3. Now the publish box opens up.

    Publish Box
    1. Select the custom option.
    2. Add profile name as localhost(you can give anything you like)

      Add profile

    3. After profile is added you will be given screen for selecting Publishing Method and location where published files should be placed.

      Publish Method and Location
    4. Click next and you will get to settings screen of publish window

      Publish Settings Screen
      1. Make sure you select the configuration as Release
      2. Make sure to check the checkbox for Delete all existing files prior to publish(This will make sure that files in publish folder will just be for our application)

    5. Now click on Publish. VS will publish the required files in the selected folder and you will see the following message on output window of Visual Studio

      Open IIS Manager

      Output Window

Now as our files are published let’s do setting for IIS.

If you haven’t configured IIS on your machine yet. Please follow the steps Configure IIS.

  1. Install the Windows Server Hosting bundle on the server. The bundle will install the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module. The module creates the reverse-proxy between IIS and the Kestrel server.
  2. Execute iisreset at the command line(start as administrator) or restart the server to pickup changes to the system PATH.
  3. Open IIS Manager

    Open IIS Manager
    IIS Manager

    1. Copy the published files to the following location
               
      1. C:\inetpub\wwwroot

      Create a new folder and copy all the files from the published location to this folder.

    2. When you click on Add Website, do the following settings

      Add Website Settings
      1. Give your website a name
      2. Give physical path to the files where you have copied.
      3. Change the port 80 to another port that is not in use.
      4. Click OK

    3. Now let’s run the application. Select the website added and on the right side you will see to browse the website. Click on browse and website will be launched in your default browser.

      Browse Application

Our website is ready :-)

.NET Core Website on IIS

Thanks for reading.

Do let me know if you face any issue in the process.

Ebook Download
View all
Learn
View all