Skip to content

Instantly share code, notes, and snippets.

@baywet
Last active April 22, 2016 06:47
Show Gist options
  • Save baywet/f7ed425c48ccde4399c7 to your computer and use it in GitHub Desktop.
Save baywet/f7ed425c48ccde4399c7 to your computer and use it in GitHub Desktop.
Fix of PublishAspNet5Website given by microsoft to support slots
param($websiteName, $packOutput, $slot)
#fix for the script provided here https://msdn.microsoft.com/en-us/Library/vs/alm/Build/azure/deploy-aspnet5?f=255&MSPPError=-2147217396
$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';
'MSDeployServiceUrl'=$msdeployurl;
'DeployIisAppPath'=$website.Name;
'Username'=$userName;
'Password'=$pw}
$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
@baywet
Copy link
Author

baywet commented Feb 18, 2016

Also submitted a PR to what I believe is the source of the documentation https://github.com/chrisrpatterson/TeamBuildAspNet5Sample/pull/4

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