Octopus.Features.IISWebSite_BeforePostDeploy.ps1 acting like using V2 of .NET framework but I'm not

Getting Error: The configuration section ‘uri’ cannot be read because it is missing a section declaration - which usually means that you have v4 Asp.NET (and config) but you are using V2 to read the web configuration. I have everything I can think of set up to use V4 though. The application pool default in IIS is v4. The application pool step config in Octopus is v4. What am I missing?

I verified that v3.5 is installed on the server (a problem that others had run into with the same error) and made sure ASPV4 was registered using aspnet_regiis -cur. I tried adding the URI config section declaration to the web.config and that (of course) got past the error, but then the site itself fails complaining of invalid configuration with two URI sections declarations. I took a look at the machine.config for v2 and v4 and they look ok (URI section declaration not in v2, but in v4 as expected).

Unfortunately, the URI section is required by OAuth, so I can’t just yank it.

Here’s the stack:
Set-WebConfigurationProperty : Filename: \?\C:\Octopus\Applications\Acceptance\PrimarySite\0.9.140420.7_1\lib\PrimarySite\web.config
Line number: 450
Error: The configuration section ‘uri’ cannot be read because it is missing a section declaration
At C:\Octopus\Applications.Tentacle\Octopus.Tentacle\2.3.6.1385\Scripts\Octopus.Features.IISWebSite_BeforePostDeploy.ps1:132 char:29

  • Set-WebConfigurationProperty <<<< -filter /system.webServer/security/authentication/anonymousAuthentication -name enabled -value “$enableAnonymous” -location $WebSiteName -PSPath “IIS:”
    • CategoryInfo : NotSpecified: (:slight_smile: [Set-WebConfigurationProperty]
      , COMException
    • FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.IIs.PowerShell.Provider.SetConfigurationPropertyCommand
      Fatal 20:25:26
      PowerShell script returned a non-zero exit code: 1

I’ve attached (a censored version) of our web.config in case that helps (it includes the URI section declaration at the top, but this section declaration is not present when the failure in the powershell occurs).

Web.config (17 KB)

Hi Dave - thanks for getting in touch. As you would have found so far, IIS is incredibly unhelpful in providing diagnostics for this error, which is almost always caused by some kind of missing or corrupted configuration on the target machine. We’ve had reports of it appearing on one of two identically-configured machines, and it’s rare the same resolution seems to apply to every occurrence. Pretty exasperating!

There’s a thread here where various items to check and possible causes are discussed, can you please check it out and let me know if any of the referenced items fix it for you? https://github.com/OctopusDeploy/Issues/issues/492

Knowing the IIS version you’re deploying to might help narrow it down.

Regards,
Nick

Ended up going to Azure and building a new Web server so no longer relevant. I’m closing the discussion.