I have a WebApp that I am trying to deploy to Azure. My stack is:
TeamCity 9.1.6 Octopus 4.0.7
I had been having a problem targeting the Staging slot which I can now do. However the Nuget Package I get from TeamCity contains two extra directories above app_data which is the top level I need to deploy. To get over the Staging deployment problem I have used a different template (Deploy an Azure Web App) than the one that was being used (DeployAzureWebApp). The first one had pre/deploy/post scripts in place in which I think pre was pulling out the app-data directory and ignoring the rest.
I need to replicate this but the template I am now using does not appear to allow scripts. I have read a little about OctoPack and wonder if there is a step I can include that will reformat the package for me or if I should go back to team city and get it to create the package as required.
To fix this issue all I needed to do was to enable scripts from the "Configure Features" button. Then I was able to have a pre-deploy script alter the extraced package contents before they were deployed.
#path variables
$projectName = $OctopusParameters['Octopus.Action.Package.PackageId']
$version = $OctopusParameters['Octopus.Action.Package.PackageVersion']
$location = Get-Location
#Write-Host "Project Name: ${projectName}"
#Write-Host "Get-Location: ${location}"
#Write-Host "Project Version: ${version}"
$appData = (Get-ChildItem -Path ${location}\${projectName}.${version} -Filter "*app_data*" -Recurse -Directory).Fullname
$source = "${location}\${projectName}.${version}\GeneratedWebPackages\*"
$destination = "${location}\${projectName}.${version}"
#Write-Host "Source: ${source}"
#Write-Host "Destination: ${destination}"
#Write-Host "App Data Path: ${appData}"
# Move the app-data directory and all sub directories
Move-Item -Path "${appData}" -Destination "${location}" -Force
#remove the original
Remove-Item -Recurse -Force -Path "${destination}"
While this works I feel the correct fix would have been to have TeamCity create the package as required in the first place.