App Pool issue when deploying .NET Core sites

Hello,
I’m currently deploying a .NET Core MVC site (with IIS) using Octopus but need 2 extra steps whenever I do so. I need to stop the app pool prior to the deploy (as i purge the folder) then start it again afterwards. I currently have 2 problems

  1. The step template for stopping an App Pool doesn’t check to see if the App Pool exists prior to stopping it, so I had to manually add this ( not ideal and should be in the actual step)
  2. Why do I need to stop/start the app pool at all? is it due to it being a .NET core web site? I don’t have these issues when deploying MVC3-4 web sites via the same means.

Any help would be appreciated!

Hi Tony,

Thanks for reaching out!

1. The step template for stopping an App Pool doesn’t check to see if the App Pool exists prior to stopping it, so I had to manually add this ( not ideal and should be in the actual step)

I checked the step template code and it does seem to check if the app pool exists. Look for if(Test-Path IIS:\AppPools\$appPoolName) in the latest version of the template: https://library.octopusdeploy.com/step-template/actiontemplate-iis-apppool-stop

Are you using the latest version of the step template?

2. Why do I need to stop/start the app pool at all? is it due to it being a .NET core web site? I don’t have these issues when deploying MVC3-4 web sites via the same means.

When you deploy an ASP.NET <4.6 app to IIS, even though you don’t explicitly make an AppPool Restart, IIS still makes one when it detects that the app content changed. Perhaps this isn’t the case with the net .NET Core apps and you have to explicitly stop/start? This is a new territory for all of us :slight_smile:

What kind of error do you get when you try to deploy without stop/start?

Thanks,
Dalmiro

Hi Dalmiro,

Thanks for getting back to me so quick!

Regarding Point 1, I’ll check and make sure we upgrade to the latest
template

Regarding Point 2 the error i get is a permission error. It seems to have
something to do with IIS not releasing the files prior to replacing them
(so it can’t purge the directory).

[15:22:40][Failed: H2DEMO8] Deploying package ‘C:\Octopus\UAT (Sprint
Demo)\Files\Ordermanager.CRM.5.11.1.921-DEV.zip-3206d187-0f93-43e6-b3d6-42d3633d6d02’
to machine ‘poll://r6k29y749qfcgnpg56f3/’
[15:22:40][Failed: H2DEMO8] Deploying package: C:\Octopus\UAT (Sprint
Demo)\Files\Ordermanager.CRM.5.11.1.921-DEV.zip-3206d187-0f93-43e6-b3d6-42d3633d6d02
[15:22:40][Failed: H2DEMO8] Performing variable substitution on
’C:\Octopus\Applications\UAT (Sprint Demo)\UAT (Sprint
Demo)\Ordermanager.CRM\5.11.1.921-DEV\appsettings.Production.json’
[15:22:40][Failed: H2DEMO8] Purging the directory ‘C:_Applications\CRM
crm-om-sprintdemo.h2ecommerce.com
[15:22:40][Failed: H2DEMO8] System.UnauthorizedAccessException: Access to
the path 'C:_Applications\CRM\crm-om-sprintdemo.h2ecommerce.com\Microsoft.AspNetCore.Antiforgery.dll’
is denied.

As you say, it probably has something to do with the difference between an
IIS website and a Kestrel one with an IIS fascia

I hope this helps

Kind regards

Tony

Hi Tony,

RE 2 - That’s most likely the case. I think you’ll be better off adding the Start/Stop just to make sure things work with IIS+ASP.NET core.

RE 1 - Let me know if downloading the latest works.

Thanks,
Dalmiro