Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install.xdt does not support <location> node in web.config #13

Open
owenmartin opened this issue Sep 17, 2013 · 6 comments
Open

install.xdt does not support <location> node in web.config #13

owenmartin opened this issue Sep 17, 2013 · 6 comments
Assignees
Labels

Comments

@owenmartin
Copy link

Trying to install nuget package causes an error to be thrown as our web.config contains the node around <system.webServer>

Example web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <modules>
        <add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" />
      </modules>
      <handlers>
        <add name="Glimpse" path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" preCondition="integratedMode" />
      </handlers>
</configuration>

Given that /configuration/system.webServer does not exist, the transformation fails.

@kevinobee
Copy link
Owner

Can you email me your web.config (use my gmail a/c)?

@ghost ghost assigned kevinobee Sep 18, 2013
@kevinobee
Copy link
Owner

With the information that the location element starts after the <configSections> element and ends before the <runtime> element I have been able to recreate the issue.

PM> install-package sitecore.glimpse
Attempting to resolve dependency 'Glimpse (≥ 1.6.1)'.
Attempting to resolve dependency 'Glimpse.AspNet (≥ 1.4.1)'.
Installing 'Glimpse 1.6.1'.
Successfully installed 'Glimpse 1.6.1'.
Installing 'Glimpse.AspNet 1.4.1'.
Successfully installed 'Glimpse.AspNet 1.4.1'.
Installing 'Sitecore.Glimpse 0.3.0'.
Successfully installed 'Sitecore.Glimpse 0.3.0'.
Adding 'Glimpse 1.6.1' to Website.
Successfully added 'Glimpse 1.6.1' to Website.
Adding 'Glimpse.AspNet 1.4.1' to Website.
Successfully added 'Glimpse.AspNet 1.4.1' to Website.
Adding 'Sitecore.Glimpse 0.3.0' to Website.
Uninstalling 'Sitecore.Glimpse 0.3.0'.
Successfully uninstalled 'Sitecore.Glimpse 0.3.0'.
Uninstalling 'Glimpse.AspNet 1.4.1'.
Successfully uninstalled 'Glimpse.AspNet 1.4.1'.
Uninstalling 'Glimpse 1.6.1'.
Successfully uninstalled 'Glimpse 1.6.1'.
Install failed. Rolling back...
install-package : An error occurred while applying transformation to 'web.config' in project 'Website': No element in the source document matches 
'/configuration/system.webServer/modules/add[@name='SitecoreRewriteModule']'
At line:1 char:1
+ install-package sitecore.glimpse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidDataException
    + FullyQualifiedErrorId :     NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

@kevinobee
Copy link
Owner

The <location> element looks to be breaking the install-package glimpse.aspnet step.

Specifically you end up with a web.config that ends with:

<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
  <!-- If you are having issues with Glimpse, please include this. It will help us figure out whats going on. 
  <logging level="Trace" />-->

  <!-- Want to use Glimpse on a remote server? Ignore the LocalPolicy by removing this comment.
  <runtimePolicies>
    <ignoredTypes>
      <add type="Glimpse.AspNet.Policy.LocalPolicy, Glimpse.AspNet"/>
    </ignoredTypes>
  </runtimePolicies>-->
</glimpse><system.web>
    <!-- Glimpse: This can be commented in to add additional data to the Trace tab when using WebForms
    <trace writeToDiagnosticsTrace="true" enabled="true" pageOutput="false"/> -->
    <httpModules>
        <add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" />
    </httpModules>
    <httpHandlers>
        <add path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" />
    </httpHandlers>
</system.web><system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
        <add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" />
    </modules>
    <handlers>
        <add name="Glimpse" path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" preCondition="integratedMode" />
    </handlers>
</system.webServer></configuration>

and attempts to the browse the site generate HTTP 500 responses.

image

@kevinobee
Copy link
Owner

Just to clarify, if you run install-package glimpse.aspnet the package installs without any warnings in the package manager console but the web site will return HTTP 500 errors as the web.config will now contain multiple definitions for the <system.web> and <system.webServer> elements.

@owenmartin
Copy link
Author

Indeed, manual intervention is required. I believe this is because Glimpse using a .transform, rather than a .xdt, and so the default behaviour is to insert missing nodes where applicable, whereas xdt just goes bang, and the InsertIfMissing attribute doesn't seem to work as nicely as it should

@nikmd23
Copy link

nikmd23 commented Sep 18, 2013

Now that NuGet finally supports .xdt based transforms, we'll be looking at switching over to those. We get issues reported from time to time stating that NuGet does the wrong thing to people's web.config, so hopefully we can clean those up.

@kevinobee - please feel free to open an issue in the Glimpse issue tracker and we will try to clean this up ASAP. I'm not 100% sure though that even .xdt transforms would alleviate this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants