1

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

Alan
  • 1,587
  • 3
  • 23
  • 43
  • Those are a lot of questions in one topic. Maybe you should devide the transform and the publish parts in separate posts? For the publish part you should provide at least some detail what you want to publish where. – Flex Nov 15 '17 at 08:43

1 Answers1

2

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

Andrew
  • 5,215
  • 1
  • 23
  • 42
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • 1
    Will study your links today; follow ups: `1)` you said use `build deploy task`. What is that task's precise name in TFS so I can 1st get familiar with invoking transforms on a build agent? But I will at your suggestion start using `Release`. Please help my understanding with this question: `2)` For each environment I create in `Release`, am I simply creating the exact same process as I do when creating a single `Build`? For reference, my current hosting environment is very simple, a web location where I simply deposit the website files, but those files must 1st be transformed. – Alan Nov 15 '17 at 12:18
  • 1
    Hi @Alan 1)you could either use the deploy task both in build and release, there are multiple tasks such as Deploy: WinRM - IIS Web App Deployment or Azure App Service Deployment. 2)For release you don't have to use the build tasks any more, you should use some other tasks such as replace token (if you have ) , deploy task. and for environment you could use the same task, or customize for each one. For the entire process, suggest you refer the blog above: https://blogs.msdn.microsoft.com/alming/2017/02/09/using-web-config-transforms-and-release-manager-tfs-2017team-services-edition/ – PatrickLu-MSFT Nov 15 '17 at 13:52
  • Your links absolutely helped me & a simple but massively important question is answered: `How do we apply VS transform files during a TFS Build?`. I had to read Silva's article over & over to finally see the difference between TFS 2015/17. The `BuildConfiguration` variable is different in TFS 2017, it's inside the `MSBuild task` - I missed it! Transforms are now applied according to the `MSBuild` task `Configuration` setting. Still more to do. Changing post title to better match the real issue. You might add to your answer it's the MSBuild task that applies the transforms. – Alan Nov 15 '17 at 18:20