0
votes

I'm using Azure DevOps to deploy an ASP.NET application to an IIS servers on-prem. The IIS servers are using a shared configuration so they need a custom Machine Key setup.

I can use XML transform to add add the machineKey entry in the Web.Config

  <system.web>
    <machineKey decryptionKey="{hex-key value}" validationKey="{hex-key value}"/>
  </system.web>

but I don't want to have the actual keys in source control so I'll need to replace those values at deploy time. Substitution is easy enough for appsettings and connection strings but how can I substitute values in the System.Web section of the Web.Config?

1

1 Answers

1
votes

How can I substitute values in the System.Web section of the Web.Config?

What about consider to use one extension Replace token? For why I recommend it is because it can achieve the demand that it can only be replaced during the pipeline running.

Also, its usage is very convenient. Just need to specify the prefix and suffix in the task, and then make apply them in to your web.config file.

enter image description here

Then specify the corresponding variables with same name in Variables tab.

Only this, during the pipeline running, the task could find the corresponding token correctly and replace the value into it.

For detailed steps, you could refer to my previous answer for details: Use replace token task.