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.
Visual Studio determines the build order and calls into MSBuild separately (as needed), all completely under Visual Studio's control. Another difference arises when MSBuild is invoked with a solution file, MSBuild parses the solution file, creates a standard XML input file, evaluates it, and executes it as a project.
Team Foundation Server (TFS) is an ALM product from Microsoft which provides the capabilities for an end-to-end development and testing using Work Item Management, Project Planning (Waterfall or Scrum), Version Control, Build/Release (Deploy) and Testing capabilities.
This topic describes how to prepare a Team Foundation Server (TFS) build server to build and deploy your solutions using Team Build and the Internet Information Services (IIS) Web Deployment Tool (Web Deploy).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With