Deploying to IIS 7.5 gives configuration section 'uri' error but deploying to iis 8 does not

Hello,
I’ve got three tentacles, two to Windows Server 2008 R2 IIS 7.5 servers, and the third to a Server 2012 IIS 8 box. The configuration transform works perfectly to the IIS8 box, but not to either IIS7.5 box. This is the same asp.net website at both places, both targeting the .net framework 4. I get the following error:

Filename: \\?\C:\Octopus\Applications\Production\SSUApp\1.0.4023\web.config
Error    05:21:37
Line number: 408
Error    05:21:37
Error: The configuration section 'uri' cannot be read because it is missing a s
Error    05:21:37
ection declaration
Error    05:21:37
At C:\Octopus\Applications\.SQ-262721-WEB2-1FE04E9C\Octopus.Tentacle\2.4.10.235
Error    05:21:37
\Scripts\Octopus.Features.IISWebSite_BeforePostDeploy.ps1:215 char:7
Error    05:21:37
+     throw <<<< 
Error    05:21:37
    + CategoryInfo          : OperationStopped: (:) [], COMException
Error    05:21:37
    + FullyQualifiedErrorId : Filename: \\?\C:\Octopus\Applications\Production 
Error    05:21:37
   \SSUApp\1.0.4023\web.config
Error    05:21:37
Line number: 408
Error    05:21:37
    Error: The configuration section 'uri' cannot be read because it is missin 
Error    05:21:37
   g a section declaration
Fatal    05:21:37
PowerShell script returned a non-zero exit code: 1

It appears that in the end a correctly formatted web.config file is left on my server, but because of the error my follow up steps don’t run, so my deploy is only half complete. Any ideas would rock.

Thanks,
Francis

Hi Francis,

Thanks for getting in touch!
We were able to find the following on the Google if you could give their solution a try on your 7.5 servers:

Let me know how that goes!
Vanessa

Sadly, I’ve already tried that, apparently .net 4’s machine.config has that line already included in it, so it causes a 500.19 error as documented here - http://stackoverflow.com/questions/4208313/dotnetopenauth-template-doesnt-work-when-published/ if I put that in.

I do wish it was that easy though.

Is there some way to verify what version of .net the tentacle is running the xml transforms is using? I’m assuming that if it’s running against some framework prior to 4, maybe that’s why it errors, but since the app runs as 4 all is good. I don’t really know, I’m starting to grasp at straws.

Thanks so much though,
Francis

Hi Francis,

Grasping at a few over here too. So under Tasks -> Script console this runs PowerShell on your tentacles just as it would run through Octopus Steps.
So you could simply run $psversiontable in there on each machine and compare the outputs.
I don’t know where it will get us, but we are definitely moving forward?

Vanessa

Yup. That was it, I’m assuming. On the win2008 r2 boxes the CLR Version returned as 2, but on the win2012 box, it was 4. I asked google how to set powershell to use version 4, it responded with http://stackoverflow.com/questions/2094694/how-can-i-run-powershell-with-the-net-4-runtime, and now it answers as version 4.

I haven’t had a chance to deploy yet, but I’m completely assuming it’s going to work now.

Thank you so much, and for the record, Octopus is such a fantastic product, I wish I’d found it years ago.

Thanks again,
Francis

I have same problem.

When deploying a error happends on the post script saying URI section is missing, this is defined in the machine.config. I have looked at the powershell clr version and it is now, as you guys talked about, version 4 so it can use the machine.config.
Im still having the same problem. This is the version output from the tentacle:

Name Value
Info 14:29:39


Info 14:29:39
PSVersion 3.0
Info 14:29:39
WSManStackVersion 3.0
Info 14:29:39
SerializationVersion 1.1.0.1
Info 14:29:39
CLRVersion 4.0.30319.18444
Info 14:29:39
BuildVersion 6.2.9200.16398
Info 14:29:39
PSCompatibleVersions {1.0, 2.0, 3.0}
Info 14:29:39
PSRemotingProtocolVersion 2.2
Info 14:29:39

PowerShell exit code: 0

and the URI section error when deploying it:
Set-WebConfigurationProperty : Filename: \?\D:\Octopus\Applications\Test\Deplo
Error 14:24:26
y.Politiken.Bruger.Admin.Website\0.0.0.60_3\web.config
Error 14:24:26
Line number: 219
Error 14:24:26
Error: The configuration section ‘uri’ cannot be read because it is missing a s
Error 14:24:26
ection declaration
Error 14:24:26
At C:\Program Files\Octopus Deploy\Tentacle\Scripts\Octopus.Features.IISWebSite
Error 14:24:26
_BeforePostDeploy.ps1:201 char:3
Error 14:24:26

  •     Set-WebConfigurationProperty -filter /system.webServer/security/authe
    

Error 14:24:26
ntication …
Error 14:24:26

Error 14:24:26

Error    14:24:26
    + CategoryInfo          : NotSpecified: (:) [Set-WebConfigurationProperty] 
Error    14:24:26
   , COMException
Error    14:24:26
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Micr 
Error    14:24:26
   osoft.IIs.PowerShell.Provider.SetConfigurationPropertyCommand
Fatal    14:24:26
PowerShell script returned a non-zero exit code: 1
Tentacle version 2.5.4.280


Hope you guys have more things we can tryout, so we can fix this problem.

I eventually fixed this in a few ways.

  1. I made sure that the win server 2008 r2 had powershell 3 installed, because that’s built against .net 4.

  2. I added to the C:\windows\microsoft.net\framework64\v2\configs machine config on the server.

After those two things (and a reinstall of the tentacle so it would use the right powershell) it’s been working with issue.

Thanks,
Francis

When I say I added in step 2, I mean I added:
<section name="uri" type="System.Configuration.UriSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> to the machine.config file

the machine.config already has URI in it but as version 4, maybe its the problem. I upgraded powershell and restartet the tentacle but a reinstall will maybe work. Ill try it.

Ah version 2 should also contain it. Perfekt now its solved, thanks!

yeah, that was the only way I could figure out to solve it. I don’t love it, but I can now ignore it and move on to cooler things, knowing that it’s probably not something i’ll have to worry about on new server builds, because they’ll all be 2012 or newer.