什么 TFS 2017 构建任务在 TFS 构建期间应用 web.config 转换? [英] What TFS 2017 build task applies web.config transforms during TFS builds?

查看:14
本文介绍了什么 TFS 2017 构建任务在 TFS 构建期间应用 web.config 转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更改了一些原始信息,以使帖子在发现后更加关注真正的问题.

Some original info was changed to make the post more focused on the real issue after it was found.

这些是当前环境的一些细节.我列出这些只是因为在其他帖子中提出了问题,以确定在当前环境中哪些是有效的,哪些是无效的:

These are some of the details of the current environment. I listed these only because questions were raised in other posts to determine what was and was not working in the current environment:

Upon check-in TFS 2017 successfully builds a web project on the build agent.
A VS 2017 publish profile can manually transform the project properly
The build machine artifact location includes both the transform and profile files

神器位置如下图:

我在微软的 VS 网站、SO 和其他论坛上对此进行了深入研究,但是有很多不同的答案,其中很多是针对旧版本的,我无法将其拼凑起来.因此,我有几个子问题.

I have researched this in depth on Microsoft's VS site, SO and other forums, but there are so many different answers, many of them for older versions, I have been unable to piece this together. As a result I have several sub-questions.

1) 可以在构建和发布中进行转换吗?.我读到转换是在发布过程中应用的,而不是在构建过程中,这让我想知道在构建过程中是否甚至可以做到这一点.但是当我探索发布时,我看到所有相同的任务都可以在 Build 中使用,这表明我可以在 Build 或 Release 中使用转换进行发布.对吗?

1) Can transforms be engaged in both Builds and Releases?. I read that transforms are applied during the publish process, not the build process, and that made me wonder if it is even possible to do this during a Build. But then when I was exploring releases, I saw all the same tasks usable in a Build, which suggests I can publish with a transform in either Build or Release. Is that correct?

2) TFS 2017 是否需要进行大量特殊处理才能使用转换文件?一些帖子指示编辑 .proj 文件.我想在进行这种详细操作之前得到确认,尤其是考虑到 TFS 2017 的改进.

2) Does TFS 2017 require a lot of special handling to engage a transform file? Some of the posts instructed the editing of the .proj file. I wanted to get a confirmation before doing that kind of detailed manipulation, especially given the improvements in TFS 2017.

以下信息是名为confPanner-CI"的当前构建定义的状态.阴影 PS 脚本已成功用于上传到托管位置以测试整个过程,但这对于手头需要应用转换的任务来说是不够的:

The following information is the state of the current build definition named "confPanner-CI". The shaded PS script was successfully used to upload to the hosting location to test the whole process, but that is not adequate for the task at hand which requires transforms to be applied:

还为 powershell 脚本创建临时位置的完整 MSBuild 参数是:

The full MSBuild Arguments which also created a temp location for the powershell script are:

/p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=c:ConfPlnrWeb

如果我要添加发布任务,我会看到 Publish Build Artifacts 任务:

If I were to add a task for publishing I saw the Publish Build Artifacts task:

但如下所示的设置似乎都与变换无关:

But none of the settings as shown below seem to relate to transforms:

最重要的问题是:我如何配置构建,以便 web 项目上传应用正确的 web 转换?

更新:在下面的答案之后添加的以下内容导致至少有一个地方可以在构建期间应用 VS 转换,并且可能也是一个版本.

Update: The following added after the answer below led to at least one place where VS transforms can be applied during a build, and presumably also a release.

在 MSBuild Build 解决方案任务中设置如下所示的配置:

Inside the MSBuild Build solution task set the Configuration as shown below:

推荐答案

Publish Build Artifacts 任务用于发布相关工件(a"工作目录包含工件(也称为drop")在构建结束时上传)到 Visual Studio Team Services/TFS 或文件共享.

Publish Build Artifacts task is used to publish the related artifacts ( The "a" working directory contains the artifacts (also known as the "drop") that are uploaded at the end of the build) to Visual Studio Team Services/TFS or a file share.

通常它应该是一个包并用于部署任务,例如 部署:WinRM - IIS Web 应用部署Azure App Service Deployment 实现部署.

Usually it should be a package and be used in a deploy task such as Deploy: WinRM - IIS Web App Deployment or Azure App Service Deployment to achieved the deployment.

1) 转换可以同时用于构建和发布吗?

1) Can transforms be engaged in both Builds and Releases?

是的,您也可以使用构建部署任务在构建管道中执行此操作.您需要在发布构建工件任务之后添加该任务.

2) TFS 2017 是否需要大量特殊处理才能使用转换文件?

2) Does TFS 2017 require a lot of special handling to engage a transform file?

更新

TFS 2017 中的 BuildConfiguration 变量不同,它在里面MSBuild 任务!变换现在根据到 MSBuild 任务配置设置.

The BuildConfiguration variable is different in TFS 2017, it's inside the MSBuild task! Transforms are now applied according to the MSBuild task Configuration setting.

编辑 .proj 文件是一种进行转换的方法.如果您不需要更改转换,它将在构建期间自动执行.您还可以使用一些 3-rd 方任务/扩展进行额外转换,例如:XDT 变换

Edit the .proj file is a method to do the transform. If you don't need to change the transform, it will auto do it during the build.You could also use some 3-rd party task/extension for extra transform such as: XDT Transform

通常我们将构建和发布分开进行部署,因为易于配置多个环境并且易于调试问题.您绝对可以仅在构建中执行此操作,但过程臃肿.您可以参考本教程:使用 Team Foundation Server/Services vNext Builds 构建和部署 Azure Web 应用程序.

Usually we separate the build and release for the deployment, cause it's easy to configure multiple environments and easy to debug issue. You definitely could do this only in build but with a bloated process. You could refer this tutorial: Build and Deploy Azure Web Apps using Team Foundation Server/Services vNext Builds.

对于单独的构建和发布解决方案,您可以查看此博客:使用 web.config 转换和发布管理器 - TFS 2017/团队服务版

For a separate build and release solution, you could take a look at this blog: Using web.config transforms and Release Manager – TFS 2017/Team Services edition

这篇关于什么 TFS 2017 构建任务在 TFS 构建期间应用 web.config 转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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