简体   繁体   中英

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

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)

我可以通过将所有引用的项目包括到解决方案中来解决类似的问题-在这种情况下,将项目Y包括到解决方案B中。

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>

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.

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.

由于缺少rep,我无法添加评论,但是按照user1825216的回答,我从命令行运行MSBuild,因此我通过在-p:Platform=x64而非build命令中解决了此错误修改.vcxproj。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM