msbuildvisual-studio-2017web.config-transformbuild-agent

What TFS 2017 build task applies web.config transforms during TFS builds?


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:

enter image description here

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:

enter image description here

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:

enter image description here

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

enter image description here

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:

enter image description here


Solution

  • 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