TFS 2010 Build Automation and post-build event

ε祈祈猫儿з 提交于 2019-11-30 01:53:40

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>
Giulio Vian

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!