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

Can I replace part of a value? #200

Open
MrYossu opened this issue Dec 22, 2016 · 4 comments
Open

Can I replace part of a value? #200

MrYossu opened this issue Dec 22, 2016 · 4 comments

Comments

@MrYossu
Copy link

MrYossu commented Dec 22, 2016

All of the examples I've seen of using SlowCheetah involve replacing the full contents of an attribute in a node.

What I want to do is replace part of an attribute value. For example, if my App.config file contains the following...

  <endpoint address="http://localhost:24953/Services/AuditService.svc"
            binding="customBinding"
            bindingConfiguration="CustomBindingDefault"
            contract="AuditServiceReference.AuditService"
            name="AuditService" />

...then I can add a transform to my App.Release.config file as follows...

  <endpoint address="http://www.mydomain.co.uk/Services/AuditService.svc"
            behaviorConfiguration="LargeMessageBehavior"
            binding="customBinding"
            bindingConfiguration="CustomBindingDefault"
            contract="AuditServiceReference.AuditService"
            name="AuditService"
            xdt:Transform="Replace"
            xdt:Locator="Match(name)" />

...and it will produce the correct output.

However, as I have a lot of these service references, I have lots of entries like the above in the App.config file, with corresponding entries in the App.Release.config file.

What I would really like to do is only have to add one entry to the App.Release.config file that works all of the service entries in the App.config file, ie it transforms localhost:24953 into www.mydomain.co.uk for each node in the file.

Is this possible, or do I have to have a separate entry in my App.Release.config file for every service?

@MrYossu
Copy link
Author

MrYossu commented Jan 30, 2017

Anyone?

@todthomson
Copy link

65197903

@jviau
Copy link
Collaborator

jviau commented Jan 30, 2017

SlowCheetah uses Microsoft.Web.Xdt to process the XML transforms. Here is the MSDN page for it. I believe the SetAttributes section is what you are looking for.

@sayedihashimi
Copy link
Owner

Replacing a portion of the value is not supported with XDT out of the box. It is possible to create a custom XDT transform which can replace a portion of an attribute value. I describe how to do this in an old blog post at http://sedodream.com/2010/09/09/extendingxmlwebconfigconfigtransformation.aspx.

With that said, I've never tested using a custom transform with SlowCheetah. Also @jviau and others are in the middle of refactoring the code, so if you get it working now you may need to update a reference later.

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

No branches or pull requests

4 participants