Do you have to publish .net core

lawrence whittemore asked on May 20, 2021 19:27

Do you have to publish .net core sites or can you just set something up and IIS to run the site where the files are?

Correct Answer

Juraj Ondrus answered on May 21, 2021 07:05

NOTE: The below steps are not the only right one and may not apply in all cases how to host .Net Core app in the IIS. It also depends how the project is configured and startup setup. The below steps work for the sample Dancing Goat Core project. If the below does not work for you, you need to find some other way how to deploy the project, e.g. looking on MSDN, Google or Stackoverflow.

You need to usually publish or deploy the Core app. There are several good articles on this topic on the Internet. Or, for local development, so I do not have to publish it every time, I do this:

  1. Open the Core project in Visual Studio. (I am using the sample DancingGoatCore project)
  2. Right-click on the DancingGoatCore project and select Properties.
  3. On the Debug tab, create a new Profile called IIS - sample screen shot
  4. Configure the following (screen shot):
    Profile: IIS
    Launch: IIS
    Launch browser: Checked (but leave the URL empty)
    Environment variables: Add a new one, Key = ASPNETCORE_ENVIRONMENT, Value = Development
    App URL: e.g. http://localhost/K13_DancingGoatCore
    Hosting Model: Default (In Process)

5.Save the properties.
6. Change the default run profile in Visual Studio to IIS (screen shot)
Now run the website from Visual Studio for the first time. When you first run the application, a new Application Pool and a new application under the Default Website will automatically be created in IIS (screen shot)
7. Configure the Presentation URL in administration interface (Sites application -> < edit site > -> General -> Presentation URL) to the app URL you specified in Step 4.

And now, I can just browse http://localhost/K13_DancingGoatCore without need to run Visual studio or publishing the app. Of course, when you make code changes in the Core app, you need to build it in VS.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Sylvain C. answered on September 8, 2021 12:53

Hello Juraj,

Thank you for your explanation, it works fine for the DancingGoatCore website

I tried to follow the same process for the MedioClinic website from the "Kentico Developer 13 for Developers" course. In VS, when I run the website with this new IIS run profile, I have an error in the XperienceLogger.cs file at the following line: var siteId = Service.ResolveOptional<ISiteService>().CurrentSite?.SiteID ?? default;

The error is: Resolution of 'CMS.Base.ISiteService' failed with the following error: IoC container cannot be used for service resolution because it was not initialized yet. This means that the application was not properly pre-initialized or yet initialized. Use 'CMS.Core.Service.InitializeContainer' to perform container initialization.

How can I solve this so I can run the MedioClinic website directly from IIS?

Thank you

0 votesVote for this answer Mark as a Correct answer

Aaron Macdonald answered on October 12, 2021 03:22 (last edited on October 12, 2021 03:22)

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.