From d7c36f22573ba12f501ba05e315af7dd9cd4fab9 Mon Sep 17 00:00:00 2001 From: Vasilii Polikarpov <126792224+vpolikarpov-akvelon@users.noreply.github.com> Date: Tue, 21 Nov 2023 10:38:18 +0100 Subject: [PATCH] Fix issue where GetPackerTemplatePath fails in PS5 (#8852) --- helpers/GenerateResourcesAndImage.ps1 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/helpers/GenerateResourcesAndImage.ps1 b/helpers/GenerateResourcesAndImage.ps1 index 808556765..d7e65ae5f 100644 --- a/helpers/GenerateResourcesAndImage.ps1 +++ b/helpers/GenerateResourcesAndImage.ps1 @@ -17,20 +17,21 @@ Function Get-PackerTemplatePath { ) switch ($ImageType) { + # Note: Double Join-Path is required to support PowerShell 5.1 ([ImageType]::Windows2019) { - $relativeTemplatePath = Join-Path "windows" "templates" "windows-2019.json" + $relativeTemplatePath = Join-Path (Join-Path "windows" "templates") "windows-2019.json" } ([ImageType]::Windows2022) { - $relativeTemplatePath = Join-Path "windows" "templates" "windows-2022.json" + $relativeTemplatePath = Join-Path (Join-Path "windows" "templates") "windows-2022.json" } ([ImageType]::Ubuntu2004) { - $relativeTemplatePath = Join-Path "ubuntu" "templates" "ubuntu-20.04.json" + $relativeTemplatePath = Join-Path (Join-Path "ubuntu" "templates") "ubuntu-20.04.json" } ([ImageType]::Ubuntu2204) { - $relativeTemplatePath = Join-Path "ubuntu" "templates" "ubuntu-22.04.pkr.hcl" + $relativeTemplatePath = Join-Path (Join-Path "ubuntu" "templates") "ubuntu-22.04.pkr.hcl" } ([ImageType]::UbuntuMinimal) { - $relativeTemplatePath = Join-Path "ubuntu" "templates" "ubuntu-minimal.pkr.hcl" + $relativeTemplatePath = Join-Path (Join-Path "ubuntu" "templates") "ubuntu-minimal.pkr.hcl" } default { throw "Unknown type of image" } }