发布期间的 Azure DevOps XML 转换不起作用 [英] Azure DevOps XML Transformation During Release Not Working

查看:17
本文介绍了发布期间的 Azure DevOps XML 转换不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我们的管道配置为允许一个构建用于多个环境,而无需创建单独的构建.根据

2) 确保在您的 VS 项目中包含转换文件 Web.Preview.config,并复制到输出目录.

3) 在构建过程中禁用配置转换,您只需要在构建任务的 MSBuild 参数部分添加参数/p:TransformWebConfigEnabled=False.如果要在发布期间更新连接字符串,还需要添加/p:AutoParameterizationWebConfigConnectionStrings=False.这将使用 Web.Preview.config 来转换" web.config.

4) 在您的发行版中仔细检查 File Transforms & 下的 IIS Web App Deploy 任务.已检查 XML 转换的变量替换选项.

I want to configure our pipeline to allow one build to be used for multiple environments without having to create separate builds. According to the docs, it seems like it is possible, as it says:

  • You can use this technique to create a default package and deploy it to multiple stages.

I named my stage as my environment (preview), and I created a web.config file for that environment (web.preview.config) file. All my environment configuration files in the same path as Web.Config file.

The logs say transformation was complete:

2018-11-17T00:26:52.0383966Z [command]D:a_tasksAzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb13.4.13cttctt.exe s:D:a_temp emp_web_package_06958915987488234ContentD_Ca1sMicrosoft.Xbox.MvpMicrosoft.Xbox.Mvp.ApiobjPreviewPackagePackageTmpinWeb.config t:D:a_temp emp_web_package_06958915987488234ContentD_Ca1sMicrosoft.Xbox.MvpMicrosoft.Xbox.Mvp.ApiobjPreviewPackagePackageTmpinWeb.Release.config d:D:a_temp emp_web_package_06958915987488234ContentD_Ca1sMicrosoft.Xbox.MvpMicrosoft.Xbox.Mvp.ApiobjPreviewPackagePackageTmpinWeb.config pw i 2018-11-17T00:26:52.4335280Z [command]D:a_tasksAzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb13.4.13cttctt.exe s:D:a_temp emp_web_package_06958915987488234ContentD_Ca1sMicrosoft.Xbox.MvpMicrosoft.Xbox.Mvp.ApiobjPreviewPackagePackageTmpinWeb.config t:D:a_temp emp_web_package_06958915987488234ContentD_Ca1sMicrosoft.Xbox.MvpMicrosoft.Xbox.Mvp.ApiobjPreviewPackagePackageTmpinWeb.Preview.config d:D:a_temp emp_web_package_06958915987488234ContentD_Ca1sMicrosoft.Xbox.MvpMicrosoft.Xbox.Mvp.ApiobjPreviewPackagePackageTmpinWeb.config pw i 2018-11-17T00:26:52.5443873Z XML Transformations applied successfully

I can see that it first transformed to release and then it applied preview as the doc says (release then environment). However, although it says XML Transformations applied successfully, when I check the config variables, they are not changed. The only way I could make the transformation work was to define the buildConfiguration variable when I queue a new build, which blocks me from using the same build for different environments.

When I was researching, I found this from this link:

Web.config is transformed during the build process, if you generate the deployment package from "Build" and then deploy it in "Release", then you cannot transform it before deployment.

But the doc said I can use one default package for multiple stages...Does that still mean I have to create separate build for each environment? Is XML transformation not what I should be looking at for the scenario I wanna solve?

Thank you in advance!

++ Edit:

Release Settings:

Release steps (I think? I have a strong feeling that this is what you are looking for...):

解决方案

1) Make sure you transform works. Test it here.

2) Ensure in your VS project that you are including the transform file, Web.Preview.config, and copying to output dir.

3) Disable the config transform during the build, you just need to add argument /p:TransformWebConfigEnabled=False in MSBuild Arguments section of your Build task. You also need to add /p:AutoParameterizationWebConfigConnectionStrings=False if you want to update the connection string during the release. This will use the Web.Preview.config to "transform" the web.config.

4) Double check that in your release for the IIS Web App Deploy task under File Transforms & Variable Substitution Options you have XML transformation checked.

这篇关于发布期间的 Azure DevOps XML 转换不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆