0
votes

I am trying to set up a Build on an on premise Team Foundation Server 2015 using web.config transformations. The transformations work fine based on the build configuration I select. I have 3 build configurations: Debug, Release, and one that I created, called "Staging". I am trying to make it so I can re-use the same Build for different environments by setting the $(BuildConfiguration) variable at queue time. In my TFS build's "Visual Studio Build" step, when I set the $(BuildConfiguration) to "debug" the build is output to the agent folder like this: $(Build.SourcesDirectory)\projectFolder\obj\Debug\Package\PackageTmp. If I set it to "release", then it goes to $(Build.SourcesDirectory)\projectFolder\obj\Release\Package\PackageTmp. In both cases the Web.config file is transformed correctly.

However, if I set the build configuration to "Staging", the files are still placed in the "debug" folder $(Build.SourcesDirectory)\projectFolder\obj\Debug\Package\PackageTmp instead of a "Staging" folder. (Transformations also work fine in this case, and use the staging values)

This creates a problem in my "Copy Files" step. I have the "Source Folder" value in that step to $(Build.SourcesDirectory)\projectFolder\obj\ $(BuildConfiguration) \Package\PackageTmp, but when using "Staging", it cannot find the source folder because TFS is placing the build files in the "Debug" folder.

Is there a way to force TFS to place the built items (my web app files, basically) in a folder matching the build configuration parameter, in this case, "Staging"?

1

1 Answers

0
votes

A note: It's best to not use web.config transformations, but to build once and allow your web.config to be transformed at deployment time (either by injecting appropriate values or by using MSDeploy parameters).

That said, you can control the output folder with the /p:OutDir= MSBuild argument.

I suspect, however, that you just need to open up your project settings in Visual Studio, go to the Build tab, and set an appropriately-named output folder there.