I want to build a .vcxproj via MSBuild from outside Visual Studio. The problem is that there are many occurrences of $(SolutionDir) inside the .vcxproj file which apparently onl
The solution to explicitly pass SolutionDir
as an argument is insufficient for me.
Namely, if the project I want to build has dependencies with different build configurations, the build fails with a This project doesn't contain the Configuration and Platform combination of
error.
This makes sense, since I didn't specify the target configuration for the dependencies and thus it tries to target same configuration as the project I'm building, which they don't have (in my case).
Since a solution file contains the build configurations for all projects in the solution (given some solution-configuration), we want to make use of this solution to solve this problem. Luckily, MSBuild allows us to build a solution and pass a specific target project as argument, which will only cause that project to be build (together with its dependencies).
msbuild MySolution.sln /t:MyProject