NuGet Package Converts Config File

Is there a way to make the NuGet package convert a configuration file? For example, when I want my NuGet package to edit a file web.config, I create a file web.config.install.xdt. But what if I want my NuGet package to edit a file web.config.debug?

I tried to create the file web.config.debug.install.xdt, but ran into one problem: I cannot force the transform to insert attributes that are themselves xdt transform attributes. Sort of:

<?xml version="1.0" encoding="utf-8" ?>
<configuration  xmlns:xdt1="http://schemas.microsoft.com/XML-Document-Transform">

  <system.serviceModel >
    <client xdt1:Transform="Insert">
      <endpoint address="http://blah.blah" binding="basicHttpBinding" contract="Test.Contract" 
                name="TestWs" xdt:Transform="Replace" xdt:Locator="Match(name)"/>
    </client>
  </system.serviceModel>

</configuration>

(I tried changing the xdt namespace, but that didn't help either.)

+4
source share
1 answer

Although this is probably not the best answer, he did my job when I found myself in this situation:

"" , xdt.

https://docs.nuget.org/create/Transforming-Configuration-Files-Using-dotTransform-Files.md

, , , xmlns .transform.

, web.qa.config, :

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
      <appSettings>
            <add key="Tier" value="qa" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
      </appSettings>
 </configuration>

:

<add key="RedirectUri" value="yourRedirectUriForQA" xdt:Transform="Replace" />

Nuget web.qa.config.transform:

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <appSettings>
         <add key="RedirectUri" value="yourRedirectUriForQA" xdt:Transform="Replace" />
    </appSettings>
</configuration>

, .nuspec, .

+1

All Articles