You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS2019构建时LargeAddressAware目标无法定位editbin.exe问题求助

问题原因

该报错的核心是$(VS160COMNTOOLS)属性在你当前的构建上下文中未被正确赋值,具体原因如下:

  • VS2019安装时默认不会将VS160COMNTOOLS写入系统全局环境变量,该变量仅在「VS2019 开发者命令提示符」启动时由启动脚本临时注入当前会话。你从Visual Studio IDE直接启动构建、或在普通系统上下文调用MSBuild时,进程环境中不存在该变量,因此读取结果为空。
  • 只有C项目默认会导入VC工具集相关构建属性,自动生成$(VS160COMNTOOLS)这类MSBuild属性。如果你的项目是C#/VB等非C项目,默认不会加载VC相关目标文件,该属性自然为空。

修复方案

可以修改原构建目标,替换依赖VS160COMNTOOLS的路径查找逻辑,使用更通用的定位方式,修改后的参考代码如下:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="MakeApplicationLargeAddressAware" AfterTargets="Build" Condition=" '$(Platform)' != 'x64' ">
    <!-- 优先使用VC工具集自带的路径属性定位 -->
    <PropertyGroup>
      <EditBinPath Condition=" '$(EditBinPath)' == '' And Exists('$(VC_ExecutablePath_x64)editbin.exe') ">$(VC_ExecutablePath_x64)editbin.exe</EditBinPath>
    </PropertyGroup>
    <!-- 兜底通配符查找VS2019默认安装路径下的editbin -->
    <ItemGroup Condition=" '$(EditBinPath)' == '' ">
      <SearchPath Include="$(ProgramFiles)\Microsoft Visual Studio\2019\*\VC\Tools\MSVC\**\x64\editbin.exe" />
      <SearchPath Include="$(ProgramFiles(x86))\Microsoft Visual Studio\2019\*\VC\Tools\MSVC\**\x64\editbin.exe" />
    </ItemGroup>
    <PropertyGroup>
      <EditBinPath Condition=" '$(EditBinPath)' == '' ">%(SearchPath.FullPath)</EditBinPath>
    </PropertyGroup>

    <Error Text="The editbin.exe could not be found.  Please make sure you have the c++ tools installed for Visual Studio!" Condition=" '$(EditBinPath)' == '' " />
    <Message Text="Found editbin.exe at $(EditBinPath)" Importance="high" />
    <Exec Command="&quot;$(EditBinPath)&quot; /LARGEADDRESSAWARE &quot;$(TargetPath)&quot;" />
  </Target>
</Project>

修改后如果仍有报错,可再次确认VS安装时已勾选「C++桌面开发」工作负载下的「VC工具集核心功能」组件。

内容的提问来源于stack exchange,提问作者koder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.14 14:54:00