Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

web.config transform xml element

I'm getting rid of web.config configuration batch file (Hanselman's) and want to use the config transformation feature in vs2010. However I'm having a bit of trouble figuring out of to transform an xml element (as opposed to an attribute on an element).

This is a snippet from my web.config:

<Federation type="..." xmlns="...">
      <SigningCertificate .../>
      <AllowedAudienceUris>
               <Audience>https://audience.url.com</Audience>
      </AllowedAudienceUris>
</Federation>

I want to transform the element by inserting a different url based on the build configuration - can this be done?

Thanks in advance!

/Jasper

like image 308
jaspernygaard Avatar asked Nov 06 '22 01:11

jaspernygaard


1 Answers

If the AllowedAudienceUris and Audience elements occur only once, omitting the xdt:Locator is also fine:

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <Federation>
    <AllowedAudienceUris xdt:Transform="Replace">
      <Audience>https://example.com</Audience>
    </AllowedAudienceUris>
  </Federation>
</configuration>
like image 181
Marco G Avatar answered Nov 10 '22 14:11

Marco G