79202417

Date: 2024-11-19 07:23:04
Score: 0.5
Natty:
Report link

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:

enter image description here

enter image description here

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>
Reasons:
  • Blacklisted phrase (1): this document
  • Blacklisted phrase (0.5): How can I
  • Blacklisted phrase (1): stackoverflow
  • Whitelisted phrase (-1): solution is
  • RegEx Blacklisted phrase (0.5): Why is that
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Self-answer (0.5):
  • High reputation (-1):
Posted by: bers