Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Fix of PublishAspNet5Website given by microsoft to support slots
param($websiteName, $packOutput, $slot)
#fix for the script provided here
$website = $null;
$baseUrl = $websiteName;
if($slot -eq $null){
$website = Get-AzureWebsite -Name $websiteName
} else {
$baseUrl += "-" + $slot
$website = Get-AzureWebsite -Name $websiteName -Slot $slot
# get the scm url to use with MSDeploy. By default this will be the second in the array
$msdeployurl = $website.EnabledHostNames | ? {$_ -like "*" + $baseUrl + ".scm*" }
$passwordIndex = (([array]::IndexOf($website.EnabledHostNames, $msdeployurl)) + 1) / 2;
$siteProperties = $website.SiteProperties.Properties
$userName = if($website.PublishingUsername -eq $null) {($siteProperties | ?{ $_.Name -eq "PublishingUsername" }).Value | select -first 1 -Skip ($passwordIndex-1)} else {$website.PublishingUsername}
$pw = if($website.PublishingPassword -eq $null) { ($siteProperties | ?{ $_.Name -eq "PublishingPassword" }).Value | select -first 1 -Skip ($passwordIndex-1)} else {$website.PublishingPassword}
$publishProperties = @{'WebPublishMethod'='MSDeploy';
$publishScript = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\default-publish.ps1"
. $publishScript -publishProperties $publishProperties -packOutput $packOutput
Copy link

baywet commented Feb 18, 2016

Also submitted a PR to what I believe is the source of the documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment