Currently, I have the following MSBuild command:
msbuild
/t:Build
/p:Configuration=Release
/p:OutputPath=C:\MySolutionOutput\
MySolution.sln
Which compiles, however, I have multiple projects in my solution. When I do a build this way with the solution file, it copies all project outputs to the same directory, and the output from Project2 overwrites the output from Project1 (or whatever order they're built in).
Instead, I want MSBuild to put each project into a subfolder of the project name.
msbuild
/t:Build
/p:Configuration=Release
/p:OutputPath=C:\MySolutionOutput\$(ProjectName)
MySolution.sln
However, the $(ProjectName) syntax does not work as it literally makes a folder called $(ProjectName).
How do I make MSBuild solution building output each project to a subdirectory of the OutputPath, preferably without making MSBuild xml files, or building each project individually?
To illustrate further, my projects are as follows.
+ Project 1
+ File1.txt
+ File2.txt
+ ReadMe.txt
+ Project 2
+ File3.txt
+ File4.txt
+ ReadMe.txt
What my build outputs
C:\MySolutionOutput\File1.txt
C:\MySolutionOutput\File2.txt
C:\MySolutionOutput\File3.txt
C:\MySolutionOutput\File4.txt
C:\MySolutionOutput\ReadMe.txt
^-- (this is the 2nd readme, project 1's readme gets overwritten)
What I want
C:\MySolutionOutput\Project 1\File1.txt
C:\MySolutionOutput\Project 1\File2.txt
C:\MySolutionOutput\Project 1\ReadMe.txt
C:\MySolutionOutput\Project 2\File3.txt
C:\MySolutionOutput\Project 2\File4.txt
C:\MySolutionOutput\Project 2\ReadMe.txt