DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Continuous Integration Tip #2 – Using App_offline.htm in Your Build

Continuous Integration Tip #2 – Using App_offline.htm in Your Build

Douglas Rathbone user avatar by
Douglas Rathbone
·
Jun. 08, 12 · Interview
Like (0)
Save
Tweet
Share
10.25K Views

Join the DZone community and get the full member experience.

Join For Free

deploying in an automated fashion using continuous integration doesn’t happen instantly, and depending on the size of your application, your continuous integration deployment can get caught in a state of unknown/in-between if a user visits your application half way through deployment. this can be far from optimal, but asp.net has a trick up it’s sleave in the form of the app_offline.htm file.

image this is the second post in a series on continuous integration tips & tricks in follow up to a post i made about setting up continuous integration automated deployment with web deployment projects & team city .

while there has been quite a bit of broadcast advertisement of the app_offline file over the years, whenever i bring it up with developers i usually get a blank stare in reply.

basically the gist of this is simple: if you place a file named app_offline.htm in the root of your application, all requests to asp.net pages or web services, is met by the contents of this file.

because of this really cool feature that asp.net has on offer, we can use it to our advantage in our automated build. what we need to do is copy a file into the root of our application before we copy the site.

the example build file

in all my examples, i've been using microsoft web deployment projects and teamcity . this solution uses msbuild for it’s automation, therefore i’m going to show you an example msbuild script that you can add to your web deployment project. you'll have to alter these for your build provider of choice if you use a different one (nant etc).

create an html file called deploymentinprogress.htm in the root of your application (it can be anywhere, as long as you update your build script to reflect the new path) and in it put some html that mentions that the app is being deployed. i suggest that if you use css include all the styles in the header instead of linking to it, and if you use any images in the page they are hosted on another domain/location (because you’ll be deploying your site and want to make sure the image file you calls exists and hasn’t been deleted by your deployment process).

add the following to bottom of your web deployment project file.

<target name="afterbuild">
    <propertygroup>
    <!-- this is where i want to copy my deployment to-->
        <deploymentdestination>c:\myiisroot\</deploymentdestination>
    </propertygroup>
    <itemgroup>
        <filestocopy include="$(outputpath)\**\*.*" />
    </itemgroup>

    <!-- copy the app offline file-->
    <copy sourcefiles="$(outputpath)deploymentinprogress.htm" 
                destinationfiles="$(deploymentdestination)app_offline.htm" />
    
    <!-- copy the deployment files-->
    <copy sourcefiles="@(filestocopy)" 
                destinationfiles="@(filestocopy->'$(deploymentdestination)%(recursivedir)%(filename)%(extension)')" />
    <!-- delete the app offline file-->
    <delete files="$(deploymentdestination)app_offline.htm" />
</target>

this will copy your file (in the process renaming it to app_offline.htm ), copy your project files, and then delete the app_offline.htm file so that your application can start.

this can  be further integrated with the ftp upload i mentioned in the previous post to give a remote deployment option.

Continuous Integration/Deployment Integration application

Published at DZone with permission of Douglas Rathbone, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Java Code Review Solution
  • When to Choose Redpanda Instead of Apache Kafka
  • 5 Software Developer Competencies: How To Recognize a Good Programmer
  • Java REST API Frameworks

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: