AutoParameterizationWebConfigConnectionStrings 在 azure devops 发布管道中不起作用

AutoParameterizationWebConfigConnectionStrings not working in azure devops release pipelines

我正在 Azure DevOps 中为一个新项目设置构建和发布管道。我从一个已经工作了一段时间的现有项目中反映了这一点。

问题是连接字符串没有通过 XML 或发布管道变量替换进行转换。

我在构建阶段传递了以下参数:

/p:AutoParameterizationWebConfigConnectionStrings=false /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\"

然而,在我使用 system.debug=true 发布的两个项目中,我看到了这个错误:

ConnectionString attributes in Web.config is parameterized by default. Note that the transformation has no effect on connectionString attributes as the value is overridden during deployment by 'Parameters.xml or 'SetParameters.xml' files. You can disable the auto-parameterization by setting /p:AutoParameterizationWebConfigConnectionStrings=False during MSBuild package generation.

我确实在发布管道上检查了 XML 转换和 XML 变量替换框。

我试过让这个工作一整天都无济于事。

大家还有什么想法或建议吗?

作为解决方法,请尝试通过将以下字符串添加到项目文件来禁用自动参数化,并检查是否可行。 (确保将标签放在正确的位置,例如您在场景中提到的:在发布版本 属性 组下)

<AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings>

此外,请参考此博客以检查是否有助于您解决问题:Using XML Transformations when deploying to Azure App Service using VSTS