首页 > 解决方案 > app.config not getting transformed after installation of nuget package

问题描述

Please find attached app.config and app.config.install.xdt file content. Not able to find the cause of not transofming the file. The goal is to remove the added plugin under tag in app.config once my custom specflow package installation is complete. Is there any tool available where we can see the log(s) while install the nuget package and show wheather config file transformation is successful or fail? I already searched for other questions but no clue. Both the xml files are valid as I validat them from https://webconfigtransformationtester.apphb.com/.

app.config content

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
  </configSections>

  <log4net>
    <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <appendToFile value="true"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %P{Level}%4P{Source} - %message%newline"/>
      </layout>
    </appender>

    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="[%-5level] %message%newline"/>
      </layout>
    </appender>

    <root>
      <level value="DEBUG"/>
      <appender-ref ref="FileAppender"/>
      <appender-ref ref="ConsoleAppender"/>
    </root>
  </log4net>

  <specFlow>
    <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
    <plugins>
      <add name="Com.Plugin.Gherkin.SpecFlow.2.4" path="Com.Plugin.Gherkin.SpecFlow.2.4" type="Generator"/>
    </plugins>
  </specFlow>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
  </startup>
</configuration>

app.config.install.xdt

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

Package.nuspec

<?xml version="1.0"?>
<package >
  <metadata>
    <id>Sushil</id>
    <version>1.0.0</version>
    <authors>stade</authors>
    <owners>stade</owners>
    <licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl>
    <projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl>
    <iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package description</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2019</copyright>
    <tags>Tag1 Tag2</tags>
    <dependencies>
      <dependency id="SampleDependency" version="1.0" />
    </dependencies>
  </metadata>

  <files>
    <!--Add Section to Uninstall and Re-install Application.Config files-->
    <file src="app.config.install.xdt" target="content" />
    <file src="app.config.uninstall.xdt" target="content" />
  </files>
</package>

标签: c#nugetapp-confignuget-packagexdt-transform

解决方案


推荐阅读