I have a solution in Visual Studio 16.8.3 (Enterprise 2019). Projects of the solution have settings that depend on the value of the environment variable OPTIMIZE
. Something like the following (other settings are omitted):
<ItemDefinitionGroup Condition="'$(OPTIMIZE)' == 'TRUE'">
<ClCompile>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile>
</ItemDefinitionGroup>
...
<ItemDefinitionGroup Condition="'$(OPTIMIZE)' != 'TRUE'">
<ClCompile>
<WholeProgramOptimization>false</WholeProgramOptimization>
</ClCompile>
</ItemDefinitionGroup>
I set OPTMIZE=TRUE
and build the solution. Then I close VS, set OPTIMIZE=FALSE
, open VS. Now I'm expecting that the whole solution will be rebuilt since every cpp's file compilation settings changed. But when I press Build Solution
, nothing happens. When I right-click the project in the Solution Explorer and press Build
, nothing happens again.
But, when I select any cpp file in any project and compile it, then the project somehow understands that the settings for all its cpp files changed. Now if I right-click the project in the Solution Explorer, and press Build
, the whole project is rebuilt.
I want the project to understand that the settings changed when I change the value of the environment variable. How can I achieve this behavior?
P.S. Of course, I can use Rebuild Solution
if I know the settings changed. But I don't want to keep in mind if the value of the OPTIMIZE
variable changed since the last build. I would like just to press Build Solution
and have a small incremental build if there were no changes and a complete rebuild if the settings changed.