Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget Config.Transform Formatting Issue

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="[email protected]" />
                </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="[email protected]" />                    </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?

like image 257
Blake Blackwell Avatar asked Jul 31 '13 12:07

Blake Blackwell


People also ask

Is NuGet config necessary?

If you're trying to create a NuGet package from your own code, you do not need a NuGet. config file. The NuGet. config file exists to specify package sources from which packages are installed and updated - i.e. where you consume packages from.

Why does NuGet add app config?

The reason that the NuGet package manager adds assembly binding redirects to library projects is because there are types of projects where the output type is a library, but there are special mechanisms in place to assure that the library's app or web config file will be applied at runtime.

How add config transform?

Release. config transformation files that are created by default for the two default build configurations. You can create transformation files for custom build configurations by right-clicking the Web. config file and choosing Add Config Transforms from the context menu.


1 Answers

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.

like image 166
Sumo Avatar answered Sep 28 '22 06:09

Sumo