Q:

How to keep dcu files in per project folder (e.g.: .\$(Platform)\$(Config)\$(ProjectFilename)?

I have lot of Delphi projects in a project group.   I can set Unit output directory to .\$(Platform)\$(Config) and all dcu files  will keep in the directory according to platform and config value.
In my build environment, I would like to set the Unit output directory to something like  .\$(Platform)\$(Config)\$(ProjectFilename) so all DCU files shall keep in it's own directory identified by current project file.
The Build Events in Project | Options has $(ProjectFilename) macro but I can't use it in Unit output directory.
I want to set .\$(Platform)\$(Config)\$(ProjectFilename) to all projects' Unit output directory and it will keep all DCU files in unique project directory.

A:

I found this answer coincidentally.  I pick one project and (ms)build with verbosity of diagnostic.  By studying the output of msbuild, I simply pick a variable: MSBuildProjectName and specify in my optset file shared by 300 projects:
<DCC_DcuOutput>.\$(Platform)\$(Config)\$(MSBuildProjectName)</DCC_DcuOutput>

And I try build all projects in IDE.  Amazingly, Delphi create folders for each project built and keep the DCU files in the folders respectively.

