Fix Microsoft.AzureCLI 2.53.1 x64/x86 InstallerUrls#123641
Fix Microsoft.AzureCLI 2.53.1 x64/x86 InstallerUrls#123641microsoft-github-policy-service[bot] merged 2 commits intomicrosoft:masterfrom
Conversation
This now matches what we did for 2.53.0.
|
/AzurePipelines run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
One more thing if the maintainer of the bot sees this PR:
|
|
I'm not familiar with winget, can we add this info after installation? |
|
Is anyone going to approve or merge this? It leads to issues like what's described in Azure/azure-cli#27492 (comment) as long as anyone tries to upgrade the package. Every hour we wait, more and more people are likely running into problems. I don't know enough about the packaging rules to know if we should be adding |
|
@halter73 I'll approve this for merge if you please resolve the above review comments (#123641 (comment)). ProductCode is one of the fields WinGet client uses for package correlation and it's better to include it in the manifest for MSI packages. The bot definitely needs fixing, but we should make sure that this version works as intended for majority of users and there aren't any package matching issues |
|
[Policy] Needs-Author-Feedback |
Co-authored-by: Muhammad Danish <mdanishkhdev@gmail.com>
Head branch was pushed to by a user without write access
|
/AzurePipelines run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Publish pipeline succeeded for this Pull Request. Once you refresh your index, this change should be present. |
|
@mdanish-kh, I have created issue Azure/azure-cli#27861 to track adding
It seems all other methods require either installing the MSI or other dependencies. Could you please share more detail on this PowerShell scripting? I believe this script will be very helpful for all winget publishers. I am also wondering if it is possible to programmatically acquire |
@jiasli You can see how it's utilized in Tools/YamlCreate.ps1. I'll attach the relevant code for you here WindowsFunction Get-MSIProperty {
Param
(
[Parameter(Mandatory = $true)]
[string] $MSIPath,
[Parameter(Mandatory = $true)]
[string] $Parameter
)
try {
$windowsInstaller = New-Object -com WindowsInstaller.Installer
$database = $windowsInstaller.GetType().InvokeMember('OpenDatabase', 'InvokeMethod', $null, $windowsInstaller, @($MSIPath, 0))
$view = $database.GetType().InvokeMember('OpenView', 'InvokeMethod', $null, $database, ("SELECT Value FROM Property WHERE Property = '$Parameter'"))
$view.GetType().InvokeMember('Execute', 'InvokeMethod', $null, $view, $null)
$record = $view.GetType().InvokeMember('Fetch', 'InvokeMethod', $null, $view, $null)
$outputObject = $($record.GetType().InvokeMember('StringData', 'GetProperty', $null, $record, 1))
$view.GetType().InvokeMember('Close', 'InvokeMethod', $null, $view, $null)
[System.Runtime.InteropServices.Marshal]::FinalReleaseComObject($view)
[System.Runtime.InteropServices.Marshal]::FinalReleaseComObject($database)
[System.Runtime.InteropServices.Marshal]::FinalReleaseComObject($windowsInstaller)
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
return $outputObject
} catch {
Write-Error -Message $_.ToString()
break
}
}
$MSIFilePath = "$env:USERPROFILE\Downloads\azure-cli-2.53.1.msi"
$ProductCode = ([string](Get-MSIProperty -MSIPath $MSIFilePath -Parameter 'ProductCode') | Select-String -Pattern '{[A-Z0-9]{8}-([A-Z0-9]{4}-){3}[A-Z0-9]{12}}').Matches.Value
Write-Host "ProductCode retrieved from $MSIFilePath : $ProductCode"But looking at the issue, I believe you're looking for a Linux-based solution. That is also mentioned in the script. You can do Linux$MSIFilePath = "/home/user/Downloads/azure-cli-2.53.1.msi"
([string](file $MSIFilePath) | Select-String -Pattern '{[A-Z0-9]{8}-([A-Z0-9]{4}-){3}[A-Z0-9]{12}}').Matches.ValueEquivalent bash code #!/bin/bash
MSIFilePath="/home/user/Downloads/azure-cli-2.53.1.msi"
echo $(file $MSIFilePath | grep -oP '{[A-Z0-9]{8}-([A-Z0-9]{4}-){3}[A-Z0-9]{12}}')Also, you may want to look at https://github.com/russellbanks/Komac, a community-developed tool (maintained by @russellbanks) for generating winget manifests. It's cross-platform, so you would be able to run it on Linux and it'll auto retrieve the product code for you, I believe. |
|
Thank you @mdanish-kh, but the But after installing the MSI, The PowerShell script in #123641 (comment) also gives > $ProductCode = ([string](Get-MSIProperty -MSIPath $MSIFilePath -Parameter 'ProductCode') | Select-String -Pattern '{[A-Z0-9]{8}-([A-Z0-9]{4}-){3}[A-Z0-9]{12}}').Matches.Value
> Write-Host "ProductCode retrieved from $MSIFilePath : $ProductCode"
ProductCode retrieved from C:\Users\xxx\Downloads\azure-cli-2.54.0-x64.msi : {C56C2883-5C38-4789-B6BA-4D4B17440AE6}Is there anything I am doing wrong? |
|
BTW, it seems the script of > $MSIFilePath = "$env:USERPROFILE\Downloads\azure-cli-invalid.msi"
> Get-MSIProperty -MSIPath $MSIFilePath -Parameter 'ProductCode'
MethodInvocationException:
Line |
11 | $database = $windowsInstaller.GetType().InvokeMember('OpenDatabas …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "InvokeMember" with "5" argument(s): "OpenDatabase,DatabasePath,OpenMode" |
|
Our MSI expert @heaths suggests using the > Install-Module MSI -Force
> (Get-MSIProperty -Property ProductCode -Path "$env:USERPROFILE\Downloads\azure-cli-2.54.0-x64.msi").Value
{C56C2883-5C38-4789-B6BA-4D4B17440AE6}This is so far the easiest and most direct way I am aware of to retrieve |
|
@jiasli - it looks like I didn't test the script thoroughly enough for the Linux part. Thanks for finding out the correct way, I should probably look to update the YamlCreate.ps1 script too with this finding |
|
@jiasli Did you get it to work in a Linux environment? I could get the module to work on Windows but still no luck on Linux 👀 |
|
@mdanish-kh, you are welcome. I didn't try it on Linux either. As described in Azure/azure-cli#27861, I think I am going to extract However, I am not an expert on MSI or the |
|
It's not going to work on a non-Windows platform because it uses Windows Installer APIs that are only on Windows. Can you not do this on a Windows agent? Otherwise, there is a Rust crate I've used in another project that actually implements the binary format (OLE docs + proprietary compression algorithms MSIs use). I could write a simple CLI that, given a path, extracts But the |
|
Oh, look at that: I basically already wrote it: https://github.com/heaths/msigetprop-rs
The only difference is that this requires downloading the repo and installing Rust. You can download an x86_64 version here: https://github.com/heaths/msigetprop-rs/releases/download/v0.1.0/msigetprop-x86_64-unknown-linux-gnu.tar.gz If you need another build, let me know or feel free to install Rust and build whatever you need yourself. BTW: the |



This now matches what we did for 2.53.0.
I noticed this when I tried to
winget upgrade --alland afterwards runningwinget upgradestill showed Microsoft.AzureCLI as out of date at 2.53.0. In turned out I had the 2.53.0 x64 and 2.53.1 x86 installed side by side.This exact PR has been opened by community members for at least the last three versions:
@stephengillie @johnstep You probably want to look into fixing the @azclibot. Is that open source?
Microsoft Reviewers: Open in CodeFlow