Between versions 2.5.4.280 and 2.5.6.356 of the tentacle, you all changed setting the authentication method to use appcmd.exe. While it is wrapped in the Execute-WithRetry code, it doesn’t actually check the exit code to determine if it needs to be retried. (the failure does not throw an exception.)
Our error when the configuration is locked in this case is:
Calling code:
Execute-WithRetry {
Write-Host “Windows authentication enabled: $enableWindows”
& $appCmdPath set config “$WebSiteName” -section:“system.webServer/security/authentication/windowsAuthentication” /enabled:"$enableAnonymous" /commit:apphost
}
Results in Error:
Windows authentication enabled: True
Applied configuration changes to section “system.webServer/security/authentication/windowsAuthentication” for “MACHINE/WEBROOT/APPHOST/XXXXXXX” at configuration commit path "MACHINE/WEBROOT/APPHOST"
ERROR ( hresult:80070020, message:Failed to commit configuration changes.
The process cannot access the file because it is being used by another process. )
IIS configuration complete
Fatal 13:55:35 PowerShell script returned a non-zero exit code: 32
Tentacle version 2.5.8.447
here is the link to the previous error that instigated the retry code: http://help.octopusdeploy.com/discussions/problems/15952-error-cannot-write-configuration-file-while-setting-bindings
I would say that the code should be something like:
Execute-WithRetry {
Write-Host “Windows authentication enabled: $enableWindows”
& $appCmdPath set config “$WebSiteName” -section:“system.webServer/security/authentication/windowsAuthentication” /enabled:"$enableAnonymous" /commit:apphost
if ($LastExitCode -ne 0) {
throw “Failed Setting Windows Authentication with exit code $LastExitCode”
}
}
Thanks!