Incomplete merging of web.config though Nuget
Closed this issue · 2 comments
On adding package "elmah.sqlserver" from nuget it did not add any of the sectionGroup for elmah to my web.config (it did add the elmah setction and new connection string however). I have had to manually add the following into the configSections section:
<sectionGroup name="elmah"> <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah"/> <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" /> <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" /> <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah"/> </sectionGroup>
Also, the standard handler is not merged:
<add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
This issue is somewhat related to NuGet and how it changed the default behavior in version 2.5 with respect to upgrading dependencies during install. See “Dependencies are no longer unnecessarily updated during package installation” in NuGet docs on versioning. The thing is, elmah.sqlserver
1.2.0 has a dependency on elmah
≥ 1.2.0 but that version doesn't have web.config
transformations. They were added later in a minor update. Prior to NuGet 2.5, installing elmah.sqlserver
1.2.0 would automatically upgrade the elmah
1.2.0 dependency to 1.2.2 and apply the web.config
transformations. With NuGet 2.5 and later releases, you have to ask for the old upgrade behavior.
If you issue Install-Package elmah.sqlserver
for a web project in the Package Manager Console in VS, you'll see output similar to the following:
PM> Install-Package elmah.sqlserver
Attempting to gather dependencies information for package 'elmah.sqlserver.1.2.0' with respect to project 'WebApp', targeting '.NETFramework,Version=v4.5.2'
Attempting to resolve dependencies for package 'elmah.sqlserver.1.2.0' with DependencyBehavior 'Lowest'
Resolving actions to install package 'elmah.sqlserver.1.2.0'
Resolved actions to install package 'elmah.sqlserver.1.2.0'
Adding package 'elmah.1.2.0' to folder 'A:\WebApp\packages'
Added package 'elmah.1.2.0' to folder 'A:\WebApp\packages'
Added package 'elmah.1.2.0' to 'packages.config'
Successfully installed 'elmah 1.2.0' to WebApp
Adding package 'elmah.sqlserver.1.2.0' to folder 'A:\WebApp\packages'
Added package 'elmah.sqlserver.1.2.0' to folder 'A:\WebApp\packages'
Added package 'elmah.sqlserver.1.2.0' to 'packages.config'
Successfully installed 'elmah.sqlserver 1.2.0' to WebApp
Notice that it installed elmah.1.2.0
because it said in the beginning:
Attempting to resolve dependencies for package 'elmah.sqlserver.1.2.0' with DependencyBehavior 'Lowest'
To fix this, issue Install-Package elmah.sqlserver -DependencyVersion HighestMinor
instead and you should see that it installs elmah.1.2.2
instead and you should see the transformations applied to your web.config
after:
PM> Install-Package elmah.sqlserver -DependencyVersion HighestMinor
Attempting to gather dependencies information for package 'elmah.sqlserver.1.2.0' with respect to project 'WebApp', targeting '.NETFramework,Version=v4.5.2'
Attempting to resolve dependencies for package 'elmah.sqlserver.1.2.0' with DependencyBehavior 'HighestMinor'
Resolving actions to install package 'elmah.sqlserver.1.2.0'
Resolved actions to install package 'elmah.sqlserver.1.2.0'
Adding package 'elmah.corelibrary.1.2.2' to folder 'A:\WebApp\packages'
Added package 'elmah.corelibrary.1.2.2' to folder 'A:\WebApp\packages'
Added package 'elmah.corelibrary.1.2.2' to 'packages.config'
Successfully installed 'elmah.corelibrary 1.2.2' to WebApp
Adding package 'elmah.1.2.2' to folder 'A:\WebApp\packages'
Added package 'elmah.1.2.2' to folder 'A:\WebApp\packages'
Added package 'elmah.1.2.2' to 'packages.config'
Successfully installed 'elmah 1.2.2' to WebApp
Adding package 'elmah.sqlserver.1.2.0' to folder 'A:\WebApp\packages'
Added package 'elmah.sqlserver.1.2.0' to folder 'A:\WebApp\packages'
Added package 'elmah.sqlserver.1.2.0' to 'packages.config'
Successfully installed 'elmah.sqlserver 1.2.0' to WebApp
In the GUI, you want to change the dependency behavior option as shown below before you hit Install:
You should then also see the right versions resolved: