qetza / vsts-xdttransform-task

Visual Studio Team Services Build and Release extension that applies XDT transforms on XML files.
MIT License
20 stars 9 forks source link

SetAttributes duplicates attributes #3

Closed mikesigs closed 7 years ago

mikesigs commented 7 years ago

I have a connection string that I am trying to tokenize. My connection string is pretty standard:

<connectionStrings>
    <add name="Foo" connectionString="The connection string" providerName="System.Data.SqlClient" />
</connectionStrings>

With the transform I am attempting to simply change the connectionString attribute as follows:

<connectionStrings>
    <add name="Foo" connectionString="__FooConnectionString__" xdt:Transform="SetAttributes(connectionString)" xdt:Locator="Match(name)" />
</connectionStrings>

If I use the Preview Transform feature in Visual Studio the transform is applied properly. However, the output of the XDT Transform Task in VSTS duplicates the providerName attribute so the connection string looks like this:

<connectionStrings>
    <add name="Foo" connectionString="__FooConnectionString__" providerName="System.Data.SqlClient" providerName="System.Data.SqlClient" />
</connectionStrings>

This causes the application to fail upon startup.

mikesigs commented 7 years ago

I thought I'd use the Replace transform as a work around but it doesn't help. I still wind up with two providerName attributes.

Any thoughts on how I can debug this?

qetza commented 7 years ago

Hi @mikesigs,

I'm using a standard library from Microsoft (https://www.nuget.org/packages/Microsoft.Web.Xdt/) to apply the transformations but I'll take a look if I can reproduce and find a solution.

You can always activate the task verbose logs by adding a variable system.debug with the value true.

mikesigs commented 7 years ago

Hi @qetza. My apologies. It was embarrassingly simple actually, but in my defenese, I didn't set any of this up. The issue was in the variable value being placed in that token. I.e. FooConnectionString = the connection string value providerName="System.Data.SqlClient"