machineKey标签的转换

问题描述 投票:0回答:1

我们必须转换标签,其中“decryptionKey”和“validationKey”对于我们的开发和测试环境将是不同的。

我们尝试为validationKey和decryptionKey提供不同的变量,但与xdt:Transform和xdt:Locator属性混淆,因为它们将在同一个标​​记中出现一次。

假设以下是web.config machineKey标记,

<machineKey decryptionKey="012345678910111213141516"
            validation="SHA1"                validationKey="235487512547896321458778996325456965542126364586965" />

我们必须进行如下的改造,

<machineKey decryptionKey="#{DecryptionKey}#"
            validation="SHA1"
            validationKey="#{ValidationKey}#"
            xdt:Transform="SetAttributes" 
            xdt:Locator="Match(decryptionKey)"
            xdt:Transform="SetAttributes" 
            xdt:Locator="Match(validationKey)" />

需要这种解决方案,我们必须在单个标签中提供多个变量。

azure-devops environment-variables release-management web.config-transform
1个回答
0
投票

要设置多个属性,需要将它们作为逗号分隔列表传递给SetAttributes。

这是记录here

但是,如果您实际上正在替换所有属性,那么使用xdt:Transform="Replace"并在每个配置中设置整个标记值可能更容易/更清晰。

© www.soinside.com 2019 - 2024. All rights reserved.