Search code examples
visual-studio-2013tfstfsbuild

Detect TFS Build vs. Visual Studio build


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.


Solution

  • 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.