Configuration transforms
fDeploy Agent supports .NET XML Document Transform (XDT) for transforming configuration files during deployment. This feature allows you to maintain environment-specific configuration changes using the standard Microsoft XDT syntax, even for files that are not web.config.
How it works
During deployment, configuration transforms run after the package is extracted and before variable substitution. This means you can combine XDT transforms with fDeploy variable substitution for maximum flexibility.
The deployment pipeline order is:
- Package upload and extraction
- Configuration transforms
- Variable substitution
- Certificate installation
- IIS configuration
XDT syntax
Transform files use the Microsoft XML Document Transform namespace. Here is an example of a transform file that removes the debug attribute from the compilation element:
<?xml version="1.0"?><configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <system.web> <compilation xdt:Transform="RemoveAttributes(debug)" /> </system.web></configuration>For more information on XDT syntax, refer to the Microsoft documentation on web.config transforms.
Automatic transforms
When the âAutomatically run .NET configuration transformation filesâ checkbox is enabled on an IIS deployment step, fDeploy Agent will scan your deployed package for transform files that follow the standard naming convention and apply them automatically.
Transform files are applied in this order:
*.Release.config*.<Environment>.config
For example, suppose your package contains:
Web.configWeb.Release.configWeb.Production.configWeb.Test.configWhen deploying to an environment named âProductionâ, fDeploy Agent will:
- Apply
Web.Release.configtoWeb.config - Apply
Web.Production.configtoWeb.config
The Web.Test.config file will not be applied since the target environment is âProductionâ, not âTestâ.
Additional transforms
You can define additional transforms in the âAdditional transformsâ text field. These transforms run regardless of whether the automatic transforms checkbox is enabled. This is useful when your transform files do not follow the standard naming convention.
Additional transforms are defined using the format:
TransformFile => TargetFileOne transform definition per line. fDeploy supports three types of definitions:
Explicit
Transform.config => Target.configApplies Transform.config to Target.config when both files are in the same directory. fDeploy will search recursively through all directories in your package for matching pairs.
Relative path
Path\Transform.config => Target.configApplies Transform.config to Target.config when Transform.config is in the directory Path relative to Target.config.
Wildcard
Wildcards can be used to match multiple files. They can be used anywhere in the transform filename (left side), but only at the start of the target filename (right side).
Wildcard on both sides:
*.Transform.config => *.configApplies foo.Transform.config to foo.config and bar.Transform.config to bar.config.
Wildcard on transform only:
*.Transform.config => Target.configApplies foo.Transform.config and bar.Transform.config to the same Target.config.
Wildcard on target only:
Transform.config => Path\*.configApplies Transform.config to foo.config and bar.config when foo.config and bar.config are in the directory Path relative to Transform.config.
Configuring transforms in fDeploy
To enable configuration transforms on a deployment step:
- Navigate to your projectâs deployment process
- Select or create an IIS deployment step
- Expand the âConfiguration transformsâ section
- Check âAutomatically run .NET configuration transformation filesâ to enable convention-based transforms
- Optionally, define additional transforms in the âAdditional transformsâ text field
The configuration transforms section is located between the IIS configuration and variable substitution sections in the step editor.