It seems that the corresponding information is stored in the .sln file, therefore you can specify the solution file instead of MainProject.vcxproj. Use Configuration Manager in Visual Studio to manage the configurations, without affecting the static library.
error MSB8013 with C++ project reference
I have a main project with a reference to another project (a static library). The main project has multiple release configurations and the referenced project has a single release configuration.
Building the main project in Visual Studio works fine (both project belongs to the same solution), but with MSBuild it says "error MSB8013".
[MainProject trunk] $ cmd.exe /C " chcp 1252 & "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\msbuild.exe" /p:CL_MPCount=6 "/p:Configuration=Release Config2" /p:Platform=x64 MainProject.vcxproj " && exit %%ERRORLEVEL%%
Active code page: 1252
Microsoft (R) Build Engine version 17.2.1+52cd2da31 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 2022-06-08 09:29:59.
Project "C:\Program Files (x86)\Jenkins\workspace\MainProject trunk\MainProject.vcxproj" on node 1 (default targets).
Project "C:\Program Files (x86)\Jenkins\workspace\MainProject trunk\MainProject.vcxproj" (1) is building "C:\Program Files (x86)\Jenkins\workspace\MainProject trunk\Libs\LibProject\LibProject.vcxproj" (2) on node 1 (default targets).
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(437,5): error MSB8013: This project doesn't contain the Configuration and Platform combination of Release Config2|x64.
MSBuild seems to assume that the configuration name is the same for both projects. I suppose I could add more configurations to match the names, but that's a really ugly solution. Is there anyway to specify the configuration name for the referenced project, or how can I get around this?