Transformations on web.config when it has DependentUpon reference

Jun 16, 2011 at 11:25 AM

For my application web.config file is generated by t4 template. And as a result my config file is nested from web.tt file:

web.config file location

Now when I install elmah, for example, I get following output:

PM> Install-Package elmah
Successfully installed 'elmah 1.2.0.1'.
'web.config' already exists. Skipping...
'web.config' already exists. Skipping...
Successfully added 'elmah 1.2.0.1' to ProjectNameToken.Web.

And no configuration of elmah added to web.config file. I verified that elmah section is not present in solution:

Find all "elmah", Subfolders, Find Results 1, "Entire Solution", ""
 
Matching lines: 0    Matching files: 0    Total files searched: 101

Any ideas why it happens? I know that nuget won't update my web.tt file, but at least web.config, is it possible? This happens because web.config file has attribute DependentUpon:

    <Content Include="Web.config">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Web.tt</DependentUpon>
    </Content>

in csproj file. If I remove it everything works as expected. Is it an nuget issue? 

Jun 16, 2011 at 5:27 PM

Not sure exactly what's going on, but generally it doesn't seem right to modify generated file, as you'd lose it all next time it gets re-generated.

Jun 16, 2011 at 5:46 PM

Yes, changes are going to be lost, but I want to see them before and move to the template. Is it possoble?

Jun 16, 2011 at 5:49 PM

You may want to open a bug to track the scenario. My guess is that whatever logic we use to locate project files doesn't find dependent files. So we try to create a new file, and fail because it already exists and we don't want to overwrite it.

Dec 13, 2011 at 3:32 PM

Issue is open since v. 1.3. If you won't fix it, why don't you close it?

Dec 13, 2011 at 6:20 PM

what is the issue number?

Dec 14, 2011 at 7:55 AM

 

1210

Dec 14, 2011 at 2:37 PM

Thanks. I've moved the issue to triage. We'll evaluate it for 1.7 release.

Dec 14, 2011 at 5:00 PM

FWIW i've had similar issues with Nuget. I have packages that have Web.Config Web.Staging.Config and Web.Release.config that the latter 2 are contained in Web.config using dependent upon.

If I install those packages into a project that already has a Web.Staging.Config instead of Nuget applying the appripriate config transformations to the file it will:

'web.staging.config' already exists. Skipping...

It will correctly apply the web.config and web.release.config transforms however.

In a project that does not have the web.staging.config it will correctly create the file with appropriate configuration.

This makes upgrading packages not straight forward as if I release a new version of the package that has changes to the web.staging.config they will be ignored on install with the aforementioned error.

May 30, 2012 at 6:46 PM
dotnetchris wrote:

FWIW i've had similar issues with Nuget. I have packages that have Web.Config Web.Staging.Config and Web.Release.config that the latter 2 are contained in Web.config using dependent upon.

If I install those packages into a project that already has a Web.Staging.Config instead of Nuget applying the appripriate config transformations to the file it will:

'web.staging.config' already exists. Skipping...

It will correctly apply the web.config and web.release.config transforms however.

In a project that does not have the web.staging.config it will correctly create the file with appropriate configuration.

This makes upgrading packages not straight forward as if I release a new version of the package that has changes to the web.staging.config they will be ignored on install with the aforementioned error.

Half a year later, and running Nuget 1.8.30524.9000 confirmed this still exists.