Skip to content

Commit 735d2b3

Browse files
committed
Fix WinGet not finding an applicable uninstall version (fix #3307)
1 parent 72909b9 commit 735d2b3

3 files changed

Lines changed: 26 additions & 25 deletions

File tree

src/UniGetUI.PackageEngine.Enums/OverridenInstallationOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public struct OverridenInstallationOptions
66
public PackageScope? Scope;
77
public bool? RunAsAdministrator;
88
public bool PowerShell_DoNotSetScopeParameter = false;
9+
public bool? WinGet_SpecifyVersion = null;
910

1011
public OverridenInstallationOptions(PackageScope? scope = null, bool? runAsAdministrator = null)
1112
{

src/UniGetUI.PackageEngine.Managers.WinGet/Helpers/WinGetPkgOperationHelper.cs

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected override IReadOnlyList<string> _getOperationParameters(IPackage packag
4343
_ => []
4444
});
4545

46-
if (operation is OperationType.Uninstall && package.Version != "Unknown")
46+
if (operation is OperationType.Uninstall && package.Version != "Unknown" && package.OverridenOptions.WinGet_SpecifyVersion is not false)
4747
{
4848
parameters.AddRange(["--version", $"\"{package.Version}\""]);
4949
}
@@ -135,55 +135,54 @@ protected override OperationVeredict _getOperationResult(
135135
// See https://github.com/microsoft/winget-cli/blob/master/doc/windows/package-manager/winget/returnCodes.md for reference
136136
uint uintCode = (uint)returnCode;
137137

138-
if (uintCode == 0x8A150109)
139-
{
140-
// If the user is required to restart the system to complete the installation
138+
if (uintCode is 0x8A150109)
139+
{ // TODO: Restart required to finish installation
141140
if (operation is OperationType.Update) MarkUpgradeAsDone(package);
142-
//return OperationVeredict.RestartRequired;
143141
return OperationVeredict.Success;
144142
}
145143

146-
if (uintCode == 0x8A150077 || uintCode == 0x8A15010C || uintCode == 0x8A150005)
147-
{
144+
if (uintCode is 0x8A150077 or 0x8A15010C or 0x8A150005)
145+
{ // At some point, the user clicked cancel or Ctrl+C
148146
return OperationVeredict.Canceled;
149147
}
150148

151-
if (uintCode == 0x8A150011)
152-
{
153-
// TODO: Needs skip checksum
149+
if (operation is OperationType.Uninstall && uintCode is 0x8A150017 && package.OverridenOptions.WinGet_SpecifyVersion is not false)
150+
{ // No manifest found matching criteria
151+
package.OverridenOptions.WinGet_SpecifyVersion = false;
152+
return OperationVeredict.AutoRetry;
153+
}
154+
155+
if (uintCode is 0x8A150011)
156+
{ // TODO: Integrity failed
154157
return OperationVeredict.Failure;
155158
}
156159

157-
if (uintCode == 0x8A15002B)
158-
{
160+
if (uintCode is 0x8A15002B)
161+
{ // TODO: The update cannot be installed (not applicable)
159162
return OperationVeredict.Failure;
160163
}
161164

162-
if (uintCode == 0x8A15010D || uintCode == 0x8A15004F || uintCode == 0x8A15010E)
163-
{
164-
// Application is already installed
165+
if (uintCode is 0x8A15010D or 0x8A15004F or 0x8A15010E)
166+
{ // Application is already installed
165167
if (operation is OperationType.Update) MarkUpgradeAsDone(package);
166168
return OperationVeredict.Success;
167169
}
168170

169-
if (returnCode == 0)
170-
{
171-
// Operation succeeded
171+
if (returnCode is 0)
172+
{ // Operation succeeded
172173
if (operation is OperationType.Update) MarkUpgradeAsDone(package);
173174
return OperationVeredict.Success;
174175
}
175176

176-
if (uintCode == 0x8A150056 && package.OverridenOptions.RunAsAdministrator != false && !CoreTools.IsAdministrator())
177-
{
178-
// Installer can't run elevated
177+
if (uintCode is 0x8A150056 && package.OverridenOptions.RunAsAdministrator is not false && !CoreTools.IsAdministrator())
178+
{ // Installer can't run elevated, but this condition hasn't been forced on UniGetUI
179179
package.OverridenOptions.RunAsAdministrator = false;
180180
return OperationVeredict.AutoRetry;
181181
}
182182

183-
if ((uintCode is 0x8A150019 or 0x80073D28) && package.OverridenOptions.RunAsAdministrator != true)
184-
{
183+
if ((uintCode is 0x8A150019 or 0x80073D28) && package.OverridenOptions.RunAsAdministrator is not true)
184+
{ // Installer needs to run elevated, handle autoelevation
185185
// Code 0x80073D28 was added after https://github.com/marticliment/UniGetUI/issues/3093
186-
// Installer needs to run elevated
187186
package.OverridenOptions.RunAsAdministrator = true;
188187
return OperationVeredict.AutoRetry;
189188
}

src/UniGetUI/Pages/DialogPages/DialogHelper_Operations.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ public static async Task ShowLiveLogDialog(AbstractOperation operation)
179179
var LiveOutputTextBlock = new RichTextBlock
180180
{
181181
Margin = new Thickness(8),
182-
FontFamily = new FontFamily("Consolas")
182+
FontFamily = new FontFamily("Consolas"),
183+
TextWrapping = TextWrapping.WrapWholeWords
183184
};
184185

185186
var LiveOutputScrollBar = new ScrollViewer

0 commit comments

Comments
 (0)