【问题标题】:Nuget Config.Transform Formatting IssueNuget Config.Transform 格式问题
【发布时间】:2013-08-01 00:28:51
【问题描述】:

我创建了一个Nuget config transform file,它具有以下转换:

<?xml version="1.0">
<configuration>
    <system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBinding_IMyService" />
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://mydomain/MySvc/MySvc.svc"
                binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyService"
                contract="MyNamespace.MyService" name="NetTcpBinding_IMyService">
                <identity>
                    <userPrincipalName value="admin@mydomain.com" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

当它合并到应用程序的 app.config 或 web.config 文件时会出现问题。它将所有内容连接成一行,而不是干净地间隔,如下所示:

    <system.serviceModel><bindings><netTcpBinding><binding name="NetTcpBinding_IMyService" /></netTcpBinding></bindings><client><endpoint address="net.tcp://mydomain/MySvc/MySvc.svc" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyService" contract="MyNamespace.MyService" name="NetTcpBinding_IMyService"><identity><userPrincipalName value="admin@mydomain.com" />                    </identity></endpoint></client></system.serviceModel>

对于那些使用我的包的人来说,这不是很可读。有什么我想念的吗?也许适当的回车?

【问题讨论】:

    标签: web-config nuget app-config


    【解决方案1】:

    在 NuGet 的原始 Web.config 转换中存在格式限制。从 v2.6 开始,添加了没有这些限制的 XDT 转换。请参阅docs,了解如何将.install.xdt.uninstall.xdt 文件用于包中的任何XML 文件。一旦我开始使用 XDT,格式问题就消失了。

    【讨论】:

    • 值得注意的是,PackageReference 不支持 xdt 转换 - “正如从 packages.config 迁移到 PackageReference 的文档的包兼容性问题部分中所述,如下所述的 XDT 转换仅由 packages.config 支持。如果将以下文件添加到包中,使用带有 PackageReference 的包的消费者将不会应用转换(请参阅此示例以使 XDT 转换与PackageReference 一起使用)。"
    猜你喜欢
    • 2011-08-11
    • 1970-01-01
    • 2011-09-23
    • 2018-04-02
    • 1970-01-01
    • 2023-04-11
    • 2014-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多