Nuget Config.Transform Formatting Issue

左心房为你撑大大i 提交于 2020-01-23 08:41:05

问题


I have created a Nuget config transform file that has the following transformation:

<?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>

The problem occurs when it merges into an application's app.config or web.config file. Instead of being cleanly spaced it joins everything into one line as follows:

    <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>

This is not very readable to those consuming my package. Is there something I am missing? Proper carriage returns perhaps?


回答1:


There are formatting limitations in the original Web.config transforms of NuGet. As of v2.6, XDT transforms have been added which don't have these limitations. See the docs on how to use the .install.xdt and .uninstall.xdt files for any XML files in your package. Once I started using XDT, formatting issues went away.



来源:https://stackoverflow.com/questions/17971083/nuget-config-transform-formatting-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!