安装VS2022后VS2019构建Unity HoloLens项目报错求助
问题:VS2022安装后VS2019构建Unity/HoloLens项目报错
之前本地构建代理仅安装VS2019时,Unity/HoloLens项目构建完全正常。为满足其他.NET 6项目需求安装VS2022后,使用VS2019构建该Unity项目时出现以下错误:
构建代理报错信息
EXEC(0,0): Error : System.NotSupportedException: Visual Studio 2017 support for ARM64 is not installed. C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(46,5): Error MSB3073: Der Befehl ""C:\agent\_work\1\b\UWP_Build\Il2CppOutputProject\\IL2CPP\build\deploy\netcoreapp3.1\il2cpp.exe" --libil2cpp-static --compile-cpp -architecture=ARM64 -configuration=Release -platform=winrt -outputpath="C:\agent\_work\1\b\UWP_Build\\build\bin\ARM64\Release\GameAssembly.dll" --data-folder="C:\agent\_work\1\b\UWP_Build\\build\bin\ARM64\Release\\" -cachedirectory="C:\agent\_work\1\b\UWP_Build\\build\obj\il2cppOutputProject\ARM64\Release\\" -generatedcppdir="C:\agent\_work\1\b\UWP_Build\Il2CppOutputProject\\Source" --incremental-g-c-time-slice=3 --baselib-directory="C:\agent\_work\1\b\UWP_Build\Players\UAP\il2cpp\ARM64\Release" --avoid-dynamic-library-copy --profiler-report --additional-defines=WINDOWS_UWP --additional-defines=UNITY_UWP --additional-defines=UNITY_WSA_10_0 --additional-defines=UNITY_WSA --additional-defines=UNITY_WINRT --additional-defines=PLATFORM_WINRT -dotnetprofile=unityaot -verbose --relative-data-path=Data/il2cpp_data --map-file-parser="C:\agent\_work\1\b\UWP_Build\Il2CppOutputProject\\IL2CPP\MapFileParser\MapFileParser.exe"" wurde mit dem Code -1 beendet. Process 'msbuild.exe' exited with code '1'.
手动用VS2019构建时额外报错
System.NotSupportedException: Visual Studio 2017 support for ARM64 is not installed. MSB3073 The command ""C:\agent\_work\1\b\UWP_Build\Il2CppOutputProject\\IL2CPP\build\deploy\netcoreapp3.1\il2cpp.exe" --libil2cpp-static --compile-cpp -architecture=ARM64 -configuration=Release -platform=winrt -outputpath="C:\agent\_work\1\b\UWP_Build\\build\bin\ARM64\Release\GameAssembly.dll" --data-folder="C:\agent\_work\1\b\UWP_Build\\build\bin\ARM64\Release\\" -cachedirectory="C:\agent\_work\1\b\UWP_Build\\build\obj\il2cppOutputProject\ARM64\Release\\" -generatedcppdir="C:\agent\_work\1\b\UWP_Build\Il2CppOutputProject\\Source" --incremental-g-c-time-slice=3 --baselib-directory="C:\agent\_work\1\b\UWP_Build\Players\UAP\il2cpp\ARM64\Release" --avoid-dynamic-library-copy --profiler-report --additional-defines=WINDOWS_UWP --additional-defines=UNITY_UWP --additional-defines=UNITY_WSA_10_0 --additional-defines=UNITY_WSA --additional-defines=UNITY_WINRT --additional-defines=PLATFORM_WINRT -dotnetprofile=unityaot -verbose --relative-data-path=Data/il2cpp_data --map-file-parser="C:\agent\_work\1\b\UWP_Build\Il2CppOutputProject\\IL2CPP\MapFileParser\MapFileParser.exe"" was terminated with the code -1. MSB8020 The build tools for v143 (platform toolset = "v143") were not found. To build using the v143 build tools, install the v143 build tools. Alternatively, upgrade to the latest Visual Studio tools by selecting the Project menu or right-clicking the solution and selecting Reassign Solution.
VS2019已安装对应工作负载,但安装VS2022后,项目错误要求VS2017的ARM64支持和v143构建工具(实际项目应使用VS2019对应的v142),以下是解决办法:
解决办法
1. 强制指定VS2019的MSBuild路径
安装VS2022后系统默认MSBuild可能指向VS2022版本,导致构建调用错误工具链:
- VS2019 Community版MSBuild路径:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe - 构建脚本或命令行中,用该路径替代默认
msbuild.exe执行构建。
2. 修复VS2019的ARM64组件
VS2022安装可能干扰了VS2019组件注册:
- 打开VS2019安装程序,选择「修改」
- 确保勾选「通用Windows平台开发」工作负载下的「ARM64和ARM64EC工具」组件
- 点击「修改」完成修复安装。
3. 统一项目平台工具集为v142
项目被错误切换到VS2022的v143工具集,需强制改回VS2019的v142:
- 用VS2019打开Unity生成的UWP项目
- 右键项目 → 属性 → 配置属性 → 常规 → 平台工具集,选择「v142 (Visual Studio 2019)」
- 确保所有配置(Debug/Release)和平台(ARM64/x64等)都统一设置为v142
- 保存后重新构建。
4. 清理Unity构建缓存
IL2CPP缓存可能残留VS2022配置信息:
- 删除项目的
Library文件夹、obj和bin目录 - 在Unity编辑器中重新生成UWP项目
- 用VS2019打开新生成的项目构建。
5. 调整环境变量优先级
VS2022可能修改了环境变量,导致VS2019无法找到工具:
- 打开系统环境变量,检查
VCTargetsPath是否指向VS2019路径(如C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160) - 若存在VS2022相关路径,调整顺序让VS2019路径优先级更高。
内容的提问来源于stack exchange,提问作者Perazim
相关产品推荐
相关产品推荐

