Created
September 14, 2010 14:06
-
-
Save rarous/579086 to your computer and use it in GitHub Desktop.
Script for packaging and deployment of ASP.NET applications to IIS via Web Deploment Tools
This file contains 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
Properties { | |
$Build_dir = Split-Path $psake.build_script_file | |
$Packages_dir = Join-Path $build_dir 'Packages' | |
$MsDeploy_dir = Join-Path $env:ProgramFiles 'IIS\Microsoft Web Deploy' | |
$SiteName = 'www.example.com' | |
$Package = "$SiteName.zip" | |
$Dest = 'hosting.com' | |
$UserName = 'IIS User Name' | |
$Pwd = 'Secret Password' | |
} | |
Task Deploy { | |
Deploy-Package "$build_dir\Web\Web.csproj" Release $Package $Dest $SiteName $UserName $Pwd | |
} | |
function Deploy-Package { | |
param($Project, $Configuration, $PkgLocation, $DestServer, $SiteName, $UserName, $Password) | |
Write-Host Cleaning project files -ForegroundColor Cyan | |
Exec { MsBuild $Project /t:Clean /p:Configuration=$Configuration /v:q } | |
Write-Host "Staring building project $Project" -ForegroundColor Cyan | |
Exec { MsBuild $Project /t:Build /p:Configuration=$Configuration /v:q } | |
Write-Host "Starting packaging project $Project" -ForegroundColor Cyan | |
Exec { MsBuild $Project /t:Package /p:Configuration=$Configuration /p:PackageLocation=$PkgLocation /v:m } | |
Write-Host "Starting deployment site $SiteName to $DestServer" -ForegroundColor Cyan | |
$serverUrl = "https://${DestServer}:8172/msdeploy.axd?site=$SiteName" | |
$dest = "auto,computerName=$serverUrl,username=$UserName,password=$Password,authtype=basic" | |
Exec { & $MsDeploy_Dir\MsDeploy -verb:sync -source:package=$PkgLocation -dest:$dest -allowUntrusted } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unfortunately msdeploy doesn't handle spaces in path when invoked from powershell even though Exec command tries to quote them. I tried many thinkable solutions how to escape/quote paths with space, but I had to use this nasty solution to workaround the problem:
Exec { cmd.exe /C $("msdeploy.exe -verb:sync -source:contentPath=
"{0}
" -dest:package="{1}\{2}.zip
"" -f $destinationDir, $destinationBackupDir, $backupFileName ) }