From aa25833ee8cfcd1ee6ddc2c39d85a4c012f09691 Mon Sep 17 00:00:00 2001 From: Naacbin Date: Tue, 28 May 2024 00:16:00 +0200 Subject: [PATCH] Refactor WinDbg install --- .../windbg.vm/tools/chocolateyinstall.ps1 | 35 +++++++++++++------ packages/windbg.vm/windbg.vm.nuspec | 2 +- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/packages/windbg.vm/tools/chocolateyinstall.ps1 b/packages/windbg.vm/tools/chocolateyinstall.ps1 index e4aa27ad5..12d6195d5 100644 --- a/packages/windbg.vm/tools/chocolateyinstall.ps1 +++ b/packages/windbg.vm/tools/chocolateyinstall.ps1 @@ -5,17 +5,32 @@ try { $toolName = 'WinDbg' $category = 'Debuggers' - # It seems WinDbg is now distributed as an .appinstaller and we need to install it using Add-AppxPackage - Add-AppxPackage -AppInstallerFile 'https://windbg.download.prss.microsoft.com/dbazure/prod/1-0-0/windbg.appinstaller' + $bundleUrl = "https://windbg.download.prss.microsoft.com/dbazure/prod/1-2402-24001-0/windbg.msixbundle" + $bundleSha256 = "e941076cb4d7912d32a22ea87ad2693c01fa465227b4d1ead588283518de428f" - $shortcutDir = Join-Path ${Env:TOOL_LIST_DIR} $category - $shortcut = Join-Path $shortcutDir "$toolName.lnk" - $executableCmd = Join-Path ${Env:WinDir} "system32\cmd.exe" - # Use `start` to close the open console - $executableArgs = "/C start WinDbgX.exe" - $executableDir = Join-Path ${Env:UserProfile} "Desktop" - Install-ChocolateyShortcut -shortcutFilePath $shortcut -targetPath $executableCmd -Arguments $executableArgs -WorkingDirectory $executableDir -RunAsAdmin + $packageArgs = @{ + packageName = ${Env:ChocolateyPackageName} + url = $bundleUrl + checksum = $bundleSha256 + checksumType = "sha256" + fileFullPath = Join-Path ${Env:TEMP} "$toolName.msixbundle" + } + Get-ChocolateyWebFile @packageArgs + Add-AppxPackage -Path $packageArgs.fileFullPath + + $installDir = (Get-AppxPackage -Name "Microsoft.$toolName").InstallLocation + $iconLocation = Join-Path $installDir "DbgX.Shell.exe" -Resolve + $executablePath = "$(where.exe WinDbgXA.exe)" + VM-Install-Shortcut -toolName $toolName -category $category -executablePath $executablePath -iconLocation $iconLocation -RunAsAdmin } catch { - VM-Write-Log-Exception $_ + if ($_.Exception.Message -match "INFO: Could not find files for the given pattern\(s\).") + { + $executablePath = Join-Path $installDir "DbgX.Shell.exe" + VM-Install-Shortcut -toolName $toolName -category $category -executablePath $executablePath -iconLocation $iconLocation -RunAsAdmin + } + else + { + VM-Write-Log-Exception $_ + } } diff --git a/packages/windbg.vm/windbg.vm.nuspec b/packages/windbg.vm/windbg.vm.nuspec index cef8d9838..a30a40f89 100644 --- a/packages/windbg.vm/windbg.vm.nuspec +++ b/packages/windbg.vm/windbg.vm.nuspec @@ -2,7 +2,7 @@ windbg.vm - 0.0.0 + 1.2402.24001.20240527 Microsoft WinDbg is a debugger that can be used to analyze crash dumps, debug live user-mode and kernel-mode code, and examine CPU registers and memory.