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

查看:73
本文介绍了发布期间的Azure DevOps 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.

我将舞台命名为我的环境(预览),并为该环境创建了一个web.config文件(web.preview.config).我所有的环境配置文件都与Web.Config文件位于同一路径.

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.

日志显示转换已完成:

2018-11-17T00:26:52.0383966Z [命令] D:\ a_tasks \ AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1 \ 3.4.13 \ ctt \ ctt.exe s:D:\ a_temp \ temp_web_package_06958915987488234 \ D_C \ a \ 1 \ s \ Microsoft.Xbox.Mvp \ Microsoft.Xbox.Mvp.Api \ obj \ Preview \ Package \ PackageTmp \ bin \ Web.config t:D:\ a_temp \ temp_web_package_06958915987488234 \ Content \ D_C \ a \ 1 \ s \ Microsoft.Xbox.Mvp \ Microsoft.Xbox.Mvp.Api \ obj \ Preview \ Package \ PackageTmp \ bin \ Web.Release.config d:D:\ a_temp \ temp_web_package_06958915987488234 \ Content \ D_C \ a \ 1 \ s \ Microsoft.Xbox.Mvp \ Microsoft.Xbox.Mvp.Api \ obj \ Preview \ Package \ PackageTmp \ bin \ Web.config pw i 2018-11-17T00:26:52.4335280Z [命令] D:\ a_tasks \ AzureRmWebAppAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1 \ 3.4.13 \ ctt \ ctt.exe s:D:\ a_temp \ temp_web_package_06958915987488234 \ Content a \ 1 \ s \ Microsoft.Xbox.Mvp \ Microsoft.Xbox.Mvp.Api \ obj \ Preview \ Package \ PackageTmp \ bin \ Web.config t:D:\ a_temp \ temp_web_package_06958915987488234 \ Content \ D_C \ a \ 1 \ s \ Microsoft.Xbox.Mvp \ Microsoft.Xbox.Mvp.Api \ obj \ Preview \ Package \ PackageTmp \ bin \ Web.Preview.config d:D:\ a_temp \ temp_web_package_06958915987488234 \ Content \ D_C \ a \ 1 \ s \ Microsoft.Xbox.Mvp \ Microsoft.Xbox.Mvp.Api \ obj \ Preview \ Package \ PackageTmp \ bin \ Web.config pw i 2018-11-17T00:26:52.5443873Z XML转换成功应用

2018-11-17T00:26:52.0383966Z [command]D:\a_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\3.4.13\ctt\ctt.exe s:D:\a_temp\temp_web_package_06958915987488234\Content\D_C\a\1\s\Microsoft.Xbox.Mvp\Microsoft.Xbox.Mvp.Api\obj\Preview\Package\PackageTmp\bin\Web.config t:D:\a_temp\temp_web_package_06958915987488234\Content\D_C\a\1\s\Microsoft.Xbox.Mvp\Microsoft.Xbox.Mvp.Api\obj\Preview\Package\PackageTmp\bin\Web.Release.config d:D:\a_temp\temp_web_package_06958915987488234\Content\D_C\a\1\s\Microsoft.Xbox.Mvp\Microsoft.Xbox.Mvp.Api\obj\Preview\Package\PackageTmp\bin\Web.config pw i 2018-11-17T00:26:52.4335280Z [command]D:\a_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\3.4.13\ctt\ctt.exe s:D:\a_temp\temp_web_package_06958915987488234\Content\D_C\a\1\s\Microsoft.Xbox.Mvp\Microsoft.Xbox.Mvp.Api\obj\Preview\Package\PackageTmp\bin\Web.config t:D:\a_temp\temp_web_package_06958915987488234\Content\D_C\a\1\s\Microsoft.Xbox.Mvp\Microsoft.Xbox.Mvp.Api\obj\Preview\Package\PackageTmp\bin\Web.Preview.config d:D:\a_temp\temp_web_package_06958915987488234\Content\D_C\a\1\s\Microsoft.Xbox.Mvp\Microsoft.Xbox.Mvp.Api\obj\Preview\Package\PackageTmp\bin\Web.config pw i 2018-11-17T00:26:52.5443873Z XML Transformations applied successfully

我可以看到它首先转换为发行版,然后按照文档中的说明应用了预览(先发行版,然后发行环境).但是,尽管它说XML转换成功应用,但是当我检查配置变量时,它们并没有改变.进行转换工作的唯一方法是在排队新的构建时定义buildConfiguration变量,这使我无法在不同的环境中使用相同的构建.

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.

在研究时,我从

在构建过程中将转换Web.config,如果从构建"生成部署程序包,然后在发行"中部署它,则无法在部署之前对其进行转换.

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.

但是医生说我可以在多个阶段使用一个默认软件包...这是否仍然意味着我必须为每个环境创建单独的版本? XML转换不是我要解决的方案应该看的东西吗?

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?

提前谢谢!

++

发布设置:

发布步骤(我想?我强烈感觉这就是您想要的...):

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

推荐答案

1)确保进行转换.测试一下 此处.

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

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

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

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

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)仔细检查您的发行版中是否有文件转换和复制"下的"IIS Web应用程序部署"任务.您已检查XML转换的变量替换选项".

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天全站免登陆