0

Now that my TFS builds are starting to work after our DLL hell issues. I am tasked with figuring out how to deploy specific images to specific environments.

I am currently trying to see if TFS allows ignoring files based on configuration out of the box. Otherwise does anyone know a way using the web.config to change what images are read based on which environment I'm in. I am an SCM with very little DEV experience and my TFS experience says there's no way to do this without writing a custom build script. Asking because I realize my experience isn't complete.

Any help would be amazing thank you for your time!

rmccoy
  • 1
  • 2

1 Answers1

0

This is one of those misleading topics: packaging and deploying web applications (deduced from the reference to web.config, correct me if I am wrong).

Packaging and deploy

TFS is agnostic toward the kind of code you are compiling, so you have to instruct the "Visual Studio" build system that is invoked by TFS to compile in the MSBuild step.

In the ALM Rangers' Build Guidance there are specific section on this. In the web-app case one typically set MSBuild arguments to something like

/p:DeployOnBuild=True /p:Configuration=QA /p:DeployIisAppPath="web.qa.contoso.com" /p:DeployTarget=Package

to get a Zip file, to be used with WebDeploy.

Selecting content

In case you need different content to create different packages, there is a simple neat trick for TFVC (don't work with Git). Say you want to have a QA package and a Production package with two different JPGs (or keys to sign, or certificates, whatever). The two version of the file are $/MyProj/Special/Prod.jpg and $/MyProj/Special/QA.jpg. Create two TFS Build Definitions, and map this way

| Build | Status | Source Control Path        | Build Agent Path              |
|-------|--------|----------------------------|-------------------------------|
| QA    | Active | $/MyProj                   | $(SourceDir)\                 |
| QA    | Cloak  | $/MyProj/Special           |                               |
| QA    | Active | $/MyProj/Special/QA.jpg    | $(SourceDir)\Special\logo.jpg |
|-------|--------|----------------------------|-------------------------------|
| Prod  | Active | $/MyProj                   | $(SourceDir)\                 |
| Prod  | Cloak  | $/MyProj/Special           |                               |
| Prod  | Active | $/MyProj/Special/Prod.jpg  | $(SourceDir)\Special\logo.jpg |
Giulio Vian
  • 8,248
  • 2
  • 33
  • 41
  • I am new to the forums and how these are handled. I tried to address the brunt of the problem but I will lay it out in specifics. Our Dev's use an image to remind users that the environment they are in is the Test environment. This image obviously doesnt need to go to production. My worry comes with deploying to these environments and specifically avoiding that image. I feel like a TFS solution for this is a lot more complicated and would be the equivalent of using a machine gun to kill a fly versus a DEV solution that simply switched images based on environments. – rmccoy Aug 28 '14 at 18:00
  • At other companies I've seen them use flags in a db or the code and I've heard this may be doable with a flag in the web.config file. Our current TFS build arguments look as follows (and I apologize if they are terribly simplistic but so far with the projects that have been converted from WSP's to WAP's this seems to be the only working way to deploy them): /p:DeployOnBuild=true /p:VisualStudioVersion=12.0 /p:DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir=\\destination address – rmccoy Aug 28 '14 at 18:04
  • Awesome! I didn't realize it was that simple Giulio! One question though my understanding is that the cloak will make the folder be seen as in flux and not to be deployed. What happens when I need the other files from that folder deployed as well. Say for instance a new JPG has been added to our static JPG's or in the case of deploying to a brand new server. – rmccoy Aug 28 '14 at 18:29
  • You can cloak even a single file (in that example $/MyProj/Special/logo.jpg), but for you sanity is better to contract a schema with your developers: probably they can rearrange the path in way that is meaningful to both sides. – Giulio Vian Aug 28 '14 at 19:17
  • Giulio sorry to follow up so late but it took a while to convince my devs to give this a try. Now we are looking at this error when we build using the suggested format: 2>Done Building Project "Project File" (default targets) -- FAILED. 1>Done Building Project "Solution File" (default targets) -- FAILED. Once I remove the line the build works so its not the build in general. Is there anything I should be looking for as a common errors list looking at this. – rmccoy Sep 24 '14 at 17:40
  • Not sure if SO can help, but post a question with error details and context: none can read you screen (mind) if you do not share it. – Giulio Vian Sep 25 '14 at 06:36
  • Sorry for the vague answer with the build log its a lot of file names etc so I was hoping maybe this was a common error. I will try to clean the text and post it shortly. – rmccoy Sep 25 '14 at 10:22