From 3f729edf1950b818fa6a8dd9141bd231a0565994 Mon Sep 17 00:00:00 2001 From: Yannick Reekmans Date: Sat, 16 Aug 2025 01:37:13 +0200 Subject: [PATCH] Parse Tags like in GenerateResourcesAndImage.ps1 Adjust the logic of dealing with Tags in a way that is an exact copy of the logic within GenerateResourcesAndImage.ps1 . This solves a parsing error. --- images.CI/linux-and-win/build-image.ps1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/images.CI/linux-and-win/build-image.ps1 b/images.CI/linux-and-win/build-image.ps1 index 431702ce99..0e890e3e27 100644 --- a/images.CI/linux-and-win/build-image.ps1 +++ b/images.CI/linux-and-win/build-image.ps1 @@ -38,7 +38,14 @@ $SensitiveData = @( ': ->' ) -$azure_tags = $Tags | ConvertTo-Json -Compress +# Prepare tags +$TagsJson = $Tags | ConvertTo-Json -Compress +if ($PSVersionTable.PSVersion.Major -eq 5) { + $TagsJson = $TagsJson -replace '"', '\"' +} +elseif ($PSVersionTable.PSVersion.Major -eq 7 -and $PSVersionTable.PSVersion.Minor -le 2) { + $TagsJson = $TagsJson -replace '"', '\"' +} Write-Host "Show Packer Version" packer --version @@ -66,7 +73,7 @@ packer build -only "$buildName*" ` -var "virtual_network_subnet_name=$VirtualNetworkSubnet" ` -var "allowed_inbound_ip_addresses=$($AllowedInboundIpAddresses)" ` -var "use_azure_cli_auth=$UseAzureCliAuth" ` - -var "azure_tags=$azure_tags" ` + -var "azure_tags=$TagsJson" ` -color=false ` $TemplatePath ` | Where-Object {