Somewhat hypothetical/heuristical answer:
Why is that?
I think this is primarily to avoid warning MSB8028 ("The intermediate directory (shared-intermediate-path) contains files shared from another project (intermediate-path).")
If so, this somewhat poorly executed, since putting projects in subdirectories does not guarantee they do not share intermediate directories. But I understand the assumption may be that projects are put into individual subdirectories, and in that case the changed behavior does make sense to avoid one level of intermediate directories.
Where is this documented?
I am still looking for anything written. However, I noticed that the Visual Studio IDE correctly shows the default value of "Intermediate Directory" to be different for the two projects in the solution file:
Note the addition of $(ShortProjectName)
. So at least this is consistent.
So one should probably note that MSBuild
uses $(ShortProjectName)\$(Platform)\$(Configuration)\
as a default Intermediate Directory for *.sln
root projects as well as when compiling individual *.vcxproj
files.
How can I configure this to stay constant?
Given the previous answer, the solution is straightforward: by overwriting the default value of Intermediate Directory, e.g., in each vcxproj
file or, somewhat more elegantly, using a shared property or even a Directory.build.props
file:
<?xml version = "1.0" encoding="utf-8"?>
<Project ToolsVersion = "4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- https://stackoverflow.com/q/79199847/ -->
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
</Project>