x64 build: error MSB8013: This project doesn't contain the Configuration and Platform combination of Debug|Win32
Asked Answered
S

5

19

I'm trying to get a pure x64 build running for a complex build with many solutions (some for CI, some for devs) and hundreds of project and have run into "error MSB8013: This project doesn't contain the Configuration and Platform combination of Debug|Win32"

I've reduced it to a simple configuration:

  • Solution A contains Project X & Project Y. Project X has a project reference to Project Y.
  • Solution B contains also contains Project X.

None of the projects or solutions contain a Win32 platform - it's been deleted.

When I build solution B (as x64), I receive

error MSB8013: This project doesn't contain the Configuration and Platform combination of Debug|Win32

The error message sometimes contains additional information:

This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform.

The problem is the referencing project does "build using the same or an equivalent Configuration or Platform."

Looking at the msbuild diagnostic, project Y is being built because project X contains a project reference to it. But the configuration and platform properties are being deleted just before project Y is built:

1>Task "MSBuild" (TaskId:28)
1>  Removing Properties: (TaskId:28)
1>    Configuration (TaskId:28)
1>    Platform (TaskId:28)

As a result Microsoft.Cpp.Default.props kicks in and sets these to Debug|Win32:

1>Task "Message" (TaskId:11)
1>  Configuration=Debug (TaskId:11)
1>Done executing task "Message". (TaskId:11)
1>Task "Message" (TaskId:12)
1>  Platform=Win32 (TaskId:12)
1>Done executing task "Message". (TaskId:12)

How can I prevent this and make msbuild pass the chosen configuration & platform?

(I understand the ultimate solution to use NuGet to manage package dependencies, but that isn't feasible in the short term)

Seymourseys answered 15/10, 2015 at 18:43 Comment(0)
U
16

I could resolve a similar issue by including all referenced projects into the solution - in this case including Project Y into solution B.

Urbanist answered 27/5, 2016 at 11:33 Comment(1)
I had some broken project references, adding the projects to the solution and updating the references fixed the problem. Thanks!Cardamom
P
4

It seems it is a bug in Microsoft.CppBuild.targets file. On some machines I see two such files: one in C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets with ~120KB size, and C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets with 77KB size. Second one is buggy and gets wrong $(Configuration)|$(Platform) value which yields mentioned error. This problem is probably directly connected with this topic, as VCTargetsPath in my projects pointed into wrong (77KB) Microsoft.CppBuild.targets directory (I use VS2015 so it should use the one from V140 directory). I found two workarounds: 1) replace buggy file or 2) modify HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\14.0\14.0\VCTargetsPath10 registry to point right file.

Pilotage answered 5/4, 2017 at 10:11 Comment(0)
S
3

One fix is to hand edit the .vcxproj files to define the default platform:

  1. Open the vcxproj file in a text editor
  2. Add this line in the "Globals" PropertyGroup:

    <Platform Condition="'$(Platform)' == ''">x64</Platform>

Seymourseys answered 15/10, 2015 at 22:32 Comment(1)
It works for me by visual studio, modiyfing "project configurations" and adding "x64"Placidia
C
3

I couldn't add a comment because of lack of rep, but in the same vein of user1825216's answer, I'm running MSBuild from a command line so I resolved this error by adding -p:Platform=x64 to the build command instead of modifying the .vcxproj.

Comportment answered 30/5, 2019 at 14:27 Comment(0)
B
1

I find it difficult to see what you're trying to achieve through this. Do you always want to build X AND Y? Even in the solution that has no reference to Y? Would be fairly illogical to me. Though, I can offer you some solutions to fixing / supressing this issue, based on what you want.

If you want to build X&Y with A and X with B

In Solution A, set the other project as a build dependency, instead of referencing project Y in project X. You can't set it as long as it refers to the other project (I always remove the reference in the .vcxproj, it's somewhere at the bottom of the project), but once you removed the inner project reference, you can have the solution reference to it and then it should work just fine.

When you build Solution A with MSBuild, it'll build X AND Y, while building solution B with MSBuild

Else

If you want to build X&Y with either solution

Sorry, but that's not really possible within MSBuild at the moment. I'd recommend adding project Y to the solution and referencing it, but then, why would you? You already have a project that has them both included, and if you want different outputs, you can easily make different configurations.

Bui answered 19/4, 2017 at 11:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.