before-deploy.ps1 is never executed

Matt's Avatar

Matt

22 Jul, 2020 03:50 PM

Hi

I have a project targeting .Net Framework 4.6.1 in which I added two scripts and named them as described in your documentation:
https://www.appveyor.com/docs/deployment/agent/#running-powershell-scripts-on-target-server-during-deployment

On every build, deploy.ps1 is always called and works perfectly, but no matter what I try (including it to the csproj one way or another, or not at all), before-deploy.ps1 isn't.

The documentation simply states "PowerShell script in the root of application folder will be called before every deployment.", so I guess there's nothing special that needs to be done here, right?

Also, I'm running the latest AppVeyor Agent version on a fully updated Windows Server 2016.

I suppose you might need more information from me. Please feel free to ask.

  1. Support Staff 1 Posted by Feodor Fitsner on 22 Jul, 2020 04:03 PM

    Feodor Fitsner's Avatar

    Hi Matt,

    What kind of app is that? before-deploy.ps1 is supported only with "web" (deploy_website) and "windows" apps (deploy_app, deploy_service).

    What do you get in deployment log? For before-deploy.ps1 the agent is simply iterates over all zip package entries until before-deploy.ps1 is found. Unpack the package to see if it contains before-deploy.ps1.

  2. 2 Posted by Matt on 22 Jul, 2020 04:27 PM

    Matt's Avatar

    Hi Feodor, and thanks for the quick follow-up.

    This is indeed a website, with deploy_website is to true.

    You were right: the script wasn't in the deployed zip file. I just ran another build / deploy after setting "Copy - Always" to the script file from its Visual Studio properties, and it worked perfectly.

    Added to the .csproj file:

    <None Update="before-deploy.ps1">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    

    Thanks a lot for your help!

  3. Support Staff 3 Posted by Feodor Fitsner on 22 Jul, 2020 11:20 PM

    Feodor Fitsner's Avatar

    Great, thanks for the update!

  4. Feodor Fitsner closed this discussion on 22 Jul, 2020 11:20 PM.

Comments are currently closed for this discussion. You can start a new one.

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