How can I make a project build behave different on 1) (local) compile inside Visual Studio and 2) triggered by TFS Build Server on TF Build Agent?
I tried (both without success)
<PropertyGroup Condition="'$(TF_BUILD)' == 'true' AND '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true' AND '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
I have (in both cases) created 2 such property groups with == and != swapped on the first condition (the one that should result in different behavior) and different content in the PropertyGroup (which is what I am really aiming for).
I am using VS 2017 and TFS 2017.
edit/update:
I found the mistake in my ways, it was that I edited the AnyCPU PropertyGoup and built x86.
Actually, all of this works, including Daniel Mann's suggestion. I was using it on the wrong propertygroup.
Since I found this information hard to find, I hope this summary helps someone in the future.
Different property values on TF and local (VS) build can be written like
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
<Optimize Condition="'$(BUILD_SOURCESDIRECTORY)' != ''">true</Optimize>
<Optimize Condition="'$(TF_BUILD)' != 'true'">false</Optimize>
..redundant..
<Optimize Condition="'$(BuildingInsideVisualStudio)' == 'false'">true</Optimize>
...
</PropertyGroup>
So on TFS Build the following conditions should be true (and false in Visual Studio):
$(BUILD_SOURCESDIRECTORY) != ''
$(TF_BUILD) == 'true'
$(BuildingInsideVisualStudio)' != 'true'