在TFS生成期间,哪些TFS 2017生成任务会应用web.config转换? [英] What TFS 2017 build task applies web.config transforms during TFS builds?

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

问题描述

对某些原始信息进行了更改,使该帖子在被发现后更加关注真实的问题。



这些是当前环境的一些详细信息。我之所以列出这些内容,仅是因为在其他帖子中提出了问题,以确定在当前环境下哪些是有效的,哪些是无效的:

  -in TFS 2017在构建代理上成功构建了一个Web项目。 
VS 2017发布配置文件可以正确地手动转换项目
生成机器工件的位置包括转换文件和配置文件

工件位置如下所示:





我已经在Microsoft的VS网站,SO和其他论坛上对此进行了深入研究,但是答案太多了,其中许多是针对较旧版本的,我无法将其拼凑起来。结果,我有几个子问题。



1)转换可以同时用于构建和发布吗?。我读到,转换是在发布过程中应用的,而不是在构建过程中应用的,这使我想知道是否有可能在构建过程中执行此操作。但是当我浏览发行版时,我看到了所有在Build中可用的相同任务,这表明我可以在Build或Release中使用转换来发布。



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



以下信息是名为 confPanner-CI。阴影的PS脚本已成功用于上载到托管位置以测试整个过程,但这不足以应付需要应用转换的手头任务:





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

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

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





但以下设置均不显示s与转换相关的eem:



解决方案

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



通常,它应该是一个软件包,并用于部署任务,例如部署:WinRM-IIS Web应用程序部署 Azure App Service部署以实现部署。



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



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



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


更新



BuildConfiguration变量在以下方面有所不同在TFS 2017中,它位于 MSBuild任务
内!现在根据
将转换应用于MSBuild任务配置设置。


编辑 .proj 文件是执行转换的一种方法。如果不需要更改转换,它将在构建过程中自动执行。您还可以使用第三方任务/扩展进行额外的转换,例如: XDT转换



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



单独构建和发布解决方案,您可以看一下此博客:使用web.config转换和Release Manager – TFS 2017 / Team Services版


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

The artifact location is shown below:

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) 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) 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.

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:

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

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:

The bottom line question is: How do I configure the build so the web project upload has the proper web transform applied?

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.

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

解决方案

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.

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) Can transforms be engaged in both Builds and Releases?

Yes, you could also do this in a build pipeline with the useage of build deploy task. You need to add the task after the publish build artifacts task.

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

update

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.

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

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.

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生成期间,哪些TFS 2017生成任务会应用web.config转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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