-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor WinDbg install #1058
base: main
Are you sure you want to change the base?
Refactor WinDbg install #1058
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @naacbin. It is nice that the shortcut has the WinDbg icon! 🚀!
$installDir = (Get-AppxPackage -Name "Microsoft.$toolName").InstallLocation | ||
$executablePath = Join-Path $installDir "DbgX.Shell.exe" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tested this code locally? I get an error when trying to run the shortcut:
The following code works:
$installDir = (Get-AppxPackage -Name "Microsoft.$toolName").InstallLocation | |
$executablePath = Join-Path $installDir "DbgX.Shell.exe" | |
$installDir = (Get-AppxPackage -Name "Microsoft.$toolName").InstallLocation | |
$iconLocation = Join-Path $installDir "DbgX.Shell.exe" -Resolve | |
$executablePath = "$(where.exe WinDbgX.exe)" | |
VM-Install-Shortcut -toolName $toolName -category $category -executablePath $executablePath -iconLocation $iconLocation -RunAsAdmin |
Note I have also added a -Resolve
to Join-Path
to ensure the DbgX.Shell.exe
exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have tested locally strange...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How, did you test ? I have tried from Tools
directory and the Windows bar, it seems to work. Maybe it was the RunAsAdmin
that was needed. Can you try again ?
I have added the
-Resolve
parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested the current code again. I install a package in an empty VM (setup as documented in the wiki) and double clicking the shortcut in the Tools directory shows the error:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running DbgX.Shell.exe
directly (without the shortcut) also shows the same error (even if run as admin).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, the only difference between our setup is that my empty VM only has chocolatey
, I don't have a snapshot with install.ps1
installed (yet). If I get some time, I will investigate on this, but anyway, your proposal seems to work for me too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the CI of windows-2019 doesn't appreciate "$(where.exe WinDbgX.exe)"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, the only difference between our setup is that my empty VM only has
chocolatey
, I don't have a snapshot withinstall.ps1
installed (yet).
After creating a snapshot as documented in the wiki but with my current VM (which is build 22621) it still works (without the where.exe
. So the problem, comes from Windows version.
50b7c8b
to
32e9234
Compare
|
||
$installDir = (Get-AppxPackage -Name "Microsoft.$toolName").InstallLocation | ||
$iconLocation = Join-Path $installDir "DbgX.Shell.exe" -Resolve | ||
$executablePath = "$(where.exe WinDbgX.exe)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like the windows-2019 run can't find WinDbgX.exe
which likely mean it hasn't been installed... (likely it was also not working before, but we were not checking). The GH runner is using Windows 10.0.17763
, locally I am using 10.0.19045
for testing.
Searching online about issues installing WinDbg, I see information about conflicts with the Windows Software Development Kit. For example: https://superuser.com/questions/1524982/windbg-repeatedly-downloads-but-doesnt-install. Maybe requiring windows-sdk-10.0
as dependency fixes the issue. 🤔
@mandiant/vms any other ideas how to fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I won't be able to test it myself as I don't have any Windows 10 VM and can't get one easily to test for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have Windows 10, but newer than the one in GH actions and it works for me. I am also not sure how to get an older Windows 10 for local testing. We can use GH for testing by pushing new changes to this PR (or running the test in a fork to avoid the noise in the PR).
@mandiant/vms any ideas to fix or test this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Searching online about issues installing WinDbg, I see information about conflicts with the Windows Software Development Kit. For example: https://superuser.com/questions/1524982/windbg-repeatedly-downloads-but-doesnt-install. Maybe requiring
windows-sdk-10.0
as dependency fixes the issue. 🤔
I tried to add windows-sdk-10.0
as dependency but it still failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do not figure out what the issue is, we can keep running it as a console app with:
VM-Install-Shortcut -toolName $toolName -category $category -executablePath "start $toolName.exe" -consoleApp $true -runAsAdmin -iconLocation $iconLocation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ana06, I have tried another idea by catching the exception, it seems to work !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like that we use $executablePath = Join-Path $installDir "DbgX.Shell.exe"
as executing DbgX.Shell.exe
does not work for me, so potentially this is broken for others too. I think without the start
it should work and be equivalent to the code we had before:
VM-Install-Shortcut -toolName $toolName -category $category -executablePath "$toolName.exe" -consoleApp $true -runAsAdmin -iconLocation $iconLocation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have noticed I can't even accces
C:\Program Files\WindowsApps\
whereDbgX.Shell.exe
is, likely why I can't execute it
I don't think it's related, at least not directly. Since you should be able to accessC:\Program Files\WindowsApps\Microsoft.WinDbg_1.2402.24001.0_x64__8wekyb3d8bbwe
. in my installation (which works with DbgX.Shell.exe
) I don't have access to WinDbg either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like that we use
$executablePath = Join-Path $installDir "DbgX.Shell.exe"
as executingDbgX.Shell.exe
does not work for me, so potentially this is broken for others too.
I only use it when which
fails, so only for older versions of Windows 10, it seems. According to the current windbg.vm
code, it shouldn't work for these older versions of Windows either because WinDbgX
is hard-coded without VM-Assert-Path
.
I think without the
start
it should work and be equivalent to the code we had before:
VM-Install-Shortcut -toolName $toolName -category $category -executablePath "$toolName.exe" -consoleApp $true -runAsAdmin -iconLocation $iconLocation
If I do this, it will still not work for older versions of Windows 10, I think my solution might give it a chance to actually work.
9185d7d
to
dcc69b0
Compare
checksumType = "sha256" | ||
fileFullPath = Join-Path ${Env:TEMP} "$toolName.msixbundle" | ||
} | ||
Get-ChocolateyWebFile @packageArgs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a VM-Assert-Path $packageArgs.fileFullPath
to ensure the file has been downloaded before installing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not necessary, as Get-ChocolateyWebFile
will throw an error with "incorrect hash" if the file has not been downloaded.
|
||
$installDir = (Get-AppxPackage -Name "Microsoft.$toolName").InstallLocation | ||
$iconLocation = Join-Path $installDir "DbgX.Shell.exe" -Resolve | ||
$executablePath = "$(where.exe WinDbgX.exe)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'm looking into this and it looks like the same issue I ran into when I was trying to do the It seems that the Now the issue with not being able use I'm thinking that the better route might be what @Ana06 suggested with #1058 (comment) where we use a Console App, or an alternative that I think may be more suitable would be to just remove the Console App part:
In either case, the issue still remains that I will try to do a little more testing to see if I can find an alternative, but that's my current take at the moment. :) |
Judging from these posts, it sounds like the A suggested alternative that may work for us would be to create a command similar to Or a powershell command I'm not sure what the best solution really is, but for it to truly work on Windows Server 2019 we'd likely need one of these options, as I'd be willing to accept @Ana06 thoughts? |
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 $_ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is the route we want to take, as noted in my comments on the PR.
I think our current route of just making a shortcut may be the better alternative for the moment, unless we want to take the time to properly test and confirm one of the possible working solutions I noted in my comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least we need to continue on this error, or windows-2019
will fail on where.exe WinDbgX.exe
.
I don't think changing permission of the directory will solve anything, because on my side it's working with |
So we merge this PR with the line provided and create an issue to find a better way with |
Get-ChocolateyWebFile @packageArgs | ||
Add-AppxPackage -Path $packageArgs.fileFullPath | ||
|
||
$installDir = (Get-AppxPackage -Name "Microsoft.$toolName").InstallLocation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the error I got as well. @d35ha do you get the error for the icon or only when used as executable path?
|
||
$installDir = (Get-AppxPackage -Name "Microsoft.$toolName").InstallLocation | ||
$iconLocation = Join-Path $installDir "DbgX.Shell.exe" -Resolve | ||
$executablePath = "$(where.exe WinDbgXA.exe)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually where.exe
doesn't throw exceptions, it returns 1
in case of failure and since $ErrorActionPreference
is set to Stop
; the non-zero return code is treated as an exception with the stderr
as exception message.
It's a way better to use the powershell function Get-Command
with the ErrorAction
set to Continue
and to check the returned path if empty or not instead of relying on exceptions.
It would be like this:
$executablePath = (Get-Command WinDbgXA.exe -ea 0).Path
if (!$executablePath)
{
$executablePath = Join-Path $installDir DbgX.Shell.exe
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@d35ha your proposal could cause that $executablePath
is set to Join-Path $installDir DbgX.Shell.exe
which doesn't fail the package, but we know fails to open in Windows 10 because of being in a protected directory. This results in a broken shortcut without noticing during the installation, or am I missing something?
I rework WinDbg install to improve it (versioned + icon support #997)
Closes #997