Skip to content

Instantly share code, notes, and snippets.

@sochix
Created October 3, 2015 03:45
Show Gist options
  • Save sochix/6de4b8690d6139441597 to your computer and use it in GitHub Desktop.
Save sochix/6de4b8690d6139441597 to your computer and use it in GitHub Desktop.
<#
#
# Publish Project with msdeploy
# -----------------------------
#
# Parameters:
# * publishProfilePath - path to pubxml profile, downloaded from Azure
# * profileName - profile name from VS deploy dialog
# * projectName
#>
param(
[string]$publishProfilePath,
[string]$profileName,
[string]$projectName)
function Get-MSBuildCmd
{
process
{
$path = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\" |
Sort-Object {[double]$_.PSChildName} -Descending |
Select-Object -First 1 |
Get-ItemProperty -Name MSBuildToolsPath |
Select -ExpandProperty MSBuildToolsPath
$path = (Join-Path -Path $path -ChildPath 'msbuild.exe')
return Get-Item $path
}
}
[xml]$profile = Get-Content $publishProfilePath
$publishProfile = $profile.publishData.publishProfile | Where { $_.profileName -eq $profileName }
$solutionDir = (get-item $PSScriptRoot).parent.FullName #the script should be placed in dir where RateItNow.sln located
$password = $publishProfile.userPWD #password from the publish profile
$pathToMsBuild = (Get-MSBuildCmd) #path to MsBuild
$projectPath = $solutionDir + "\" + $projectName + "\" + $projectName + ".csproj"
& $pathToMsBuild $projectPath `
/p:DeployOnBuild=true `
/p:PublishProfile="$profileName" `
/p:SolutionDir="$solutionDir" `
/p:Password=$password `
/p:IncludeSetAclProviderOnDestination=False #need to publish correctly to Azure, because Azure FS don't recognize ACL rulesD1ra2pdbo6j1cjvrx93MlyMirFax3QjhmeqvoeKstbfDMCC6H7iesA37iyKo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment