简体   繁体   English

VS2017加载手动配置为x86的C++项目作为VS2010项目

[英]VS2017 loads C++ project that was manually configured to x86 as a VS2010 project

I just changed a vcxproj file (C++) to have x86 as a platform for all solution build configurations instead of Win32, which seems to be the default for all C++ projects.我刚刚更改了一个 vcxproj 文件 (C++),将 x86 作为所有解决方案构建配置的平台,而不是 Win32,这似乎是所有 C++ 项目的默认设置。 The project loads fine but it shows up as a VS 2010 project in solution explorer.该项目加载良好,但它在解决方案资源管理器中显示为 VS 2010 项目。 Based on discussions with my coworkers, my underlying assumption is that Win32 is identical to x86, but is an old tag for the platform, and that it would be better to remove it and replace it with x86.根据与我的同事的讨论,我的基本假设是 Win32 与 x86 相同,但它是该平台的旧标签,最好将其删除并替换为 x86。 I have looked online for similar questions, and while I did find similar issues, the suggestions didn't seem to help.我在网上寻找类似的问题,虽然我确实发现了类似的问题,但这些建议似乎没有帮助。

The chain of events that prompted making this change is that we are currently starting an effort to modernize our software and processes, and part of this is to prepare for our build process eventually getting pushed onto a virtual machine as I set up a smoke test for the development team.促使进行此更改的一系列事件是我们目前正在努力使我们的软件和流程现代化,其中一部分是为我们的构建过程做好准备,最终在我为开发团队。 Unfortunately, we have been using devenv.exe on an instance of CruiseControl.NET to do our installer builds;不幸的是,我们一直在 CruiseControl.NET 实例上使用 devenv.exe 来构建安装程序; so, for the smoke test I have been tasked with getting MSBuild to work on our software so we can use that directly and not have the full VS IDE loaded on the VM.所以,对于冒烟测试,我的任务是让 MSBuild 在我们的软件上工作,这样我们就可以直接使用它,而不是在 VM 上加载完整的 VS IDE。

To my horror, I have slowly learned over the last couple months that VS and MSBuild are not consistent with each other.令我震惊的是,在过去的几个月里,我慢慢了解到 VS 和 MSBuild 彼此不一致。 MSBuild without the guiding hand of VS will not honor a build order, and so will often build projects and try to link it's dependencies before building the dependencies.没有 VS 指导的 MSBuild 不会遵守构建顺序,因此通常会构建项目并在构建依赖项之前尝试链接它的依赖项。 It will also fail when projects try to access the same resource rather than just blocking.当项目尝试访问相同的资源而不仅仅是阻塞时,它也会失败。 These problems together have brought me to break apart our build by project in our CCNet script instead of just building the solution file.这些问题一起让我在 CCNet 脚本中按项目分解我们的构建,而不仅仅是构建解决方案文件。

The place where the particular flavor of the problem in question stems from, is that MSBuild will look in the project references and attempt to build those dependencies with the parent project's configuration and platform super-imposed upon them.所讨论问题的特殊之处在于,MSBuild 将查看项目引用并尝试使用父项目的配置和叠加在其上的平台来构建这些依赖项。 It seems that C# projects have x86 as their default platform while C++ has Win32.似乎 C# 项目将 x86 作为其默认平台,而 C++ 具有 Win32。 Our software is a C#/C++/CLI Frankenstein monster, and having inconsistent project platforms is wreaking havoc on my efforts.我们的软件是 C#/C++/CLI Frankenstein 怪物,不一致的项目平台对我的工作造成了严重破坏。 MSBuild also appears to always try building our x86 platform projects with 2010 build tools for some odd reason.由于某些奇怪的原因,MSBuild 似乎总是尝试使用 2010 构建工具构建我们的 x86 平台项目。 This fails as we don't have those installed and we shouldn't have to.这失败了,因为我们没有安装它们,我们不应该安装。

I made these changes directly to the xml in a separate text editor by duplicating all the Win32 property groups, changing the platform on the copy to x86, saving the file, switching the configuration for all builds in VS to the new x86 platform, saving the solution, and then removing the old Win32 property groups.我在单独的文本编辑器中直接对 xml 进行了这些更改,方法是复制所有 Win32 属性组,将副本上的平台更改为 x86,保存文件,将 VS 中所有构建的配置切换到新的 x86 平台,保存解决方案,然后删除旧的 Win32 属性组。 This appears to work but I now see the C++ project marked with "Visual Studio 2010", which explains to me why MSBuild keeps trying to use 2010 build tools, but what would be the purpose for this?这似乎有效,但我现在看到标有“Visual Studio 2010”的 C++ 项目,这向我解释了为什么 MSBuild 一直尝试使用 2010 构建工具,但这样做的目的是什么?

In short the question is this: why is VS loading x86 platform projects as 2010 projects?简而言之,问题是:为什么 VS 将 x86 平台项目加载为 2010 项目? Any insight is appreciated, keeping in mind that we are wedded to VS as our IDE and MSBuild as our build program, and we want to still have our local devenv building work.感谢您提供任何见解,请记住,我们已将 VS 作为我们的 IDE,并将 MSBuild 作为我们的构建程序,并且我们仍然希望我们的本地 devenv 构建工作。 Our C++/CLI code is all going to be rewritten to C# and we are moving from CCNet in the future, but we would like this to work with what we have right now.我们的 C++/CLI 代码都将被重写为 C#,我们将来会从 CCNet 迁移,但我们希望它能够与我们现在拥有的一起工作。

If you modified your .vcxproj Platform references to "x86", it won't work and is an "unknown platform" as far as Visual C++ is concerned.如果您修改了对“x86”的 .vcxproj 平台引用,它将无法工作,并且就 Visual C++ 而言是“未知平台”。 The actual 32-bit Platform name is "Win32" and has been for ages.实际的 32 位平台名称是“Win32”并且已经使用了很长时间。

Only the "solution" system was updated to handle "x86" as an alias for "Win32".只有“解决方案”系统被更新为处理“x86”作为“Win32”的别名。

TL;DR: Revert your changes to your vcxproj files. TL;DR:恢复对 vcxproj 文件的更改。 You can modify the SLN to call it "x86" instead of "Win32" in the combobox if you want.如果需要,您可以修改 SLN 以在组合框中将其称为“x86”而不是“Win32”。

    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|x86 = Debug|x86
        Debug|x64 = Debug|x64
        Release|x86 = Release|x86
        Release|x64 = Release|x64
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {guid}.Debug|x86.ActiveCfg = Debug|Win32
        {guid}.Debug|x86.Build.0 = Debug|Win32
        {guid}.Debug|x64.ActiveCfg = Debug|x64
        {guid}.Debug|x64.Build.0 = Debug|x64
        {guid}.Release|x86.ActiveCfg = Release|Win32
        {guid}.Release|x86.Build.0 = Release|Win32
        {guid}.Release|x64.ActiveCfg = Release|x64
        {guid}.Release|x64.Build.0 = Release|x64
    EndGlobalSection

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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