winget is requiring us to include ProductCode of the MSIs in Microsoft.AzureCLI's manifest (microsoft/winget-pkgs#123641 (comment)): https://github.com/microsoft/winget-pkgs/blob/master/manifests/m/Microsoft/AzureCLI/2.54.0/Microsoft.AzureCLI.installer.yaml
Three methods for extracting the ProductCode are provided: microsoft/winget-pkgs#123641 (comment)
If you use one of the popular manifest authoring tools to create the manifest, they will automatically add/update this field for you.
If you want to retrieve this for yourself, you can use a number of different methods:
- For installed MSI packages, you can get it by running the command (On PowerShell 5 / Windows PowerShell)
get-wmiobject Win32_Product | Sort-Object Name | Format-Table IdentifyingNumber, Name -AutoSize
- If you have the
.msi file, you can use something like MSI Viewer or some PowerShell scripting to retrieve the ProductCode.
- You can run the manifest in Windows Sandbox using the sandbox script and it will print out the related metadata for the package which includes the ProductCode
I am able to get the ProductCode with the first method on my Windows machine (even though Get-WmiObject Win32_Product is slow):
> Get-WmiObject Win32_Product | Sort-Object Name | Format-Table IdentifyingNumber, Name, Version -AutoSize
IdentifyingNumber Name Version
----------------- ---- -------
...
{C56C2883-5C38-4789-B6BA-4D4B17440AE6} Microsoft Azure CLI (64-bit) 2.54.0
However, all these methods require either installing the MSI or other dependencies. As our automation bot @azclibot for generating the manifest is hosted on a Linux agent and the manifest generation logic is written in Bash syntax, these methods may not be practicable unless we move @azclibot to a Windows agent.
A workaround I can think of is to extract the ProductCode while building the MSI and save it to the built ADO artifact. Then use the ProductCode saved in the artifact to generate the manifest.
Regarding a fixed ProductCode
According to https://wixtoolset.org/docs/v3/xsd/wix/product/, Id of Product element is an AutogenGuid:
The product code GUID for the product.
So, in Azure CLI's Product.wxs, it is declared as
And according to https://learn.microsoft.com/en-us/windows/win32/msi/productcode
This ID must vary for different versions and languages.
It is not possible to have a fixed GUID. We must generate a new one for each MSI package.
Also see:
wingetis requiring us to includeProductCodeof the MSIs inMicrosoft.AzureCLI's manifest (microsoft/winget-pkgs#123641 (comment)): https://github.com/microsoft/winget-pkgs/blob/master/manifests/m/Microsoft/AzureCLI/2.54.0/Microsoft.AzureCLI.installer.yamlThree methods for extracting the
ProductCodeare provided: microsoft/winget-pkgs#123641 (comment)I am able to get the
ProductCodewith the first method on my Windows machine (even thoughGet-WmiObject Win32_Productis slow):However, all these methods require either installing the MSI or other dependencies. As our automation bot @azclibot for generating the manifest is hosted on a Linux agent and the manifest generation logic is written in Bash syntax, these methods may not be practicable unless we move @azclibot to a Windows agent.
A workaround I can think of is to extract the
ProductCodewhile building the MSI and save it to the built ADO artifact. Then use theProductCodesaved in the artifact to generate the manifest.Regarding a fixed
ProductCodeAccording to https://wixtoolset.org/docs/v3/xsd/wix/product/,
IdofProductelement is anAutogenGuid:So, in Azure CLI's
Product.wxs, it is declared asazure-cli/build_scripts/windows/Product.wxs
Line 36 in aeb94ed
And according to https://learn.microsoft.com/en-us/windows/win32/msi/productcode
It is not possible to have a fixed GUID. We must generate a new one for each MSI package.
Also see: