2

I have some information in my nupkg that I would like to include in the consumer's application. What is the best way to include a partial app.config directly when consuming the nupkg?

I have currently done this:

  • mypackage.nupkg
    • content
      • App.config

But this makes that it wants to override a user's own App.config, while there could be valuable information in there.

So I want to combine my App.config with the user's App.config.

I already saw something like this: C#: manage Multiple App.config files, but I cannot see how I could force the user to include my piece into its App.config.

Contents of my App.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="somefolder;someotherfolder;" />
    </assemblyBinding>
  </runtime>
</configuration>

How can I force the consumer to add my App.config to its own app.config?

Community
  • 1
  • 1
Marnix
  • 6,384
  • 4
  • 43
  • 78

1 Answers1

5

You do this using .transform files:

In NuGet's traditional way of configuration-file transformation, you add a file to your package's content and give it the same name as the file you want to transform, followed by a .transform extension. For example, to transform a web.config file, you create a web.config.transform file. The transformation file contains XML that looks like a web.config or app.config file, but it includes only the sections that need to be merged into the project's configuration file.

stuartd
  • 70,509
  • 14
  • 132
  • 163