VC ++ 2017找不到VC ++工具版本“ 14.16.27023”

时间:2019-01-06 01:50:54

标签: visual-c++

我已经安装了Visual 2017 C ++生成工具。我正在尝试运行vsdevcmd来准备环境。但是,我收到一个错误消息,说明实际上没有安装VC ++工具。

以下是我得到的错误:

[DEBUG:vcvars.bat] Could not find VC++ tools version "14.16.27023" under "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\".
[DEBUG:ext\vcvars.bat] init:COMPLETE
[DEBUG:core\vsdevcmd_end] initializing with arguments ''
[ERROR:VsDevCmd.bat] *** VsDevCmd.bat encountered errors. Environment may be incomplete and/or incorrect. ***
[ERROR:VsDevCmd.bat] In an uninitialized command prompt, please 'set VSCMD_DEBUG=[value]' and then re-run
[ERROR:VsDevCmd.bat] vsdevcmd.bat [args] for additional details.
[ERROR:VsDevCmd.bat] Where [value] is:
[ERROR:VsDevCmd.bat]    1 : basic debug logging
[ERROR:VsDevCmd.bat]    2 : detailed debug logging
[ERROR:VsDevCmd.bat]    3 : trace level logging. Redirection of output to a file when using this level is recommended.
[ERROR:VsDevCmd.bat] Example: set VSCMD_DEBUG=3
[ERROR:VsDevCmd.bat]          vsdevcmd.bat > vsdevcmd.trace.txt 2>&1
[DEBUG:VsDevCmd] Writing post-execution environment to C:\Users\KRAFTW~1\AppData\Local\Temp\dd_vsdevcmd15_env.log
[DEBUG:VsDevCmd.bat] --------------------- VS Developer Command Prompt Environment [post-init] ---------------------

这是该特定错误的3级错误报告:

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC>if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\" (
set "VCToolsInstallDir=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\"
 set "VCToolsVersion=14.16.27023"
)  else (
set VCToolsInstallDir=
 if "3" GEQ "2"
 goto :end
)
[DEBUG:vcvars.bat] Could not find VC++ tools version "14.16.27023" under "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\".

该目录存在是因为我复制并粘贴了路径,并且能够更改为该目录。使用资源管理器,我还可以看到确实存在确切的版本,并且其中包含所有预期的工具(如下图所示)

enter image description here

任何想法可能是什么问题?

修改

就像汉斯在评论中指出的那样,文件名14.16.27023的开头有一个通配符。

enter image description here

根据输出,它从此处加载路径:C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC>set "__VCVARS_DEFAULT_CONFIG_FILE=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"

我已经检查了此文件,它包含以下内容(无奇数字符):

enter image description here

还用十六进制编辑器查看过,那里什么也没有:

enter image description here

我检查了vcdevcmd.bat文件,但此操作失败:

@REM *****************************************************************
@REM This section executes all .bat files found in vsdevcmd\ext.
@REM Any "leaf node" script should be placed in this directory.
@REM A few notes:
@REM * For determinism sake, the scripts are called in alphabetical
@REM   order.
@REM * This section does NOT recursively look in sub-directories
@REM   under vsdevcmd\ext. Sub-directories may be used for
@REM   "implementation detail" scripts called by .bat files in the
@REM   vsdevcmd\ext folder.
@REM *****************************************************************

@REM Iterate through ext scripts
if NOT EXIST "%VS150COMNTOOLS%vsdevcmd\ext\" (
    @echo [ERROR:%~nx0] Cannot find 'ext' folder "%VS150COMNTOOLS%vsdevcmd\ext\"
    set /A __vscmd_vsdevcmd_errcount=__vscmd_vsdevcmd_errcount+1
    goto :ext_end
)

for /F %%a in ( 'dir "%VS150COMNTOOLS%vsdevcmd\ext\*.bat" /b /a-d-h /on' ) do (
    call :call_script_helper ext\%%a
)

:ext_end
set __vscmd_dir_cmd_opt=
exit /B 0

出现错误:

'"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\vsdevcmd\ext\"' is not recognized as an internal or external command,
operable program or batch file.
[ERROR:ext\] init:FAILED code:1

现在,我什至不确定这两个错误是否相关,但都出现在日志中。我试图完全删除VS及其所有产品。我已经重新安装了全新的安装程序,无济于事。

是的,我最初有这个工作。

编辑2

好的,这是无法加载VC ++工具(从vcvars.bat开始)的问题:

:export_env_vctoolsinstalldir
if exist "%VCINSTALLDIR%Tools\MSVC\%__VCVARS_TOOLS_VERSION%\" (
    set "VCToolsInstallDir=%VCINSTALLDIR%Tools\MSVC\%__VCVARS_TOOLS_VERSION%\"
    set "VCToolsVersion=%__VCVARS_TOOLS_VERSION%"
) else (
    set VCToolsInstallDir=
    if "%VSCMD_DEBUG%" GEQ "2" @echo [DEBUG:%~nx0] Could not find VC++ tools version "%__VCVARS_TOOLS_VERSION%" under "%VCINSTALLDIR%Tools\MSVC\".
    goto :end
)

我找不到任何环境。为__VCVARS_TOOLS_VERSIONVCVARS_TOOLS_VERSION设置的变量。如果我可以设置它,也许我可以使它正常工作。

在同一文件的开头找到了该文件:

if "%__VCVARS_VERSION%" NEQ "" (
    set __VCVARS_TOOLS_VERSION=%__VCVARS_VERSION%
    goto :export_env_vctoolsinstalldir
)

我尝试设置该变量并重新运行vcdevcmd,但仍然失败:

set __VCVARS_VERSION=14.16.27023

也尝试过:

vsdevcmd -arch=amd64 -host_arch=amd64 -vcvars_ver=14.16.27023

产生错误:

[DEBUG:vcvars.bat] Checking architecture { host , tgt } : { x86 , x86 }
[DEBUG:vcvars.bat] Could not add directory to PATH: "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCPackages"
[DEBUG:vcvars.bat] Could not find VC++ tools version "14.16.27023" under "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\".
[DEBUG:ext\vcvars.bat] init:COMPLETE

0 个答案:

没有答案