locked
automatically deploy app_offline RRS feed

  • Question

  • User-1237676006 posted

    Hi,

    I'm using Web Deployment Projects 2008 to deploy directly to servers, and I would like to automatically add a custom app_offline.htm to the root of the target directory, and delete it at the end of the (succesful) deploy.

    So I added something like this:

    <Target Name="BeforeBuild"><Copy SourceFiles="@(OfflineFile)" DestinationFolder="$(OutputPath)" /></Target>

    <Target Name="AfterBuild"><Delete Files="$(OutputPath)app_offline.htm" /></Target>

    Now the problem is that I don't know how to trigger something as soon as everything is complete, bevcause the AfterBuild event fires way to early, before all files are deployed to the server.

    Can anyone help me out there?

     Thanks!

     Wiebe 

    Friday, November 7, 2008 8:58 AM

Answers

  • User-1237676006 posted

    Hi Charles,

     I managed to get it running (more or less) with something like this:

    <ItemGroup><OfflineFile Include="$(SourceWebPhysicalPath)\UI\app_offline.htm" /></ItemGroup>

     

    <Target Name="BeforeBuild">
     <
    Message Text="Taking application offline BeforeBuild..." />
    <Copy ContinueOnError="false" SourceFiles="@(OfflineFile)" DestinationFolder="$(SourceWebPhysicalPath)" />
    <
    Copy ContinueOnError="false" SourceFiles="@(OfflineFile)" DestinationFolder="$(OutputPath)" />
    </
    Target>

    <Target Name="AfterBuild">
    <
    Message Text="Bringing application back online AfterBuild..." />
    <
    Delete ContinueOnError="false" Files="$(OutputPath)app_offline.htm" />
    <
    Delete ContinueOnError="false" Files="$(SourceWebPhysicalPath)\app_offline.htm" />
    </
    Target>

    The problem was that the CopyToOutputDir task deletes the entire folder first, and I don't know how to create a new target that copies the app_offline.htm file first before deploying other files, but it now the CopyToOutputDir copies app_offline.htm pretty early in the deployment process, meaning the application will stay of line most of the time (before the directory is deleted and after the file is copied).

    Thanks for your help!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 7, 2008 11:43 AM

All replies

  • User-1190926628 posted

    I believe there's an event that fires after AfterBuild called Destroy.

    Friday, November 7, 2008 9:22 AM
  • User-1237676006 posted

     Hi Charles,

     Thank you for the answer. Unfortunately the event also seems to fire before the copying of the files takes place, because as soon as the build is finished the app_offline.htm file is gone.

     Or maybe (what I think of now) is that the deploy clears the entire target folder including the app_offline.htm file, so I'm copying it to early?

    Thanks...

    Wiebe

    p.s. sorry for double posting, I didn't see my previous post appear so I thought I'd lost it. Didn't read the bit about moderation.

    Friday, November 7, 2008 11:03 AM
  • User-1190926628 posted

    This may be a bit old school, but maybe you can have two BAT files; one calls the installer and the second BAT file when its done, and the second BAT does the cleanup.

    Friday, November 7, 2008 11:24 AM
  • User-1237676006 posted

    Hi Charles,

     I managed to get it running (more or less) with something like this:

    <ItemGroup><OfflineFile Include="$(SourceWebPhysicalPath)\UI\app_offline.htm" /></ItemGroup>

     

    <Target Name="BeforeBuild">
     <
    Message Text="Taking application offline BeforeBuild..." />
    <Copy ContinueOnError="false" SourceFiles="@(OfflineFile)" DestinationFolder="$(SourceWebPhysicalPath)" />
    <
    Copy ContinueOnError="false" SourceFiles="@(OfflineFile)" DestinationFolder="$(OutputPath)" />
    </
    Target>

    <Target Name="AfterBuild">
    <
    Message Text="Bringing application back online AfterBuild..." />
    <
    Delete ContinueOnError="false" Files="$(OutputPath)app_offline.htm" />
    <
    Delete ContinueOnError="false" Files="$(SourceWebPhysicalPath)\app_offline.htm" />
    </
    Target>

    The problem was that the CopyToOutputDir task deletes the entire folder first, and I don't know how to create a new target that copies the app_offline.htm file first before deploying other files, but it now the CopyToOutputDir copies app_offline.htm pretty early in the deployment process, meaning the application will stay of line most of the time (before the directory is deleted and after the file is copied).

    Thanks for your help!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 7, 2008 11:43 AM
  • User2113362401 posted

    I really need you to go back one or two steps. I want to understand more about how you are doing this as I'd love to take advantage of the app_offline file. Right now, I do the old school batch file process where I create an app_offline file, but it looks like you are able to have a custom file in your project (\UI\app_offline.htm) and then the publish routine uses it. Can you explain a little bit more about the <ItemGroup><OfflineFile Include="$(SourceWebPhysicalPath)\UI\app_offline.htm" /></ItemGroup> section? Where is this?

    This is the only place on the Internet I'm finding a discussion on custom app_offline. Google searches bring me back to this thread.

    Monday, December 1, 2008 1:17 PM
  • User-1190926628 posted

    This is the only place on the Internet I'm finding a discussion on custom app_offline. Google searches bring me back to this thread.

    That's because this is the home of cutting edge development :)  It seems that app_offline isn't function as it was designed and this may be worthy of a bug report to the Microsoft developers.

     

    Wednesday, December 10, 2008 1:40 PM