Re-configure multpiple AppPools in one deploy?

I am learning Octopus. Right now I’m working on a project which has one NuGet package for the website. It’s a fairly large customer with many brands. Each brand runs in a separate AppPool and uses it’s own bindings, from the same app directory.

Whenever the main NuGet package is deployed we setup the “staging.customer.com” site. And thenn we need to change a number of WebSites to point to the new directory where the app resides. Here’s an example:

Name Physical Path Bindings
brandxx.staging.customer.com d:\Websites\www.customer.com\website http*:80:brandxx.staging.customer.com
brandx.staging.customer.com d:\Websites\www.customer.com\we http*:80:brandx.staging.customer.com
staging.customer.com D:\Octopus\Applications\Stage\Customer.Interfaces.Web\1.0.121 http*:80:staging.customer.com

What is the recommended way to re-base a number of WebSites to the newly deployed app? In this case the last site is the one deployed using Octopus and we need to change the remaining WebSites to use the new directory.

I understand I could solve this by using a custom install directory. But I really like the convenience of having separate directories per deploy. So I’d rather get this working by deploying to a new path and then update all WebSites.

I’d appreciate any hints on how to best do this!

Cheers,
Joakim

I’m answering myself :slight_smile: I’m not convinced this is the ultimate way to do it but it works. Add a "Run a PowerShell script step and run this code:

$path = $OctopusParameters['Octopus.Action[<nameofpackage>].Output.Package.InstallationDirectoryPath']

Import-Module WebAdministration 

# Get all sites except the "sitenametonotupdate" one

$websites = Get-Website | ? { $_.Name -notlike '*sitenametonotupdate*' }

# Set the new path for all sites

foreach ($site in $websites) {
   
   Set-ItemProperty IIS:\Sites\$($site.Name) -name PhysicalPath -value $path
}