1

Our C# solution has a couple of folders that are populated via post-build events (i.e. they are initially empty).

The solution builds fine locally, however when using the TFS build agent, the folders don't show up in the published websites folder.

Any suggestions on how to force TFS to copy the folders over?

sazh
  • 1,792
  • 15
  • 20

1 Answers1

4

This is addressed here: publish empty directories to a web application in VS2010 web project

TFS does not execute the AfterBuild target of your proj file. I believe it will execute the AfterCompile target but this still might not do what you want.

I have used the approach of including dummy files which is simple enough even though its lame.

I've tried the approach of including a powershell script to do some post-publish tasks which works.

More recently I have adopted a convention of including a supplemental MSBuild file that ends in ".package.proj" and added an additional MSBuild execution activity to my Team Build Template that looks for it after the files are dropped to the drop location and then executes it. This provides a simple hook into the Team Build workflow without getting you deep into changing the workflow for a particular build. It's just a single additional activity wrapped in a conditional that looks for the file. If found, execute it.

You could also make a custom build template and use the Workflow activities to perform various cleanup tasks, but it's probably overkill and will increase maintenance on the build templates. Better to keep the customization simple if you can and have it function in a way that doesn't require "opt-out" configuration on builds that don't require the customization. Existing vanilla builds should continue to work as expected after the customization to the template.

Community
  • 1
  • 1
jayint32
  • 1,132
  • 8
  • 12
  • We were trying to avoid the dummy files too :). I'll try the supplemental MSBuild file - thanks again for the link! – sazh Mar 09 '12 at 18:12
  • There are a few nice things about the msbuild file approach. If necessary you can use the same file locally as in TFS. You can wire your AfterBuild target with an MSBuild "MSBuild" task to execute it and then use the MSBuild Activity in your Team Build Process template. It also minimizes the variety of technologies you have to get involved with. You're already building with MSBuild anyway, this just supplements it. By keeping things in a separate MSBuild file you'll make your life a bit easier than trying to edit your csproj or whatever which involves unloading and reloading, etc.Good luck. – jayint32 Mar 09 '12 at 19:34
  • 1
    Nice, I've been using the dummy files which always feels dirty but got the job done. Will try this next time! – Rich Feb 22 '16 at 11:51