error MSB8013 with C++ project reference

JW 61 Reputation points
2022-06-08T09:12:28.537+00:00

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?

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,527 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,001 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.1K Reputation points
    2022-06-08T09:58:05.367+00:00

    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful