How to ensure that IIS application remains "off" during deployment and during execution of deploy.ps1

rgelb's Avatar

rgelb

23 Jul, 2025 10:08 PM

My understanding is that the application (or rather the AppPool) is off while deployment takes place. However, it's not off during execution of deploy.ps1. This is a problem for me because I am setting database connection info to appsettings.json file during execution of deploy.ps1. I set the connection info from the Environment variables.

So in the space of time when deploy.ps1 is executing, I have a ton of errors in the event viewer, because database connection info hasn't been set yet.

My code for reference (and a screenshot of environment variables from the deployment settings in attached as well):

Set-Location $env:application_path
$as = 'appsettings.json'
$a = Get-Content $as | ConvertFrom-Json
$a.Service.ServiceStart = $env:ServiceStart
$a.Service.ServiceEnd = $env:ServiceEnd
$a.Service.ServiceMode = $env:ServiceMode 
$a | ConvertTo-Json | set-content $as

So how do I keep the application from running until after deploy.ps1 has executed?

P.S. The app_offline setting is true

  1. Support Staff 1 Posted by Feodor Fitsner on 24 Jul, 2025 04:54 PM

    Feodor Fitsner's Avatar

    app_offline is applied to a WebDeploy provider. I suspect it could behave differently for "regular" .NET Framework websites and .NET Core websites. Anyway, you can provide before_deploy.ps1 and explicitly stop application pool.

  2. 2 Posted by rgelb on 24 Jul, 2025 05:57 PM

    rgelb's Avatar

    @Feodor, is there such a thing as after-deploy.ps1? Gemini seems to hallucinate and say that there is. But I don't see it in your documentation.

  3. Support Staff 3 Posted by Feodor Fitsner on 24 Jul, 2025 08:53 PM

    Feodor Fitsner's Avatar

    Correct, it's before-deploy.ps1 (with dash): https://www.appveyor.com/docs/deployment/agent/#running-powershell-...

    APPLICATION_PATH is probably what you need.

  4. 4 Posted by rgelb on 24 Jul, 2025 09:45 PM

    rgelb's Avatar

    Can you also please update documentation. https://www.appveyor.com/docs/deployment/agent/ is missing APPLICATION_APPPOOL_NAME.

    As far as APPLICATION_PATH, in my case it's C:\appveyor\projects\jw-web\applications\JudicateWest.Web.UI. However, nothing is ever created under C:\appveyor\projects during the deployment. So that is incorrect.

    And is there such a thing as after-deploy.ps1? Gemini seems to hallucinate and say that there is. But I don't see it in your documentation.

  5. Support Staff 5 Posted by Feodor Fitsner on 30 Jul, 2025 01:26 AM

    Feodor Fitsner's Avatar

    Could you please confirm what APPLICATION_PATH gives in your case?

    There is no after-deploy.ps1 - there is just deploy.ps1, but it's technically "after" deploy.

  6. 6 Posted by rgelb on 02 Aug, 2025 12:49 AM

    rgelb's Avatar

    @Feodor

    APPLICATION_PATH = C:\appveyor\projects\jw-web\applications\JudicateWest.Web.UI

    and there are also these:

    APPLICATION_APPLICATION_PATH = C:\inetpub\wwwroot\netCore7Apps\jwweb2.dev
    APPLICATION_APPPOOL_NAME = jwweb2.dev

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • 2025-07-23_15_03_27-PROD-JWW_-_AppVeyor_—_Mozilla_Firefox.png 4.35 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac