Example 1: XML Document Transformation (XDT)
Consider a scenario where a user needs to modify the file OAuthServer\Web.config and wants to add an attribute to the oauth Tag in which the value of the configSource attribute is equal to OAuth.config.
- Create a file OAuthServer\Web.config in the TransformationsofConfigFiles folder according to XDT rules.
- Fill it in according to the XDT rules.
- Commit the changes.
- The Transformation is reflected in OAuthServer\Web.config after the next Deployment. Next time, the config file should give the same result as after the first application of the Transformation.
- Sample XML Transformation:
```xml
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<oauth configSource="OAuth.config" yourNewAttribute="value" xdt:Transform="SetAttributes" xdt:Locator="Match(configSource)" />
</configuration>
- For XDT Documentation, visit https://learn.microsoft.com/en-us/previous-versions/aspnet/dd465326(v=vs.110)
- For Web.config Transformation Syntax for Web Project Deployment Using Visual Studio, visit https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/transform-webconfig?view=aspnetcore-5.0