-
-
Save dphoebus/6133786592b83b028ea1 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 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
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