Red Gate forums :: View topic - Powershell and deployment sequencing...
Return to RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
Deployment Manager
Deployment Manager forum

Powershell and deployment sequencing...

Search in Deployment Manager forum
Post new topic   Reply to topic
Jump to:  
Author Message

Joined: 27 Jun 2013
Posts: 12
Location: Boston

PostPosted: Thu Jun 27, 2013 10:35 pm    Post subject: Powershell and deployment sequencing... Reply with quote

The documentation says that the 4 preset powershell scripts will be run at deployment. It is not clear where those scripts are when they run. For example, my PreDeploy.ps1 script would like to use app_offline.htm on the target website to shut off access, and then copy the predeployment contents of the website to "\Backup Websites" directory.

Is the PreDeploy.ps1 script in some temp place on the target system when it gets run? Is it placed in the target physical location of the website before it is run? That would make it hard to copy the previous website contents because they'd be gone!

There are other similar tasks for predeployment. We need to backup the previous installation exe for third party software saved in a known directory on the target machine.
Back to top
View user's profile Send private message MSN Messenger
Mike Upton

Joined: 11 May 2011
Posts: 157
Location: Red Gate

PostPosted: Sat Jun 29, 2013 10:09 am    Post subject: Reply with quote

The deployment sequence is as follows:

  1. The contents of the package is extracted to a sub-directory of the path you chose during installation of the Agent. The base path defaults to "C:\ProgramData\Red Gate\DeploymentAgent\Applications", and the subdirectory used is <environment_name>\<package_name>\<package_version>\.
  2. PreDeploy.ps1 is executed in that directory.
  3. Any relevant XML config transforms are executed
  4. Variable substitutions are performed on .config files.
  5. If the RedGatePackageDirectoryPath variable is set, the extracted (and possibly modified by previous steps) contents in that directory are copied to the directory set in that variable. The working directory for all subsequent steps is changed to the new location. Note that if RedGatePackageDirectoryPath is not set, the initial directory in the Deployment Agent's data storage location continues to be used.
  6. Database deployment (if applicable) is carried out
  7. The Deploy.ps1 script(s) is executed
  8. If a web.config file is present in the directory, IIS is updated to serve the website from the new physical location.
  9. The package file itself (the .nupkg file) is deleted from the application location
  10. The PostDeploy.ps1 script(s) is executed

Hope that helps,
Mike Upton

Software Engineer
Red Gate Software Ltd.
Back to top
View user's profile Send private message

Joined: 27 Jun 2013
Posts: 12
Location: Boston

PostPosted: Wed Jul 03, 2013 3:57 pm    Post subject: Powershell function libraries? Reply with quote

We would love to be able to create a reusable set of powershell cmd-lets that all applications may use on an agent. Things like backup database, put app off line, turn off app pool, turn on app pool...

What is the way to go here? Do you setup a powershell library directory on each agent and update that first with a prerequisites deployment?
Back to top
View user's profile Send private message MSN Messenger

Joined: 04 May 2012
Posts: 50

PostPosted: Thu Jul 04, 2013 12:51 pm    Post subject: Reply with quote

We think the best way to solve this is to create a nuget package of your Powershell libraries.

You can then deploy this package as the first step in your deployments, so that each subsequent step will be able to use the extracted scripts.

By specifying RedGatePackageDirectoryPath to be the location you want to store the scripts, each deployment will override previous ones (since they will be in the same directory), and it will be easy to work out where the scripts have been extracted.

This has the advantage that Nuget will deal with versioning for you, and you don't need to worry about keeping each agent up to date, since it will be updated at deployment time.
David Conlin
Software Developer
Deployment Manager
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group