Open swaldhoer opened 5 years ago
Starting with Visual Studio 2019 version 16.2 there is an PowerShell wrapper for Visual Studio (Developer PowerShell for VS 2019
), see devblogs.microsoft.com.
To activate the Developer PowerShell you need to run the following command:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "& { Import-Module C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll; Enter-VsDevShell -InstanceId YOUR_INSTANCE_ID}"
And the instance ID can be found by using vswhere: E.g. to find the instanceId for VS 2017:
"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property instanceId -version [15.0,16.0)
or VS 2019:
"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property instanceId -version [16.0,17)
Therefore you just need to get the instanceId
and then pass it to Enter-VsDevShell
and you could use PowerShell, conda PowerShell wrapper and Visual Studio.
Actual Behavior
The Anaconda package
vs2017_win-64
basically runs thevcvars64.bat
script coming with Visual Studio 2017 to have an activatedconda
environment with all environment variables set for using the MSVC compiler inside that activated environment. This package works when running<InstallDirectory>\Scripts\activate.bat
incmd
.Starting with
conda 4.6.0
PowerShell support was added toconda
s environment activation. Runningetenv
in PowerShell works well and the environment gets activated, but the environment variables for MSVC are not set (and that is obvious as this package works with a batch file).I would suggest this solution from Visual Studios
vswhere.exe
to make the package also working with PowerShell (seevswhere
wiki):vswhere
comes starting form VS2017, so maybe for older versions of VS this needs to be changed a little bit.Expected Behavior
The environment variables should be set correctly for
PowerShell
afteretenv
is run as they are set correctly incmd
afteractivate.bat
is run.Steps to Reproduce
C:>SET MSSdk=1
C:>SET "VS_VERSION=15.0"
C:>SET "VS_MAJOR=15"
C:>SET "VS_YEAR=2017"
C:>set "MSYS2_ARG_CONV_EXCL=/AI;/AL;/OUT;/out"
C:>set "MSYS2_ENV_CONV_EXCL=CL"
C:>set "PY_VCRUNTIME_REDIST=\bin\vcruntime140.dll"
C:>set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\"
C:>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\" )
C:>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\" )
C:>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\" )
C:>SET "CMAKE_GENERATOR=Visual Studio 15 2017 Win64"
C:>pushd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\"
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>CALL "VC\Auxiliary\Build\vcvars64.bat"
**
Visual Studio 2017 Developer Command Prompt v15.0.26730.16
Copyright (c) 2017 Microsoft Corporation
**
[vcvarsall.bat] Environment initialized for: 'x64'
Operating System:
Windows
conda info