Skip to content

Give users a chance to Input the path of BuildTools\VC#31

Closed
cchangwen wants to merge 1 commit into
php:masterfrom
cchangwen:patch-1
Closed

Give users a chance to Input the path of BuildTools\VC#31
cchangwen wants to merge 1 commit into
php:masterfrom
cchangwen:patch-1

Conversation

@cchangwen

Copy link
Copy Markdown

vswhere.exe return nothing If there is no complete installation of Visual Studio https://visualstudio.microsoft.com/visual-cpp-build-tools/

vswhere.exe return nothing If there is no complete installation of Visual Studio https://visualstudio.microsoft.com/visual-cpp-build-tools/
@cmb69

cmb69 commented Sep 21, 2024

Copy link
Copy Markdown
Member

That worked fine for me a couple of years ago (see https://gist.github.com/cmb69/47b8c7fb392f5d79b245c74ac496632c).

Is it possible that you have the build tools for vs 17 installed (plus the MSVC v142 tools), but want to build for vs16? This is supported if you call phpsdk-starter.bat -c vs16 -a x64 -s 14.29 (i.e. you explicitly pass the -s option).

@cmb69 cmb69 added the question Further information is requested label Sep 21, 2024
@cchangwen

Copy link
Copy Markdown
Author

@cmb69 Just as you said.

phpsdk-vs16-x64.bat
Could not determine 'vs16' directory
phpsdk-starter.bat -c vs16 -a x64 -s 14.2
[vcvarsall.bat] Environment initialized for: 'x64'

PHP SDK 2.3.0

OS architecture:    x64
Build architecture: x64
Visual C++:         14.29.30154.0
PHP-SDK path:       d:\php-sdk-binary-tools-php-sdk-2.3.0

@cchangwen

cchangwen commented Sep 21, 2024

Copy link
Copy Markdown
Author

In some cases, vswhere. exe don't output valid information, causing all scripts that depend on it to not work properly.
phpsdk_setshell.bat

@cmb69

cmb69 commented Sep 21, 2024

Copy link
Copy Markdown
Member

Yes, this is a known issue. That part of detection is super strict and uses a range, to avoid finding another Visual Studio installation; this is important if you have multiple versions of Visual Studio installed. See also #29.

While offering the possibility to input the path manually (i.e. this PR) is certainly an option, I prefer to apply a local patch for easy of use (I start the php-sdk environments usually quite often).

Patch
 phpsdk-vc15-x64.bat | 2 +-
 phpsdk-vc15-x86.bat | 2 +-
 phpsdk-vs16-x64.bat | 2 +-
 phpsdk-vs16-x86.bat | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/phpsdk-vc15-x64.bat b/phpsdk-vc15-x64.bat
index 5988bdb..12247b3 100755
--- a/phpsdk-vc15-x64.bat
+++ b/phpsdk-vc15-x64.bat
@@ -1,6 +1,6 @@
 @echo off
 
-call %~dp0phpsdk-starter.bat -c vc15 -a x64 %*
+call %~dp0phpsdk-starter.bat -c vc15 -a x64 -s 14.16 %*
 
 exit /b %ERRORLEVEL%
 
diff --git a/phpsdk-vc15-x86.bat b/phpsdk-vc15-x86.bat
index 3721abe..468cbaf 100755
--- a/phpsdk-vc15-x86.bat
+++ b/phpsdk-vc15-x86.bat
@@ -1,6 +1,6 @@
 @echo off
 
-call %~dp0phpsdk-starter.bat -c vc15 -a x86 %*
+call %~dp0phpsdk-starter.bat -c vc15 -a x86 -s 14.16 %*
 
 exit /b %ERRORLEVEL%
 
diff --git a/phpsdk-vs16-x64.bat b/phpsdk-vs16-x64.bat
index c0c58e4..07a1652 100755
--- a/phpsdk-vs16-x64.bat
+++ b/phpsdk-vs16-x64.bat
@@ -1,6 +1,6 @@
 @echo off
 
-call %~dp0phpsdk-starter.bat -c vs16 -a x64 %*
+call %~dp0phpsdk-starter.bat -c vs16 -a x64 -s 14.29 %*
 
 exit /b %ERRORLEVEL%
 
diff --git a/phpsdk-vs16-x86.bat b/phpsdk-vs16-x86.bat
index 5162e0a..d6f07f6 100755
--- a/phpsdk-vs16-x86.bat
+++ b/phpsdk-vs16-x86.bat
@@ -1,6 +1,6 @@
 @echo off
 
-call %~dp0phpsdk-starter.bat -c vs16 -a x86 %*
+call %~dp0phpsdk-starter.bat -c vs16 -a x86 -s 14.29 %*
 
 exit /b %ERRORLEVEL%

@shivammathur

Copy link
Copy Markdown
Member

Thanks for the PR.

We should avoid an interactive set /p fallback here because unattended builds and CI jobs may hang indefinitely when Visual Studio detection fails. Pure Build Tools installations are already supported since 7cc9c62, and selecting an older toolset installed in a newer Visual Studio installation is supported with the -s option since d1036b5. Since that covers the reported setup without introducing an interactive CI path, I’m closing this.

If manual path is still needed, it should be a non-interactive CLI option or environment variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants