Skip to content

Commit b656a99

Browse files
committed
Explicitly add a binding redirect for WindowsAzure.Storage in our install script
* Latest NuGet on VS2013 doesn't seem to add this
1 parent 3f3ce27 commit b656a99

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

AzureWebFarm.OctopusDeploy/Tools/install.ps1

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,36 @@ $startupFolder.ProjectItems |
6363
# Add App.config file with binding redirects
6464
$appConfigProjectItem = $project.ProjectItems | Where-Object { $_.Name -eq "App.config" } | Select-Object -First 1
6565
if ($appConfigProjectItem -eq $null) {
66-
Write-Host "Adding binding redirects to update Web.config"
67-
Add-BindingRedirect
68-
69-
Write-Host "Creating an App.config file for use by the RoleEntryPoint with the binding redirects in Web.config"
66+
Write-Host "Opening Web.config to update binding redirects"
7067
$webConfigProjectItem = $project.ProjectItems | Where-Object { $_.Name -eq "Web.config" } | Select-Object -First 1
7168
$webConfigPath = ($webConfigProjectItem.Properties | Where-Object { $_.Name -eq "LocalPath" } | Select-Object -First 1).Value
7269
$webConfig = [xml] (Get-Content $webConfigPath)
7370
$runtimeNode = $webConfig.configuration.runtime
71+
72+
Write-Host "Adding an explicit binding redirect for WindowsAzure.Storage"
73+
$packagesConfigProjectItem = $project.ProjectItems | Where-Object { $_.Name -eq "packages.config" } | Select-Object -First 1
74+
$packagesConfigPath = ($packagesConfigProjectItem.Properties | Where-Object { $_.Name -eq "LocalPath" } | Select-Object -First 1).Value
75+
$packagesConfig = [xml] (Get-Content $packagesConfigPath)
76+
$azureStorageConfig = $packagesConfig.SelectNodes('/packages/package[@id="WindowsAzure.Storage"]') | Select-Object -First 1
77+
$azureStorageVersion = $azureStorageConfig.version
78+
$bindingRedirectXml = [xml]('<dependentAssembly>' +
79+
'<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />' +
80+
'<bindingRedirect oldVersion="0.0.0.0-' + $azureStorageVersion + '" newVersion="' + $azureStorageVersion + '" />' +
81+
'</dependentAssembly>');
82+
$bindingRedirect = $bindingRedirectXml.SelectNodes('/dependentAssembly') | Select-Object -First 1
83+
$bindingRedirectNode = $webConfig.ImportNode($bindingRedirect, $true)
84+
$runtimeNode.assemblyBinding.AppendChild($bindingRedirectNode)
85+
$webConfig = [xml] ($webconfig.OuterXml.Replace(' xmlns=""', ''))
86+
$webConfig.Save($webConfigPath)
87+
88+
Write-Host "Adding binding redirects to update Web.config"
89+
Add-BindingRedirect
90+
91+
Write-Host "Creating an App.config file for use by the RoleEntryPoint with the binding redirects in Web.config"
7492
$appConfig = [xml]"<?xml version=`"1.0`"?><configuration />"
7593
$newRuntimeNode = $appConfig.ImportNode($runtimeNode, $true)
7694
$appConfig.DocumentElement.AppendChild($newRuntimeNode)
7795
$appConfigPath = Join-Path $projectPath "App.config"
7896
$appConfig.Save($appConfigPath)
7997
$project.ProjectItems.AddFromFile($appConfigPath)
80-
}
98+
}

0 commit comments

Comments
 (0)