Skip to content
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

Add Experimental Argument for UninstallPrevious in Upgrade Flow #2755

Merged
merged 3 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ You can enable the feature as shown below.
},
```

### uninstallPreviousArgument

This feature enables the Windows Package Manager to override the upgrade behavior to UninstallPrevious by passing the `--uninstall-previous` argument with the upgrade or install command.
You can enable the feature as shown below.

```json
"experimentalFeatures": {
"uninstallPreviousArgument": true
},
```

### dependencies

Experimental feature with the aim of managing dependencies, as of now it only shows package dependency information. You can enable the feature as shown below.
Expand Down
5 changes: 5 additions & 0 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@
"description": "Enable argument to open default logs location",
"type": "boolean",
"default": false
},
"uninstallPreviousArgument": {
"description": "Enable argument to override upgrade behavior to UninstallPrevious",
"type": "boolean",
"default": false
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ namespace AppInstaller::CLI
return Argument{ "product-code"_liv, NoAlias, Args::Type::ProductCode, Resource::String::ProductCodeArgumentDescription, ArgumentType::Standard, false };
case Args::Type::OpenLogs:
return Argument{ "open-logs"_liv, NoAlias, "logs"_liv, Args::Type::OpenLogs, Resource::String::OpenLogsArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::OpenLogsArgument};
case Args::Type::UninstallPrevious:
return Argument{ "uninstall-previous"_liv, NoAlias, Args::Type::UninstallPrevious, Resource::String::UninstallPreviousArgumentDescription, ArgumentType::Flag, ExperimentalFeature::Feature::UninstallPreviousArgument };
case Args::Type::Force:
return Argument{ "force"_liv, NoAlias, Args::Type::Force, Resource::String::ForceArgumentDescription, ArgumentType::Flag, false };
default:
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Commands/InstallCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace AppInstaller::CLI
Argument::ForType(Args::Type::CustomHeader),
Argument::ForType(Args::Type::AcceptSourceAgreements),
Argument::ForType(Args::Type::Rename),
Argument::ForType(Args::Type::UninstallPrevious),
Argument::ForType(Args::Type::Force),
};
}
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Commands/UpgradeCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ namespace AppInstaller::CLI
Argument::ForType(Execution::Args::Type::CustomHeader),
Argument{ "all"_liv, 'r', "recurse"_liv, Args::Type::All, Resource::String::UpdateAllArgumentDescription, ArgumentType::Flag },
Argument{ "include-unknown"_liv, 'u', "unknown"_liv, Args::Type::IncludeUnknown, Resource::String::IncludeUnknownArgumentDescription, ArgumentType::Flag },
Argument::ForType(Args::Type::UninstallPrevious),
Argument::ForType(Args::Type::Force),
};
}
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/ExecutionArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ namespace AppInstaller::CLI::Execution
// Upgrade command
All, // Used in Update command to update all installed packages to latest
IncludeUnknown, // Used in Upgrade command to allow upgrades of packages with unknown versions
UninstallPrevious, // Used in Upgrade command to override the default manifest behavior to UninstallPrevious

// Show command
ListVersions, // Used in Show command to list all available versions of an app
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(UninstallFailedWithCode);
WINGET_DEFINE_RESOURCE_STRINGID(UninstallFlowStartingPackageUninstall);
WINGET_DEFINE_RESOURCE_STRINGID(UninstallFlowUninstallSuccess);
WINGET_DEFINE_RESOURCE_STRINGID(UninstallPreviousArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(UnrecognizedCommand);
WINGET_DEFINE_RESOURCE_STRINGID(UnsupportedArgument);
WINGET_DEFINE_RESOURCE_STRINGID(UpdateAllArgumentDescription);
Expand Down
5 changes: 3 additions & 2 deletions src/AppInstallerCLICore/Workflows/InstallFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ namespace AppInstaller::CLI::Workflow
{
bool isUpdate = WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerExecutionUseUpdate);
UpdateBehaviorEnum updateBehavior = context.Get<Execution::Data::Installer>().value().UpdateBehavior;
bool doUninstallPrevious = isUpdate && (updateBehavior == UpdateBehaviorEnum::UninstallPrevious || context.Args.Contains(Execution::Args::Type::UninstallPrevious));
Trenly marked this conversation as resolved.
Show resolved Hide resolved

switch (m_installerType)
{
Expand All @@ -266,7 +267,7 @@ namespace AppInstaller::CLI::Workflow
case InstallerTypeEnum::Msi:
case InstallerTypeEnum::Nullsoft:
case InstallerTypeEnum::Wix:
if (isUpdate && updateBehavior == UpdateBehaviorEnum::UninstallPrevious)
if (doUninstallPrevious)
{
context <<
GetUninstallInfo <<
Expand All @@ -291,7 +292,7 @@ namespace AppInstaller::CLI::Workflow
(isUpdate ? MSStoreUpdate : MSStoreInstall);
break;
case InstallerTypeEnum::Portable:
if (isUpdate && updateBehavior == UpdateBehaviorEnum::UninstallPrevious)
if (doUninstallPrevious)
{
context <<
GetUninstallInfo <<
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLIE2ETests/BaseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void InitializeAllFeatures(bool status)
this.ConfigureFeature("directMSI", status);
this.ConfigureFeature("zipInstall", status);
this.ConfigureFeature("openLogsArgument", status);
this.ConfigureFeature("uninstallPreviousArgument", status);
}
}
}
1 change: 1 addition & 0 deletions src/AppInstallerCLIE2ETests/FeaturesCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void EnableExperimentalFeatures()
this.ConfigureFeature("experimentalCmd", true);
this.ConfigureFeature("directMSI", true);
this.ConfigureFeature("openLogsArgument", true);
this.ConfigureFeature("uninstallPreviousArgument", true);
var result = TestCommon.RunAICLICommand("features", string.Empty);
Assert.True(result.StdOut.Contains("Enabled"));
}
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLIE2ETests/SetUpFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public void InitializeWingetSettings()
dependencies = false,
directMSI = false,
openLogsArgument = false,
uninstallPreviousArgument = false,
},
debugging = new
{
Expand Down
3 changes: 3 additions & 0 deletions src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,9 @@ They can be configured through the settings file 'winget settings'.</value>
<data name="UnexpectedErrorExecutingCommand" xml:space="preserve">
<value>An unexpected error occurred while executing the command:</value>
</data>
<data name="UninstallPreviousArgumentDescription" xml:space="preserve">
<value>Uninstall the previous version of the package during upgrade</value>
</data>
<data name="UnrecognizedCommand" xml:space="preserve">
<value>Unrecognized command</value>
</data>
Expand Down
4 changes: 4 additions & 0 deletions src/AppInstallerCommonCore/ExperimentalFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ namespace AppInstaller::Settings
return userSettings.Get<Setting::EFOpenLogsArgument>();
case ExperimentalFeature::Feature::Pinning:
return userSettings.Get<Setting::EFPinning>();
case ExperimentalFeature::Feature::UninstallPreviousArgument:
return userSettings.Get<Setting::EFUninstallPreviousArgument>();
default:
THROW_HR(E_UNEXPECTED);
}
Expand Down Expand Up @@ -85,6 +87,8 @@ namespace AppInstaller::Settings
return ExperimentalFeature{ "Open Logs Argument", "openLogsArgument", "https://aka.ms/winget-settings", Feature::OpenLogsArgument };
case Feature::Pinning:
return ExperimentalFeature{ "Package Pinning", "pinning", "https://aka.ms/winget-settings", Feature::Pinning};
case Feature::UninstallPreviousArgument:
return ExperimentalFeature{ "Uninstall Previous Argument", "uninstallPreviousArgument", "https://aka.ms/winget-settings", Feature::UninstallPreviousArgument };
default:
THROW_HR(E_UNEXPECTED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace AppInstaller::Settings
ZipInstall = 0x4,
OpenLogsArgument = 0x8,
Pinning = 0x10,
UninstallPreviousArgument = 0x20,
Max, // This MUST always be after all experimental features

// Features listed after Max will not be shown with the features command
Expand Down
2 changes: 2 additions & 0 deletions src/AppInstallerCommonCore/Public/winget/UserSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace AppInstaller::Settings
EFZipInstall,
EFOpenLogsArgument,
EFPinning,
EFUninstallPreviousArgument,
// Telemetry
TelemetryDisable,
// Install behavior
Expand Down Expand Up @@ -150,6 +151,7 @@ namespace AppInstaller::Settings
SETTINGMAPPING_SPECIALIZATION(Setting::EFZipInstall, bool, bool, false, ".experimentalFeatures.zipInstall"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::EFOpenLogsArgument, bool, bool, false, ".experimentalFeatures.openLogsArgument"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::EFPinning, bool, bool, false, ".experimentalFeatures.pinning"sv);
SETTINGMAPPING_SPECIALIZATION(Setting::EFUninstallPreviousArgument, bool, bool, false, ".experimentalFeatures.uninstallPreviousArgument"sv);
// Telemetry
SETTINGMAPPING_SPECIALIZATION(Setting::TelemetryDisable, bool, bool, false, ".telemetry.disable"sv);
// Install behavior
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCommonCore/UserSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ namespace AppInstaller::Settings
WINGET_VALIDATE_PASS_THROUGH(EFZipInstall)
WINGET_VALIDATE_PASS_THROUGH(EFOpenLogsArgument)
WINGET_VALIDATE_PASS_THROUGH(EFPinning)
WINGET_VALIDATE_PASS_THROUGH(EFUninstallPreviousArgument)
WINGET_VALIDATE_PASS_THROUGH(TelemetryDisable)
WINGET_VALIDATE_PASS_THROUGH(InteractivityDisable)
WINGET_VALIDATE_PASS_THROUGH(EnableSelfInitiatedMinidump)
Expand Down