Created
August 15, 2014 05:34
-
-
Save timvw/4e32226dd1ff149b5eab to your computer and use it in GitHub Desktop.
PreDeploy.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Load unzip support | |
| [Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null | |
| function Unzip($zipFile, $destination) | |
| { | |
| If (Test-Path $destination){ | |
| Remove-Item $destination -Recurse | Out-Null | |
| } | |
| New-Item -ItemType directory -Force -Path $destination | Out-Null | |
| [System.IO.Compression.ZipFile]::ExtractToDirectory($zipFile, $destination) | Out-Null | |
| } | |
| # Unzip deployment package | |
| $CsPkg = "Customer.Project.Api.Azure.cspkg" | |
| Unzip $CsPkg "azurePackage" | |
| Unzip (Get-Item (join-path -path "azurePackage" -childPath "*.cssx")) "website" | |
| # Perform replacements, eg: replace Web.Config | |
| $ConfigFileToUse = "Web." + $OctopusParameters["Octopus.Environment.Name"] + ".config" | |
| Copy-Item -Path $ConfigFileToUse -Destination "website/sitesroot/0/Web.Config" -Force | |
| # Repackage | |
| $role = "Customer.Project.Api" | |
| $contentPath = "website\approot" | |
| $rolePath = "website/approot" | |
| $webPath = "website/sitesroot/0" | |
| $cspackPath = "C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.2\bin\cspack.exe" | |
| & $cspackPath "ServiceDefinition.csdef" "/out:$CsPkg" "/role:$role;$rolePath;Customer.Project.Api.dll" "/sites:$role;Web;$webPath" "/sitePhysicalDirectories:$role;Web;$webPath" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment