Skip to content

Commit 3e9d12b

Browse files
committed
Add example for manually installing VC15 toolset on windows-2022
1 parent a21a21b commit 3e9d12b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,55 @@ strategy:
5454
Currently, `windows-2019` may be used for all PHP versions, although this may
5555
change in future releases.
5656

57+
### Manually Installing Toolsets
58+
59+
It is possible to manually install older toolsets on `windows-2022` using an
60+
approach suggested in [actions/runner-images#9701](https://github.com/actions/runner-images/issues/9701).
61+
The following example installs VC15 by its
62+
[Component ID](https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022)
63+
to allow building PHP 7.2, 7.3, and 7.4 on a `windows-2022` image:
64+
65+
```yml
66+
run:
67+
steps:
68+
- name: Delete components
69+
shell: pwsh
70+
run: |
71+
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
72+
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
73+
$componentsToRemove= @(
74+
"Microsoft.VisualStudio.Component.VC.v141.x86.x64"
75+
)
76+
[string]$workloadArgs = $componentsToRemove | ForEach-Object {" --remove " + $_}
77+
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
78+
# should be run twice
79+
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
80+
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
81+
82+
- name: Install components
83+
shell: pwsh
84+
run: |
85+
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
86+
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
87+
$componentsToRemove= @(
88+
"Microsoft.VisualStudio.Component.VC.v141.x86.x64"
89+
)
90+
[string]$workloadArgs = $componentsToRemove | ForEach-Object {" --add " + $_}
91+
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
92+
# should be run twice
93+
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
94+
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
95+
```
96+
97+
These steps should be executed _before_ invoking the `setup-php-sdk` action.
98+
99+
An [`if` conditional](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsif)
100+
can also be used to limit these steps to specific PHP versions. For example:
101+
102+
```yml
103+
if: ${{ matrix.php == '7.4' || matrix.php == '7.3' || matrix.php == '7.2' }}
104+
```
105+
57106
## Outputs
58107
59108
- `toolset`: the required toolset version;

0 commit comments

Comments
 (0)