We have an asp.net webapplication (full framework) and deploy it using release manager. The bits are in an artifact that is created during build with the contents of the webdeploy zip and a powershell desired state configuration (dsc) script to install te webapplication. Somewhere in the powershell script we use the xTokenize DscResource to set the connectionstrings and other settings.

In our initial setup we used the token file approach that is the default. Microsoft provided us with an example: https://www.powershellgallery.com/packages/xReleaseManagement/1.0.0.0/Content/Examples%5CxTokenize_TokenFile.ps1
The steps during build and release are:
- build performs web.config transformation to remove the debug (and other things),
- build replaces the web.config connectionstring with webdeploy tokens,
- build adds the web.token.config file to the artifact,
- release copies the web.config to the wwwroot directory,
- xTokenize replaces the web.config with the web.token.config,
- xTokenize replaces the tokens in web.config with actual values
It worked, but we had to copy every change in web.config to web.token.config. This felt cumbersome and error prune.
There was another example without the need of a token file: https://www.powershellgallery.com/packages/xReleaseManagement/1.0.0.0/Content/Examples%5CxTokenize_NoTokenFile.ps1 This could be combined with the web.config transformation to eliminate the need for a web.token.config. No more double administration and less steps in the build/release.
- build performs web.config transformation to remove the debug (and other things) also replaces the connectionstrings with the __TOKENS__ ,
- –
- –
- release copies the web.config to the wwwroot directory,
- –
- xTokenize replaces the tokens in web.config with actual values
To stop the build from replacing the connectionstrings we defined a publish profile. The publish profile creates a pubxml file with the same name as the profile. We added the following line to the pubxml to stop the transformation of connectionstrings:
<AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings>
Remember to use the /p:PublishProfile=YOUR_PROFILE_NAME in the build, else the connectionstrings are transformed since it is the default behaviour.
Now our web.release.config contains some more lines that replace the connectionstrings with the __TOKENS__ (we think that is a good thing) and the web.token.config had been removed.
The results are the same working webapplication, but the way to get there is less crooked.