本文介绍MSB8006错误代码。
消息文本
MSB8006: The Platform for project '*project-name.vcxproj*' is invalid. Platform='*platform-name*'. 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 Platform.
DESCRIPTION
当项目的平台无效时,会发生此错误。
平台是一种生成目标体系结构,它使用一组匹配的C++生成工具和库,或工具集。 Visual Studio 提供了为 Win32(x86)、x64、ARM 和 ARM64 Windows 目标构建的特定平台工具集。 它还支持为 Linux、Android 和 iOS 目标生成的可选平台工具集。
Microsoft C++生成工具(也称为 MSVC 生成工具)包含特定于体系结构的相应平台工具集版本。 例如,Microsoft C++生成工具 v14.50 包含每个受支持的体系结构和目标的平台工具集。
当项目指定平台,但不是随 Visual Studio 一起安装的平台,或者 Visual Studio 找不到它时,可能会出现此错误。
决议
使用 Visual Studio 安装程序安装可选平台和工具集。 有关详细信息,请参阅 修改 Visual Studio。 使用安装程序中的 “单个组件 ”选项卡选择特定的平台、库和 SDK。
大多数项目不需要指定自定义平台,但可以创建一个。 有关详细信息,请参阅 Visual Studio C++ Project 系统扩展性和工具集集成。 为平台创建自定义 .props 文件和 .targets 文件后,可以在项目的 “属性页 ”对话框中的 IDE 中选择它。
确保项目在由引用项目生成时被加载。 验证项目是否为与引用项目相同的平台生成。
适用于
MSBuild 的所有版本