diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 98d96feb95..5db5a4331a 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -217,10 +217,28 @@ "{{ template_dir }}/scripts/Installers/Install-ServiceFabricSDK.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-WSL.ps1" + ] + }, { "type": "windows-restart", "restart_timeout": "30m" }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-UbuntuImage.ps1" + ] + }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-MSYS2.ps1" + ] + }, { "type": "powershell", "scripts":[ @@ -251,6 +269,18 @@ "{{ template_dir }}/scripts/Installers/Validate-ServiceFabricSDK.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-WSL.ps1" + ] + }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-MSYS2.ps1" + ] + }, { "type": "powershell", "scripts":[ diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 1b411672e3..9bda946be6 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -192,10 +192,28 @@ "{{ template_dir }}/scripts/Installers/Install-ServiceFabricSDK.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-WSL.ps1" + ] + }, { "type": "windows-restart", "restart_timeout": "10m" }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-UbuntuImage.ps1" + ] + }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-MSYS2.ps1" + ] + }, { "type": "powershell", "scripts":[ @@ -220,6 +238,18 @@ "{{ template_dir }}/scripts/Installers/Validate-ServiceFabricSDK.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-WSL.ps1" + ] + }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-MSYS2.ps1" + ] + }, { "type": "powershell", "scripts":[ diff --git a/images/win/scripts/Installers/Install-MSYS2.ps1 b/images/win/scripts/Installers/Install-MSYS2.ps1 new file mode 100644 index 0000000000..8aa81034ba --- /dev/null +++ b/images/win/scripts/Installers/Install-MSYS2.ps1 @@ -0,0 +1,11 @@ +################################################################################ +## File: Install-MSYS2.ps1 +## Desc: Install MSYS2 via chocolaty +################################################################################ + +Import-Module -Name ImageHelpers + +$msys2Path = "C:\tools\msys64" +choco install msys2 -y --params "/InstallDir:$msys2Path" + +Add-MachinePathItem $msys2Path diff --git a/images/win/scripts/Installers/Install-UbuntuImage.ps1 b/images/win/scripts/Installers/Install-UbuntuImage.ps1 new file mode 100644 index 0000000000..ffa0d945a4 --- /dev/null +++ b/images/win/scripts/Installers/Install-UbuntuImage.ps1 @@ -0,0 +1,33 @@ +################################################################################ +## File: Install-UbuntuImage.ps1 +## Desc: Install Ubuntu 18.04 Image for WSL +################################################################################ + +Import-Module -Name ImageHelpers + +$ubuntuTempDir = "$env:AGENT_TEMPDIRECTORY\ubuntu" + +if (-not (Test-Path $ubuntuTempDir)) { + New-Item -Path $ubuntuTempDir -ItemType Directory +} + +Push-Location $ubuntuTempDir + +$ubuntuZipName = "ubuntu.zip" +Invoke-WebRequest -Uri "https://aka.ms/wsl-ubuntu-1804" -OutFile $ubuntuZipName + +$ubuntuPath = "C:\tools\ubuntu" +if (-not (Test-Path $ubuntuPath)) { + New-Item -Path $ubuntuPath -ItemType Directory +} + +Expand-Archive -Path $ubuntuZipName -DestinationPath $ubuntuPath + +Add-MachinePathItem $ubuntuPath + +ubuntu1804 install --root +ubuntu1804 run apt update +ubuntu1804 run DEBIAN_FRONTEND=noninteractive apt upgrade -y + +Pop-Location +Remove-Item $ubuntuTempDir -Recurse -Force diff --git a/images/win/scripts/Installers/Install-WSL.ps1 b/images/win/scripts/Installers/Install-WSL.ps1 new file mode 100644 index 0000000000..bd255e81d0 --- /dev/null +++ b/images/win/scripts/Installers/Install-WSL.ps1 @@ -0,0 +1,6 @@ +################################################################################ +## File: Install-WSL.ps1 +## Desc: Install Windows subsystem for Linux +################################################################################ + +Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart \ No newline at end of file diff --git a/images/win/scripts/Installers/Validate-MSYS2.ps1 b/images/win/scripts/Installers/Validate-MSYS2.ps1 new file mode 100644 index 0000000000..957cc47d0c --- /dev/null +++ b/images/win/scripts/Installers/Validate-MSYS2.ps1 @@ -0,0 +1,14 @@ +################################################################################ +## File: Validate-MSYS2.ps1 +## Desc: Validate MSYS2 installation +################################################################################ + +$msysCommand = "msys2" + +Get-Command $msysCommand -ErrorAction SilentlyContinue -OutVariable commandInfo +if ($commandInfo) { + Write-Host "$msysCommand is successfully installed" +} else { + Write-Host "$msysCommand command unavailable" + exit 1 +} diff --git a/images/win/scripts/Installers/Validate-WSL.ps1 b/images/win/scripts/Installers/Validate-WSL.ps1 new file mode 100644 index 0000000000..45ca376f6b --- /dev/null +++ b/images/win/scripts/Installers/Validate-WSL.ps1 @@ -0,0 +1,11 @@ +################################################################################ +## File: Validate-WSL.ps1 +## Desc: Validate Windows Subsystem for Linux installation +################################################################################ + +$FeatureInfo = (Get-WindowsOptionalFeature -Online | Where FeatureName -eq Microsoft-Windows-Subsystem-Linux) + +if ($FeatureInfo.State -eq "Disabled") { + Write-Host "Microsoft-Windows-Subsystem-Linux is Disabled" + exit 1 +} \ No newline at end of file