Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS 2010 Build Automation and post-build event

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!

like image 238
marc_s Avatar asked Feb 21 '11 17:02

marc_s


People also ask

What is post build event?

Event Macros We use post build events when we wish to perform an operation after the build is successful.

What is post build?

Post build is used to update parts of the configuration after compile time and is typically used by the OEM. The post build parameters are located in a separate memory area which may be replaced by a new configuration that may be downloaded independently of the other parts for the ECU software.

What are build events Visual Studio?

MSBuild is the build engine that Visual Studio uses to process your project file when it performs a build. A build event in the IDE results in an MSBuild target in the project file. You can use any MSBuild property that is available in the target in your project file (for example, $(OutDir) or $(Configuration) ) .


3 Answers

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.

like image 82
Giulio Vian Avatar answered Nov 16 '22 00:11

Giulio Vian


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.

like image 23
harlam357 Avatar answered Nov 15 '22 23:11

harlam357


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>
like image 25
dcp Avatar answered Nov 15 '22 23:11

dcp