diff --git a/.kokoro/gcp_windows_docker/Dockerfile b/.kokoro/gcp_windows_docker/Dockerfile index 49d432faf7f..02033a41f7d 100644 --- a/.kokoro/gcp_windows_docker/Dockerfile +++ b/.kokoro/gcp_windows_docker/Dockerfile @@ -5,13 +5,16 @@ # We build in .NET 6 so we need to install .NET 6 after. FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 -# Setup Powershell -RUN powershell -Command $ErrorActionPreference = 'Stop'; -RUN powershell -Command $ProgressPreference = 'SilentlyContinue'; +# Set default powershell policy for this script (ProgressPreference='SilentlyContinue' makes +# downloads with Invoke-WebRequest not show the progress bar and is MUCH faster). +SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command", "$ErrorActionPreference='Stop'; $ProgressPreference='SilentlyContinue'; $VerbosePreference = 'Continue';"] # Install Chocolatey ENV ChocolateyUseWindowsCompression false -RUN powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" +RUN Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); \ + $old_path = [Environment]::GetEnvironmentVariable(\"PATH\", \"Machine\"); \ + $all_users_profile = [Environment]::GetEnvironmentVariable(\"ALLUSERSPROFILE\", \"Machine\"); \ + [Environment]::SetEnvironmentVariable(\"PATH\", $old_path + \";\" + $all_users_profile + \"\chocolatey\bin\", \"Machine\"); # Install .NET Core 3.0 which we need for Google.Apis.Auth.AspNetCore3 RUN choco install -y --no-progress dotnetcore-3.0-sdk @@ -19,9 +22,22 @@ RUN choco install -y --no-progress dotnetcore-3.0-sdk # Install .NET 6 RUN choco install -y --no-progress dotnet-6.0-sdk +# Install .NET 8 +RUN choco install -y --no-progress dotnet-8.0-sdk + # Install Git RUN choco install -y --no-progress git +# Install cygwin and packages exactly as Kokoro does on its own containers +RUN Invoke-WebRequest 'https://cygwin.com/setup-x86_64.exe' -OutFile C:/cygwin_setup.exe -UseBasicParsing; \ + Start-Process 'C:/cygwin_setup.exe' -ArgumentList '-X', '--quiet-mode', '--root', 'C:\Cygwin64', '--site', 'http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/64bit/2022/11/23/063529' -Wait -NoNewWindow; \ + Remove-Item C:/cygwin_setup.exe; \ + $old_path = [Environment]::GetEnvironmentVariable(\"PATH\", \"Machine\"); \ + [Environment]::SetEnvironmentVariable(\"PATH\", $old_path + \";C:\Cygwin64\bin\", \"Machine\"); + +# Restore default shell for Windows containers. +SHELL ["cmd.exe", "/s", "/c"] + # Default to PowerShell. # This is what Kokoro owned Docker images do. We'll do the same at least for now. CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]