错误 MSB8052:MSVC 工具集版本“14.28.29333”与“v120”平台工具集不兼容

问题描述

我长期以来一直面临这个问题,我正在尝试在 VS 2019 中构建一个项目,该项目之前在 vs 2013 中构建得很好。我面临这个错误,在 Microsoft 论坛上没有任何定义。

我尝试使用 2019 工具集进行所有重定向,并将工具集版本更改为项目配置文件中的当前版本,但完全没有成功。

我不知道为什么连微软论坛都没有对此错误代码错误 MSB8052)的任何解释

另外,项目名称前的括号中仍然显示visual studio 2013。我已将所有工具集更改为使用 2019 版本,但这并没有改变。

错误如下:错误 MSB8052:MSVC 工具集版本“14.28.29333”与“v120”平台工具集不兼容。请将平台工具集更改为 v142,或将 MSVC 工具集版本(VCToolsversion 属性)更改为格式为“12.0*.*”的版本。要为给定的平台工具集使用认的 MSVC 工具集版本,请不要设置 VCToolsversion 属性

不知何故,它仍在使用旧平台工具集。有人可以帮我解决这个问题吗? 在此处输入代码

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" Toolsversion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Matrix">
    <MatrixProjectDir>..\..\..</MatrixProjectDir>
  </PropertyGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{173A4A3E-C861-4013-9366-08716BF7BCCD}</ProjectGuid>
    <RootNamespace>LogicNpcUnmanagedSupport</RootNamespace>
    <SccProjectName>SAK</SccProjectName>
    <SccAuxPath>SAK</SccAuxPath>
    <ScclocalPath>SAK</ScclocalPath>
    <SccProvider>SAK</SccProvider>
    <Keyword>Win32Proj</Keyword>
    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <USEOfMfc>Dynamic</USEOfMfc>
    <CharacterSet>Unicode</CharacterSet>
    <PlatformToolset>v142</PlatformToolset>
    <Clrsupport>true</Clrsupport>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <USEOfMfc>Dynamic</USEOfMfc>
    <CharacterSet>Unicode</CharacterSet>
    <PlatformToolset>v142</PlatformToolset>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="propertysheets">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    <Import Project="..\..\..\Build\propertysheets\MatrixReleaseSettings.props" />
  </ImportGroup>
  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="propertysheets">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    <Import Project="..\..\..\Build\propertysheets\MatrixDebugSettings.props" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <_ProjectFiLeversion>10.0.40219.1</_ProjectFiLeversion>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <runcodeAnalysis>true</runcodeAnalysis>
  </PropertyGroup>
  <ItemDeFinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <AdditionalIncludeDirectories>..\Include;$(ProjectDir)\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDeFinitions>WIN32;_DEBUG;_LIB;_COMPILING_NPC_LIB_;%(PreprocessorDeFinitions)</PreprocessorDeFinitions>
    </ClCompile>
    <Lib>
      <OutputFile>$(OutDir)ag$(ProjectName).lib</OutputFile>
      <TargetMachine>MachineX64</TargetMachine>
    </Lib>
  </ItemDeFinitionGroup>
  <ItemDeFinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <AdditionalIncludeDirectories>..\Include;$(ProjectDir)\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDeFinitions>WIN32;NDEBUG;_LIB;_COMPILING_NPC_LIB_;%(PreprocessorDeFinitions)</PreprocessorDeFinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Lib>
      <OutputFile>$(Configuration)\ag$(ProjectName).lib</OutputFile>
      <TargetMachine>MachineX64</TargetMachine>
    </Lib>
  </ItemDeFinitionGroup>
  <ItemGroup>
    <ClCompile Include="agGuid.cpp" />
    <ClCompile Include="agLogicNpcBuffer.cpp" />
    <ClCompile Include="agLogicNpcCallForwarder.cpp" />
    <ClCompile Include="agLogicNpcclient.cpp" />
    <ClCompile Include="agLogicNpcdispatcher.cpp" />
    <ClCompile Include="agLogicNpcException.cpp" />
    <ClCompile Include="agLogicNpcHeader.cpp" />
    <ClCompile Include="agLogicNpcServer.cpp" />
    <ClCompile Include="stdafx.cpp">
      <precompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</precompiledHeader>
      <precompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</precompiledHeader>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="agArrayWrapper.h" />
    <ClInclude Include="agArrayWrapperComposite.h" />
    <ClInclude Include="agArrayWrapperPrimitive.h" />
    <ClInclude Include="agGuid.h" />
    <ClInclude Include="agLogicNpcBuffer.h" />
    <ClInclude Include="agLogicNpcCallForwarder.h" />
    <ClInclude Include="agLogicNpcclient.h" />
    <ClInclude Include="agLogicNpcContentFlags.h" />
    <ClInclude Include="agLogicNpcdispatcher.h" />
    <ClInclude Include="agLogicNpcException.h" />
    <ClInclude Include="agLogicNpcHeader.h" />
    <ClInclude Include="agLogicNpcServer.h" />
    <ClInclude Include="agLogicNpcServerInfo.h" />
    <ClInclude Include="agLogicNpcTransport.h" />
    <ClInclude Include="stdafx.h" />
    <ClInclude Include="targetver.h" />
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>

enter code here -  MatrixDebugSettings.props
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" Toolsversion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="propertysheets">
    <Import Project="MatrixBaseSettings.props" />
    <Import Project="MatrixMultiProcessorOptionSetting.props" />
    <Import Project="MatrixDebugBaseSettings.props" />
  </ImportGroup>
  <PropertyGroup>
    <_ProjectFiLeversion>10.0.40219.1</_ProjectFiLeversion>
  </PropertyGroup>
</Project>

enter code here - Microsoft.Cpp.x64.user.props
<?xml version="1.0" encoding="utf-8"?> 
<Project DefaultTargets="Build" Toolsversion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="propertysheets">
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup />
  <ItemDeFinitionGroup />
  <ItemGroup />
</Project>

解决方法

可以直接打开vcxproj文件,然后确认修改Platform ToolsetV142 enter image description here

如果它不起作用,您可以尝试删除 sln 文件旁边的 .vs 文件夹。