Question

In the project I've inherited, the original developer used a number of post-build events in his Visual Studio projects to copy around DLL's and stuff when building inside VS.

This is causing some grief now that I'm trying to move these things to the TFS 2010 Build system.

I was hoping to be able to create a new "Continuous" project configuration, and exclude those post-build events from Visual Studio in that configuration - but it seems those calls aren't configurable based on your project configuration....

Any ideas? Is there something I could check for to know I'm running under TFS Build and then just skip those CMD files? Any ideas would be most welcome!

Was it helpful?

Solution

What if you set an environment variable on your team build server, and then you could write a check into your post build steps to check for that environment variable. If the environment variable is set, you'd know to skip the command files that do the post build steps because you'd know you are running under TFS build.

You could combine all your post build steps into one script possibly, and then just check the environment variable at the beginning of that script.

Or you may be able to do it the opposite way and build the check into your TFS build script. You can refer here for how to check an environment variable in a TFS build.

So in your TFS build script you'd have something like:

<RunScripts Condition=" '$(RunScriptsServerVar)' != '' ">
            the environment var is NOT set, so run your scripts since we aren't in
            a TFS build
</RunScripts>

OTHER TIPS

My approach is to guard the pre- or post-build code with this

IF "$(BuildingInsideVisualStudio)"=="true" ( …your code here… )

That variable is automatically defined by Visual Studio and you do not need to change the build definition.

I use a similar approach to do this. I add the following to each project's post-build steps:

if '$(TeamBuild)'=='True' exit 0

Then when configuring the Build Definition I simply add:

/p:TeamBuild=True

...to the MSBuild Arguments.

This gives me the flexibility to keep all the configuration in the projects and the build definition.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top