Reputation: 711
Is it possible to detect whether or not the current build is executing from Visual Studio rather than an automated build with TFS without creating a separate solution configuration? I'm wondering if I can exclude certain Post Build Events if the build is running on TFS 2013, but if possible I would like to avoid a whole separate configuration.
Upvotes: 5
Views: 2191
Reputation: 8343
You do not need to edit the CSProj file: just use CMD.EXE syntax in Visual Studio Post-Build events
You can test if running inside Visual Studio
IF "$(BuildingInsideVisualStudio)"=="true" (
…
)
or inside TFS Build (2013 or later)
IF "$(TF_BUILD)"=="True" (
…
)
See the discussion a TFS 2010 Build Automation and post-build event and Team Foundation Build environment variables.
Upvotes: 8
Reputation: 711
It is possible, and I finally found out how:
Locate the PostBuildEvent XML element, and add a Condition attribute like the following:
<PostBuildEvent Condition="'$(BuildingInsideVisualStudio)' == 'true'">
At this point the PostBuildEvent will only execute when built with Visual Studio.
This answer and other answers to that question were helpful.
This particular property is briefly mentioned on this MSDN page as well.
Upvotes: 3