ASP.NET 5 Class Library - Nuget package Web.Config transform

483 views Asked by At

I've created an ASP.NET 5 Class Library using the new project structure provided by Microsoft. I can build the project and host it on a personal Nuget Feed just fine. The only problem is, I would like for this package to insert a key into the destination project Web.config file, and it is not cooperating.

Building the project results in two files:

../artifacts/bin/{Project}/Debug/{Project}.nupkg ../artifacts/bin/{Project}/Debug/{Project}.symbols.nupkg

{Project}.nupkg is what I am publishing to the hosted Nuget feed.

I've followed the Nuget docs on how to do this to no avail.

My web.config.transform file looks like this:

<configuration>
  <appSettings>
    <add key="Test Key" value="Test Value" />
  </appSettings>
</configuration>

When installed in a project, the web.config file remains unchanged.

The project structure of the ASP.NET 5 class library doesn't align exactly with the Nuget specs (e.g. it does not have content, lib, or build directories). Could that be what is causing the issue?

EDIT I'd like to use this Nuget package in an older (.Net 4.5) project. Given that ASP.NET 5 is still pretty new, I don't yet have any projects that would make use of its new structure yet (I.e. project.json). That being said, I would like to make the package backwards compatible with older (pre ASP.NET 5 projects) and newer ones (that leverage the JSON file structure) if possible.

1

There are 1 answers

3
Victor Hurdugaci On

Unfortunately, NuGet transforms are not supported in ASP.NET 5. If you give more details about your scenario, we might be able to see if there is an alternative.

Also, you should avoid using web.config. The new configuration system based on JSON files. (xml is still supported, though)