From be48ac03f749ba902b74ec342015a527edf48008 Mon Sep 17 00:00:00 2001 From: Grace Rehn Date: Wed, 5 Nov 2025 14:27:55 +1000 Subject: [PATCH 1/9] Add dotnet-script to windows worker tools --- windows.ltsc2022/Dockerfile | 5 +++++ windows.ltsc2022/README.md | 1 + windows.ltsc2022/spec/windows.ltsc2022.tests.ps1 | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/windows.ltsc2022/Dockerfile b/windows.ltsc2022/Dockerfile index f73bd17..b5e4fa2 100644 --- a/windows.ltsc2022/Dockerfile +++ b/windows.ltsc2022/Dockerfile @@ -24,6 +24,8 @@ ARG Octopus_Client_Version=14.3.1789 ARG Powershell_Version=7.4.6 ARG Python_Version=3.13.1 ARG ScriptCs_Version=0.17.1 +# Dotnet version depends on .NET runtime (currently 8.0) +ARG Dotnet_Script_Version=1.5.0 ARG Terraform_Version=1.10.4 # Install Choco @@ -99,6 +101,9 @@ RUN Invoke-WebRequest "https://dl.google.com/dl/cloudsdk/channels/rapid/download # Install ScriptCS RUN choco install scriptcs -y --version $Env:ScriptCs_Version --no-progress +# Install dotnet-script +RUN dotnet tool install -g dotnet-script --version $Env:Dotnet_Script_Version + # Install Octopus CLI RUN choco install octopus-cli -y --version $Env:Octopus_Cli_Version --no-progress diff --git a/windows.ltsc2022/README.md b/windows.ltsc2022/README.md index b5f9662..af1111f 100644 --- a/windows.ltsc2022/README.md +++ b/windows.ltsc2022/README.md @@ -31,6 +31,7 @@ - Azure CLI 2.58.0 - Azure PowerShell 4.5.0 - Azure PowerShell Modules 11.3.0 +- Dotnet Script 1.5.0 - Eksctl 0.173.0 - Google Cloud CLI 467.0.0 - Google Cloud GKE auth plugin 467.0.0-0 / 0.5.8 diff --git a/windows.ltsc2022/spec/windows.ltsc2022.tests.ps1 b/windows.ltsc2022/spec/windows.ltsc2022.tests.ps1 index c9ec11b..f159a34 100644 --- a/windows.ltsc2022/spec/windows.ltsc2022.tests.ps1 +++ b/windows.ltsc2022/spec/windows.ltsc2022.tests.ps1 @@ -21,6 +21,11 @@ Describe 'installed dependencies' { $LASTEXITCODE | Should -be 0 } + It 'has dotnet-script installed' { + dotnet-script --version | Should -Match '1.5.0' + $LASTEXITCODE | Should -be 0 + } + It 'has java installed' { java -version 2>&1 | Select-String -Pattern '21\.0\.2' | Should -BeLike "*21.0.2*" $LASTEXITCODE | Should -be 0 From 3040a4b6829f8bbd0b8ab1d973baa73eb98c36a7 Mon Sep 17 00:00:00 2001 From: Grace Rehn Date: Wed, 5 Nov 2025 15:46:51 +1000 Subject: [PATCH 2/9] Move dotnet install and pin kubectl on ubuntu worker tools --- ubuntu.22.04/Dockerfile | 2 +- windows.ltsc2022/Dockerfile | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ubuntu.22.04/Dockerfile b/ubuntu.22.04/Dockerfile index 068dcf2..506623d 100644 --- a/ubuntu.22.04/Dockerfile +++ b/ubuntu.22.04/Dockerfile @@ -103,7 +103,7 @@ RUN wget --quiet -O - https://deb.nodesource.com/setup_${NodeJs_Version}.x | bas RUN curl -fsSL "https://pkgs.k8s.io/core:/stable:/v${Kubectl_Version}/deb/Release.key" | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg && \ echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v${Kubectl_Version}/deb/ /" | tee /etc/apt/sources.list.d/kubernetes.list && \ apt-get update && \ - apt-get install -y kubectl && \ + apt-get install -y kubectl=${Kubectl_Version}.* && \ rm -rf /var/lib/apt/lists/* # Install Kubelogin diff --git a/windows.ltsc2022/Dockerfile b/windows.ltsc2022/Dockerfile index b5e4fa2..8eff40c 100644 --- a/windows.ltsc2022/Dockerfile +++ b/windows.ltsc2022/Dockerfile @@ -101,9 +101,6 @@ RUN Invoke-WebRequest "https://dl.google.com/dl/cloudsdk/channels/rapid/download # Install ScriptCS RUN choco install scriptcs -y --version $Env:ScriptCs_Version --no-progress -# Install dotnet-script -RUN dotnet tool install -g dotnet-script --version $Env:Dotnet_Script_Version - # Install Octopus CLI RUN choco install octopus-cli -y --version $Env:Octopus_Cli_Version --no-progress @@ -129,6 +126,9 @@ RUN choco install argocd-cli --yes --version $Env:Argo_Cli_Version --no-progress ADD .\scripts\update_path.cmd C:\update_path.cmd RUN .\update_path.cmd; +# Install dotnet-script, requires dotnet on path +RUN dotnet tool install -g dotnet-script --version $Env:Dotnet_Script_Version + # gcloud requires python on path, update_path.cmd adds python to path. Delete any backup files that exist (~1gb) RUN gcloud components install gke-gcloud-auth-plugin --quiet; ` if (Test-Path C:\google-cloud-sdk\.install\.backup) {Remove-Item -Path C:\google-cloud-sdk\.install\.backup -Force -Recurse} From 0870509dfa494e900664bdf78a96f6876f5284cd Mon Sep 17 00:00:00 2001 From: Grace Rehn Date: Wed, 5 Nov 2025 16:58:05 +1000 Subject: [PATCH 3/9] Add missing nuget source --- windows.ltsc2022/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows.ltsc2022/Dockerfile b/windows.ltsc2022/Dockerfile index 8eff40c..0a21056 100644 --- a/windows.ltsc2022/Dockerfile +++ b/windows.ltsc2022/Dockerfile @@ -127,7 +127,7 @@ ADD .\scripts\update_path.cmd C:\update_path.cmd RUN .\update_path.cmd; # Install dotnet-script, requires dotnet on path -RUN dotnet tool install -g dotnet-script --version $Env:Dotnet_Script_Version +RUN dotnet tool install -g dotnet-script --version $Env:Dotnet_Script_Version --add-source https://api.nuget.org/v3/index.json # gcloud requires python on path, update_path.cmd adds python to path. Delete any backup files that exist (~1gb) RUN gcloud components install gke-gcloud-auth-plugin --quiet; ` From 2bf65e3872ec49e31f8f7d748027e8cd86a0a162 Mon Sep 17 00:00:00 2001 From: Grace Rehn Date: Thu, 6 Nov 2025 15:22:26 +1000 Subject: [PATCH 4/9] Ensure dotnet-script is added to the path --- windows.ltsc2022/Dockerfile | 3 +++ windows.ltsc2022/scripts/update_path.cmd | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/windows.ltsc2022/Dockerfile b/windows.ltsc2022/Dockerfile index 0a21056..2cfb5ab 100644 --- a/windows.ltsc2022/Dockerfile +++ b/windows.ltsc2022/Dockerfile @@ -129,6 +129,9 @@ RUN .\update_path.cmd; # Install dotnet-script, requires dotnet on path RUN dotnet tool install -g dotnet-script --version $Env:Dotnet_Script_Version --add-source https://api.nuget.org/v3/index.json +# Update path again to add dotnet-script to PATH +RUN .\update_path.cmd; + # gcloud requires python on path, update_path.cmd adds python to path. Delete any backup files that exist (~1gb) RUN gcloud components install gke-gcloud-auth-plugin --quiet; ` if (Test-Path C:\google-cloud-sdk\.install\.backup) {Remove-Item -Path C:\google-cloud-sdk\.install\.backup -Force -Recurse} diff --git a/windows.ltsc2022/scripts/update_path.cmd b/windows.ltsc2022/scripts/update_path.cmd index 0dcf5b6..46405ec 100644 --- a/windows.ltsc2022/scripts/update_path.cmd +++ b/windows.ltsc2022/scripts/update_path.cmd @@ -1,2 +1,2 @@ -setx /M path "%PATH%;C:\google-cloud-sdk\bin;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\dotnet;C:\Program Files\PackageManagement\NuGet\Packages\Octopus.Client.14.3.1248\lib\net462\Octopus.Client.dll" +setx /M path "%PATH%;C:\google-cloud-sdk\bin;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\dotnet;C:\Program Files\PackageManagement\NuGet\Packages\Octopus.Client.14.3.1248\lib\net462\Octopus.Client.dll;C:\Users\ContainerAdministrator\.dotnet\tools" From dae44cbca99ee76bc3858d30d77d5171dc0f18c1 Mon Sep 17 00:00:00 2001 From: Grace Rehn Date: Thu, 6 Nov 2025 17:17:30 +1000 Subject: [PATCH 5/9] Debug --- windows.ltsc2022/Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/windows.ltsc2022/Dockerfile b/windows.ltsc2022/Dockerfile index 2cfb5ab..05456f5 100644 --- a/windows.ltsc2022/Dockerfile +++ b/windows.ltsc2022/Dockerfile @@ -127,10 +127,11 @@ ADD .\scripts\update_path.cmd C:\update_path.cmd RUN .\update_path.cmd; # Install dotnet-script, requires dotnet on path -RUN dotnet tool install -g dotnet-script --version $Env:Dotnet_Script_Version --add-source https://api.nuget.org/v3/index.json - -# Update path again to add dotnet-script to PATH -RUN .\update_path.cmd; +RUN dotnet tool install -g dotnet-script --version $Env:Dotnet_Script_Version --add-source https://api.nuget.org/v3/index.json; ` + Write-Host "Installed dotnet-script, checking location..."; ` + Get-ChildItem C:\Users\ContainerAdministrator\.dotnet\tools -ErrorAction SilentlyContinue; ` + .\update_path.cmd; ` + Write-Host "PATH after update: $env:PATH" # gcloud requires python on path, update_path.cmd adds python to path. Delete any backup files that exist (~1gb) RUN gcloud components install gke-gcloud-auth-plugin --quiet; ` From c521836544b361d3e040f9c62629810bf27e3131 Mon Sep 17 00:00:00 2001 From: Grace Rehn Date: Fri, 7 Nov 2025 10:17:54 +1000 Subject: [PATCH 6/9] Test --- windows.ltsc2022/Dockerfile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/windows.ltsc2022/Dockerfile b/windows.ltsc2022/Dockerfile index 05456f5..d3309f0 100644 --- a/windows.ltsc2022/Dockerfile +++ b/windows.ltsc2022/Dockerfile @@ -127,11 +127,13 @@ ADD .\scripts\update_path.cmd C:\update_path.cmd RUN .\update_path.cmd; # Install dotnet-script, requires dotnet on path -RUN dotnet tool install -g dotnet-script --version $Env:Dotnet_Script_Version --add-source https://api.nuget.org/v3/index.json; ` - Write-Host "Installed dotnet-script, checking location..."; ` - Get-ChildItem C:\Users\ContainerAdministrator\.dotnet\tools -ErrorAction SilentlyContinue; ` - .\update_path.cmd; ` - Write-Host "PATH after update: $env:PATH" +RUN dotnet tool install -g dotnet-script --version $Env:Dotnet_Script_Version --add-source https://api.nuget.org/v3/index.json + +# Verify installation +RUN Write-Host "Checking if dotnet-script.exe exists..."; ` + Test-Path C:\Users\ContainerAdministrator\.dotnet\tools\dotnet-script.exe; ` + Write-Host "Current machine PATH from registry:"; ` + [Environment]::GetEnvironmentVariable('PATH', 'Machine') # gcloud requires python on path, update_path.cmd adds python to path. Delete any backup files that exist (~1gb) RUN gcloud components install gke-gcloud-auth-plugin --quiet; ` From 34bcc903dde18ed6b8fd584db3dc3d44ddc6dc69 Mon Sep 17 00:00:00 2001 From: Grace Rehn Date: Fri, 7 Nov 2025 12:50:50 +1000 Subject: [PATCH 7/9] Test --- windows.ltsc2022/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/windows.ltsc2022/Dockerfile b/windows.ltsc2022/Dockerfile index d3309f0..5729e57 100644 --- a/windows.ltsc2022/Dockerfile +++ b/windows.ltsc2022/Dockerfile @@ -135,6 +135,9 @@ RUN Write-Host "Checking if dotnet-script.exe exists..."; ` Write-Host "Current machine PATH from registry:"; ` [Environment]::GetEnvironmentVariable('PATH', 'Machine') +# Update path again to add dotnet-script to PATH +RUN .\update_path.cmd; + # gcloud requires python on path, update_path.cmd adds python to path. Delete any backup files that exist (~1gb) RUN gcloud components install gke-gcloud-auth-plugin --quiet; ` if (Test-Path C:\google-cloud-sdk\.install\.backup) {Remove-Item -Path C:\google-cloud-sdk\.install\.backup -Force -Recurse} From 67428b3fd3ff98bc374323cd33744da7a5e72323 Mon Sep 17 00:00:00 2001 From: Grace Rehn Date: Fri, 7 Nov 2025 16:38:00 +1000 Subject: [PATCH 8/9] Try add dotnet root for dotnet tool --- windows.ltsc2022/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/windows.ltsc2022/Dockerfile b/windows.ltsc2022/Dockerfile index 5729e57..862e959 100644 --- a/windows.ltsc2022/Dockerfile +++ b/windows.ltsc2022/Dockerfile @@ -37,6 +37,7 @@ RUN $ProgressPreference = 'SilentlyContinue'; ` # Install dotnet 8.0+ RUN Invoke-WebRequest 'https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.ps1' -outFile 'dotnet-install.ps1'; ` [Environment]::SetEnvironmentVariable('DOTNET_CLI_TELEMETRY_OPTOUT', '1', 'Machine'); ` + [Environment]::SetEnvironmentVariable('DOTNET_ROOT', 'C:\Users\ContainerAdministrator\AppData\Local\Microsoft\dotnet', 'Machine'); ` .\dotnet-install.ps1 -Channel '8.0'; ` rm dotnet-install.ps1 From 79402564e420650bf273bbd5d65faeb6a16f7c0e Mon Sep 17 00:00:00 2001 From: Grace Rehn Date: Tue, 11 Nov 2025 10:34:15 +1000 Subject: [PATCH 9/9] Set dotnet root --- windows.ltsc2022/Dockerfile | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/windows.ltsc2022/Dockerfile b/windows.ltsc2022/Dockerfile index 862e959..9a2f497 100644 --- a/windows.ltsc2022/Dockerfile +++ b/windows.ltsc2022/Dockerfile @@ -28,6 +28,9 @@ ARG ScriptCs_Version=0.17.1 ARG Dotnet_Script_Version=1.5.0 ARG Terraform_Version=1.10.4 +# Dotnet installation directory (matches path in update_path.cmd) +ARG Dotnet_Install_Dir=C:\Users\ContainerAdministrator\AppData\Local\Microsoft\dotnet + # Install Choco RUN $ProgressPreference = 'SilentlyContinue'; ` Set-ExecutionPolicy Bypass -Scope Process -Force; ` @@ -35,9 +38,10 @@ RUN $ProgressPreference = 'SilentlyContinue'; ` iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) # Install dotnet 8.0+ +# DOTNET_ROOT is required for dotnet tools to locate the runtime RUN Invoke-WebRequest 'https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.ps1' -outFile 'dotnet-install.ps1'; ` [Environment]::SetEnvironmentVariable('DOTNET_CLI_TELEMETRY_OPTOUT', '1', 'Machine'); ` - [Environment]::SetEnvironmentVariable('DOTNET_ROOT', 'C:\Users\ContainerAdministrator\AppData\Local\Microsoft\dotnet', 'Machine'); ` + [Environment]::SetEnvironmentVariable('DOTNET_ROOT', $Env:Dotnet_Install_Dir, 'Machine'); ` .\dotnet-install.ps1 -Channel '8.0'; ` rm dotnet-install.ps1 @@ -130,15 +134,6 @@ RUN .\update_path.cmd; # Install dotnet-script, requires dotnet on path RUN dotnet tool install -g dotnet-script --version $Env:Dotnet_Script_Version --add-source https://api.nuget.org/v3/index.json -# Verify installation -RUN Write-Host "Checking if dotnet-script.exe exists..."; ` - Test-Path C:\Users\ContainerAdministrator\.dotnet\tools\dotnet-script.exe; ` - Write-Host "Current machine PATH from registry:"; ` - [Environment]::GetEnvironmentVariable('PATH', 'Machine') - -# Update path again to add dotnet-script to PATH -RUN .\update_path.cmd; - # gcloud requires python on path, update_path.cmd adds python to path. Delete any backup files that exist (~1gb) RUN gcloud components install gke-gcloud-auth-plugin --quiet; ` if (Test-Path C:\google-cloud-sdk\.install\.backup) {Remove-Item -Path C:\google-cloud-sdk\.install\.backup -Force -Recurse}