Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help: how to change an "add" and how to delete #20

Closed
lboening opened this issue Mar 28, 2017 · 7 comments
Closed

Help: how to change an "add" and how to delete #20

lboening opened this issue Mar 28, 2017 · 7 comments
Assignees
Milestone

Comments

@lboening
Copy link

I have an app.config file. It has many "add" entries in the "appSettings" section.

Using your tool, it is easy to add a key with a particular value.

But how do I target a particular "add", such as the fourth one in the list?

Example:
<add key="MaxConcurrentAutoVueControls" value="3" />

If I add, I then have two keys, one with the proper setting. The fourth one on the list is still in the appSettings set with unchanged values.

Is it possible to delete a particular key with your tool?

I know how to do it using other techniques.

@markjose
Copy link

markjose commented Sep 5, 2017

Maybe a bit late to the party here but you can address individual nodes by using the key or another attribute on the node. Use the following syntax:

{ 
"configuration/appInfo/add[@key='SomeKey']/@value": "SomeValue",
"configuration/appInfo/add[@key='AnotherKey']/@value": "$(SomeBuildOrReleaseVariable)",
"configuration/appInfo/add[@key='MaxConcurrentAutoVueControls']/@value": 3,
}

To delete you could always <clear /> and then <add />

@sergeyzwezdin
Copy link
Member

@lboening Could you please explain a bit detailed this case:

If I add, I then have two keys, one with the proper setting

It would be useful to have piece of you config file as well as your transformations.
If you have duplication of MaxConcurrentAutoVueControls key, it won't be correct behavior and should be treated as a bug.

@sergeyzwezdin
Copy link
Member

Also, as @markjose mentioned before, you can address specific key by add[@key=...] syntax.

@sergeyzwezdin
Copy link
Member

Another part of you request is deleting nodes. Because of this, I mark it as new feature request and will try to take a look what I can do here.

@sergeyzwezdin sergeyzwezdin self-assigned this Oct 15, 2017
@sergeyzwezdin sergeyzwezdin added this to the 1.3.0 milestone Oct 15, 2017
sergeyzwezdin added a commit that referenced this issue Oct 15, 2017
@sergeyzwezdin
Copy link
Member

I've added syntax to remove nodes.
In upcoming 1.3.0 version it will be possible to do something like this:

{
  "#configuration/appInfo/add[@key='SomeKey']/@value": ""
}

Please note, that # at the start of transformation key means that node will be deleted.

@sergeyzwezdin
Copy link
Member

Latest fixes were released to Nuget and VS Marketplace.

@bondort
Copy link

bondort commented Jun 2, 2020

Hey @sergeyzwezdin how do I add the "clear" tag mentioned by you above?
I tried adding "configuration/connectionStrings/clear": "" but it created a <clear></clear> tag which is incorrect.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants