Shorten copy&paste commands needed to get a Windows dev env

by integrating Enable-WindowsOptionalFeature ... into doc/win-dev.ps1.
This commit is contained in:
Alexander A. Klimov 2025-01-13 13:59:02 +01:00
parent ab0f20d8d6
commit cdb3237533
2 changed files with 14 additions and 6 deletions

View File

@ -1736,12 +1736,7 @@ and don't care for the details,
1. ensure there are 35 GB free space on C:
2. run the following in an administrative Powershell:
1. Windows Server only:
`Enable-WindowsOptionalFeature -FeatureName NetFx3ServerFeatures -Online`
2. `Enable-WindowsOptionalFeature -FeatureName NetFx3 -Online`
(reboot when asked!)
3. `powershell -NoProfile -ExecutionPolicy Bypass -Command "Invoke-Expression (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/Icinga/icinga2/master/doc/win-dev.ps1')"`
(will take some time)
`powershell -nop -ep bypass -c "iex (iwr 'https://raw.githubusercontent.com/Icinga/icinga2/master/doc/win-dev.ps1')"`
This installs everything needed for cloning and building Icinga 2
on the command line (Powershell) as follows:

View File

@ -57,6 +57,19 @@ function Install-Exe {
}
function Needs-WinFeatureRestart($feature) {
(Enable-WindowsOptionalFeature -FeatureName $feature -Online).RestartNeeded
}
$isServer = (Get-CimInstance -ClassName Win32_OperatingSystem).Caption -match 'Windows Server'
$serverNeedsRestart = $isServer -and (Needs-WinFeatureRestart NetFx3ServerFeatures)
$needsRestart = Needs-WinFeatureRestart NetFx3
if ($serverNeedsRestart -or $needsRestart) {
throw 'Restart needed'
}
try {
Get-Command choco
} catch {