Rather than building to the default folder structure, which is like
Solution.sln
Project1
bin <- project 1 output
obj <- project 1 intermediate output
Project2
bin <- project 2 output
obj <- project 2 intermediate output
I instead want to build it like
Solution.sln
bin <- project 1 AND 2 output
obj
Project1 <- project 1 intermediate output
Project2 <- project 2 intermediate output
I can do
msbuild "/p:OutputPath=../bin" "/p:IntermediateOutputPath=../obj/" Test123.sln
However, using "/p:IntermediateOutputPath=../obj/$(ProjectName)/"
does not work. Instead of creating a folder for each project, it creates one folder literally called $(ProjectName)
(I've read that most, but not all of these macros are actually a Visual Studio thing, rather than MSBuild magic).
How can I use a project-specific value (such as ProjectName
) in a property value (such as IntermediateOutputPath
) when building?
(Some background information:
Having one bin
folder on the solution level saves unnecessary copying of output files, which quickly amass over 100 MB in large solutions. Furthermore, it keeps the source folders clean so they can be read-only.
I still want separate obj
folders though, because who knows what goes in there - might be the same file names for different projects.)