VC++ 2017 Could not find VC++ tools version "14.16.27023" - visual-c++

I've installed Visual 2017 C++ build tools. I am attempting to run vsdevcmd to prepare the environment. But, I am getting an error stating VC++ tools are not installed when they infact are.
Below is the error I am getting:
[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] ---------------------
Here's the level 3 error reporting of that specific error:
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\".
That directory exists because I copied and pasted the path and was able to change into that directory. Using explorer I can also see that exact version does exist, and within it all the expected tools (as can be seen in the image below)
Any ideas what the problem could be?
Edit
As Hans pointed out in the comment there is wild character at the beginning of the filename 14.16.27023.
According to the output it's loading the path from 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"
I've inspected this file and it contains the following (no odd character):
Also viewed with a hex editor and there's nothing there:
I inspected the vcdevcmd.bat file and it's failing at this:
#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
with the error:
'"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
Now I'm not even sure if these 2 errors are related but both appear in the logs. I have attempted complete removed of VS and all of it's products. I've reinstalled with a fresh installer, to no avail.
Thing is, I had this working initially.
Edit 2
Ok, here is the problem with being unable to load VC++ tools (from 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
)
I can't find any env. variables set for __VCVARS_TOOLS_VERSION or VCVARS_TOOLS_VERSION. If I could set that, maybe I can get it to work.
Found this at the head of the same file:
if "%__VCVARS_VERSION%" NEQ "" (
set __VCVARS_TOOLS_VERSION=%__VCVARS_VERSION%
goto :export_env_vctoolsinstalldir
)
I attempted to set that variable and rerun vcdevcmd but it still failed:
set __VCVARS_VERSION=14.16.27023
Also tried:
vsdevcmd -arch=amd64 -host_arch=amd64 -vcvars_ver=14.16.27023
That produces the error:
[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

Related

Could not find fsi.exe. Attempting to resolve fsi.exe in PATH

I am new to Azure Pibelines, but try to learn it. It seems very powerfull.
Have got at .netcore31 project who works/compiles fine with 'agent specification' "windows-2019", but when I update to .net6 and "windows-2022" or "windows-latest" I got the subtitle error "Could not find fsi.exe. Attempting to resolve fsi.exe in PATH".
Have read Missing FSI.exe from F# pipeline (sometimes) and others, but ... maybe I miss ssome basic informations.
The Pibeline has step for NuGet 5.4.0, NuGet rastore, and build solutionXXX.
The solution works fine on my own machine with VS2022, and in the pibeling with VS2019. Know that fsi.exe has another path, 19<>22, but ... do I have to set that path myselves (how) on a Azure Pibeline?
VS19: c:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\fsi.exe
VS22: c:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\fsi.exe
Other helps are velcome (?), thanks a lot.
I use the following in local using the command line as an administrator and it could be added successfully:
setx /M path "%Path%;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools"
So could you kindly try to add a task before the failed build task for a try:
Here is the script for your reference.
steps:
- script: 'setx /M path "%Path%;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools"'
displayName: 'Command Line Script'

IExpress Post Installation Batch with NodeJS not finding NPM immediately

I'm trying to use iExpress to install dependencies on a small script that I've created on NodeJS.
The iExpress package simply installs the packages Node:
msiexec /i node.msi
Then runs a Post installation Batch to put the Javascript into a folder in the %UserProfile% folder.
The Post installation Batch is run with:
cmd /c post_install.bat
In the batch there is a line which isn't working:
npm install <dependency>
This doesn't seem to work immediately after the MSI install, but it will work the second time the .exe is run and NodeJS is installed.
So for whatever reason, either the MSI isn't setting the PATH variables until after the Batch is finished, or the iExpress Post Installation batch isn't getting set with the right environmental variables.
Anyone else experienced this problem, is there a work around or recommendation?
Should I put the installation of the MSI and the running of NPM into an installation script instead of using the Post Install?
The answer on What is the reason for '...' is not recognized as an internal or external command, operable program or batch file? explains where system and user environment variables are stored in Windows registry and how updates are made on them. It also explains that no process can modify the environment variables of an already running process and each new process inherits the current list of environment variables of its parent process.
So on starting IExpress installation process this installation process inherits the environment variables from its parent process which is usually Windows Explorer, but can be also a www browser or any other application.
The IExpress installation process runs msiexec /i node.msi which installs Node.js and most likely adds or modifies system or user environment variables in Windows registry. But those modifications on persistent stored environment variables for entire machine and current user are not automatically taken over to local environment variables list of already running IExpress installation process.
Next is started by IExpress installation process a command process with command line cmd /c post_install.bat which gets by Windows a fresh copy of environment variables as currently set for IExpress installation process to work with.
So whatever the Node.js installation process modified in Windows registry on the persistent stored system and user environment variables or on local environment variables of MSIEXEC process is not visible for the Windows command process executing the batch file post_install.bat.
But npm batch file executed by post_install.bat depends on environment variables stored in Windows registry during Node.js installation process. For that reason it is necessary to update local environment variables with the system and user environment variables (in this order) before executing npm batch file.
This can be done by extending post_install.bat with following commented code:
#echo off
setlocal EnableExtensions DisableDelayedExpansion
rem Set current directory to user's profile directory.
cd /D "%UserProfile%"
rem Make sure the environment variables used to build local PATH from
rem the PATH environment variables currently stored in Windows registry
rem do not already exist with unwanted values.
set "LocalPath="
set "SystemPath="
set "UserPath="
rem Get all system environment variables as currently stored in Windows
rem registry and set them in local environment with exception of system PATH.
for /F "skip=2 tokens=1,2*" %%A in ('%SystemRoot%\System32\reg.exe query "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" 2^>nul') do (
if /I "%%A" == "Path" (
set "SystemPath=%%C"
) else if /I "%%B" == "REG_SZ" (
set "%%A=%%C"
) else if /I "%%B" == "REG_EXPAND_SZ" (
call set "%%A=%%C"
)
)
rem Get all user environment variables as currently stored in Windows
rem registry and set them in local environment with exception of user PATH.
for /F "skip=2 tokens=1,2*" %%A in ('%SystemRoot%\System32\reg.exe query "HKEY_CURRENT_USER\Environment" 2^>nul') do (
if /I "%%A" == "Path" (
set "UserPath=%%C"
) else if /I "%%B" == "REG_SZ" (
set "%%A=%%C"
) else if /I "%%B" == "REG_EXPAND_SZ" (
call set "%%A=%%C"
)
)
rem PATH can contain references to environment variables which can be
rem expanded only after having all environment variables except system
rem and user PATH already set in local environment. Now it is possible
rem to expand the environment variable references in system and user
rem PATH and concatenate them two one PATH set in local environment
rem replacing PATH as inherited from process starting this batch file.
if not defined SystemPath goto ProcessUserPath
call set "LocalPath=%SystemPath%"
if not "%LocalPath:~-1%" == ";" set "LocalPath=%LocalPath%;"
:ProcessUserPath
if not defined UserPath goto SetLocalPath
call set "LocalPath=%LocalPath%%UserPath%"
:SetLocalPath
if not defined LocalPath goto DoInstall
if "%LocalPath:~-1%" == ";" set "LocalPath=%LocalPath:~0,-1%"
if defined LocalPath set "PATH=%LocalPath%"
:DoInstall
rem Call NPM in its own environment inherited from current local environment.
rem Then discard all modifications made by NPM batch file on its own local
rem environment and restore the environment this batch file has set before.
setlocal
call npm.cmd install ...
endlocal
rem Insert here other post installation commands.
rem Restore previous environment on starting this batch file which means
rem discarding all modifications made on local list of environment variables
rem and restoring initial current directory before modification by CD at top
rem and restoring initial status of command extensions and delayed expansion.
endlocal
This batch file reading system and user environment variables as currently stored in Windows registry and updating the local environment variables including local PATH works even on Windows XP / Windows Server 2003 although output of REG is different on Windows XP / Server 2003 in comparison to Windows Vista / Server 2008 and all later Windows versions.
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
call /?
cd /?
echo /?
endlocal /?
for /?
if /?
reg /?
reg query /?
rem /?
set /?
setlocal /?
This became too long for a comment, though I am honestly commenting more than answering. Best effort though, a few things:
Security: iExpress suffers from some major security vulnerabilities. If this hits your clients, it really is a terrible thing to deal with. Just my two cents and friendly heads-up.
The same applies to many self-extracting installer tools as discussed here: Error Creating a 7-zip installer package (link for reference only, you should not need it).
Recommend you go with an established and properly maintained deployment tool: Tools Discussion and links all over the place and a Tools List (simplified, major tools only). A visit to the last link recommended.
SendMessageTimeout: Environment variable updates are not immediately available for all running applications on the system, even if successfully applied.
Supposedly you can use the SendMessageTimeout API to update all running windows with new settings and variables. I am not sure how reliable this really is - I remember some problems back in the day of Win9X, but I am no expert on the subject.
Maybe have a look here: https://www.advancedinstaller.com/forums/viewtopic.php?t=27578. This is a very good message board belonging to Advanced Installer.
WiX features the WixBroadcastSettingChange and WixBroadcastEnvironmentChange Custom Actions (which I have never tried). I believe its core implementation is here: BroadcastSettingsChange.cpp.
In essence: calling SendMessageTimeout API should make the PATH change "stick".
Chris Painter: I am not up to speed on NodeJS. Hopefully Chris Painter will know how to deploy such scripts properly, I suspect there is another way that is more reliable than what you use. He may not be lurking here at the moment though.
UPDATE: Added a comment to the question above with a link which shows how Node.js can be deployed using Advanced Installer.

Visual Studio error on command "attrib -r" on a dataset file

I have downloaded a solution with multiple projects from TFS and getting 2 errors on building it.
error 1:
The command "attrib -r c:\web\idpm45\benchmarkloader\benchmarkloader\dataset\benchmarkimportdataset.cs /s
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\xsd.exe" /d /l:CS /namespace:BenchmarkLoader c:\web\idpm45\benchmarkloader\benchmarkloader\dataset\BenchmarkImportDataset.xsd /out:"c:\web\idpm45\BenchmarkLoader\benchmarkloader\dataset"
" exited with code 1.
error 2:
There was an error processing 'c:\web\idpm45\benchmarkloader\benchmarkloader\dataset\BenchmarkImportDataset.xsd'
Has anyone faced this attrib command errors?

How the setup the environment of MIT-Scheme with slimv in windows 7?

I read the source code of slimv\ftplugin\scheme\slimv-scheme.vim
if exists( 'g:scheme_builtin_swank' ) && g:scheme_builtin_swank
" MIT Scheme contains a built-in swank server since version 9.1.1
return 'scheme --eval "(let loop () (start-swank) (loop))"'
endif
There's no scheme.exe in my system, only find one c:\Program Files\MIT-GNU Scheme\bin\mit-scheme.exe
When I tried to run C:\Program Files\MIT-GNU Scheme\bin>mit-scheme.exe --eval "(let loop () (start-
swank) (loop))", there's an error
---------------------------
MIT/GNU Scheme terminating
---------------------------
scheme: can't find a readable default for option --band.
searched for file all.com in these directories:
c:\local\mit-scheme
Reason for termination:
Inconsistency detected.
---------------------------
I have tried to load one .scm in Vim and type this command:
:echo SlimvSwankCommand()
And the autodetection was unsuccessful:(
You need to build a command that runs a swank server inside MIT Scheme.
Let's suppose that Scheme is installed in the MIT-GNU Scheme directory on Windows.
You also need a swank server for MIT Scheme, e.g. swank-mit-scheme.scm in slimv (taken from SLIME).
Then you start MIT Scheme from the command prompt and load the swank server this way:
"C:\Program Files\MIT-GNU Scheme\mit-scheme" --band "C:\Program Files\MIT-GNU Scheme\lib\all.com" --library "C:\Program Files\MIT-GNU Scheme\lib" --load "C:\Program Files\Vim\vimfiles\slime\contrib\swank-mit-scheme.scm"
If you want slimv to run it for you upon pressing ,c then you need to embed the above command in '!start /MIN ...' and pass it to g:slimv_swank_scheme in your _vimrc (remember to enclose each path that contains space in double quotes):
let g:slimv_swank_scheme='!start /MIN "C:\Program Files\MIT-GNU Scheme\mit-scheme" --band "C:\Program Files\MIT-GNU Scheme\lib\all.com" --library "C:\Program Files\MIT-GNU Scheme\lib" --load "C:\Program Files\Vim\vimfiles\slime\contrib\swank-mit-scheme.scm"'
Of course you can use another swank server as well. The main point is to pass the full path to each component in the above command. I suggest that first you try to run the swank server manually from the command prompt. When it's okay you can put it into '!start /MIN ...'.

fatal error C1083: Cannot open include file: 'Windows.h': and scons

Today is officially my first day with C++ :P
I've downloaded Visual C++ 2005 Express Edition and Microsoft Platform SDK for Windows Server 2003 SP1, because I want to get my hands on the open source Enso Project.
So, after installing scons I went to the console and tried to compile it using scons, but I got this error:
C:\oreyes\apps\enso\enso-read-only\src\platform\win32\Include\WinSdk.h(64) : fatal error C1083: Cannot open include file: 'Windows.h': No such file or directory
scons: *** [src\platform\win32\InputManager\AsyncEventProcessorRegistry.obj] Error 2
scons: building terminated because of errors.
After checking these links:
VS ans PSDK
Include tiffi.h
Wndows.h
I've managed to configure my installation like this:
And even run this script
And I managed to compile the file below in the IDE.
// Test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
But I still get that exception in the console. Does anyone have scons experience?
EDIT
Actually (and I forgot to tell you this) I started the command prompt with the link "Visual Studio 2005 Command Prompt".
I assume this will include the paths in environment variables. Well after printing them I find that it didn't:
echo %INCLUDE%
echo %LIB%
echo %PATH%
And they were not present, so I created this .bat file:
set PATH=%PATH%;"C:\Program Files\Microsoft Platform SDK\Bin"
set INCLUDE=%INCLUDE%;"C:\ Program Files\Microsoft Platform SDK\Include"
set LIB=%LIB%;"C:\ Program Files\Microsoft Platform SDK\Lib"
Still, scons seeems not to take the vars... :(
Using the above recommendations will not work with scons: scons does not import the user environment (PATH and other variables). The fundamental problem is that scons does not handle recent versions of SDKs/VS .
I am an occasional contributor to scons, and am working on this feature ATM. Hopefully, it will be included soon in scons, but the feature is much harder to implement reliably than I first expected, partly because every sdk/compiler combination is different (and sometimes even MS does not get it right, some of their .bat files are broken), so I can't give you a date. I hope it will be included in 1.2 (to be released in approximatively one month).
You need to set the include file path (and possibly other things). At the command line this is typically done using a batch file that Visual Studio installs called vsvars32.bat (or vcvars32.bat for compatibility with VC6).
I'm not familiar with scons so I don't know the best way to get these settings configured for that tool, but for standard makefiles there's usually a line in the makefile which sets a macro variable with the include directory path and that macro is used as part of a command line parameter in the command that invokes the compiler.
Another possibility might be to have the scons process invoke vsvars32.bat or run the scons script from a command line that has been configured with the batch file.
In short you need to get the things that vsvars32.bat configures into the scons configuration somehow.
There will be a batch file similar to this one (for MSVC 2005) that sets up the environment variables:
c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat
Step 1: Find a similar file in the Express installation folders
Step 2: Create a shortcut on the desktop with these target details and a suitably modified path:
cmd.exe /K "c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"
Step 3: Open the DOS prompt via this shortcut
The command line build should now work from within this console window.
You show us how you configured Visual Studio for compilations within Visual Studio but you didn't show us what command line environment you tried. Sorry I haven't tried Express versions so I don't know if they create additional Start menu shortcuts like Pro and above do. If you open a suitable command prompt with its environment variables already set then you can compile on the command line. Otherwise you have to set variables yourself or execute a batch script to set them, each time you open a command prompt.
It'll be nice when scons does this automatically. For now, I use this (run from an SDK command prompt, not sure if there is a difference if run after vsvars32.bat):
import os
env = Environment(ENV={'PATH': os.environ['PATH']})
env['ENV']['TMP'] = os.environ['TMP']
env.AppendUnique(CPPPATH=os.environ['INCLUDE'].split(';'))
env.AppendUnique(LIBPATH=os.environ['LIB'].split(';'))
This works for me while compiling wxwidgets with Visual C++ 2005 Express using the command line prompt:
REM Fix Error error C1083 'windows.h'
(Use /useenv option when compiling.)
set PDSKWIN=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2
(Change to the right one.)
set INCLUDE=%PDSKWIN%\Include;%INCLUDE%
set LIB=%PDSKWIN%\Lib;%LIB%
Then I use this line when compiling. I believe just add /useenv to your lines and everything should work fine:
vcbuild /useenv /nohtmllog /nologo name.proj (or any file to compile)

Resources