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

Implementation for Portable Uninstall and Upgrade #2140

Merged
merged 26 commits into from
May 14, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion schemas/JSON/settings/settings.schema.0.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"description": "Uninstall settings",
"type": "object",
"properties": {
"purgePortableApp": {
"purgePortablePackage": {
"description": "Controls whether the default behavior for uninstall removes all files and directories relevant to this package. Only applies to the portable installerType.",
"type": "boolean",
"default": false
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
<ClInclude Include="Workflows\ImportExportFlow.h" />
<ClInclude Include="Workflows\MsiInstallFlow.h" />
<ClInclude Include="Workflows\MSStoreInstallerHandler.h" />
<ClInclude Include="Workflows\PortableInstallFlow.h" />
<ClInclude Include="Workflows\PortableFlow.h" />
<ClInclude Include="Workflows\SettingsFlow.h" />
<ClInclude Include="Workflows\ShellExecuteInstallerHandler.h" />
<ClInclude Include="Workflows\InstallFlow.h" />
Expand Down Expand Up @@ -333,7 +333,7 @@
<ClCompile Include="Workflows\ImportExportFlow.cpp" />
<ClCompile Include="Workflows\MsiInstallFlow.cpp" />
<ClCompile Include="Workflows\MSStoreInstallerHandler.cpp" />
<ClCompile Include="Workflows\PortableInstallFlow.cpp" />
<ClCompile Include="Workflows\PortableFlow.cpp" />
<ClCompile Include="Workflows\SettingsFlow.cpp" />
<ClCompile Include="Workflows\ShellExecuteInstallerHandler.cpp" />
<ClCompile Include="Workflows\InstallFlow.cpp" />
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
<ClInclude Include="Public\COMContext.h">
<Filter>Public</Filter>
</ClInclude>
<ClInclude Include="Workflows\PortableInstallFlow.h">
<ClInclude Include="Workflows\PortableFlow.h">
<Filter>Workflows</Filter>
</ClInclude>
</ItemGroup>
Expand Down Expand Up @@ -322,7 +322,7 @@
<ClCompile Include="Workflows\DownloadFlow.cpp">
<Filter>Workflows</Filter>
</ClCompile>
<ClCompile Include="Workflows\PortableInstallFlow.cpp">
<ClCompile Include="Workflows\PortableFlow.cpp">
<Filter>Workflows</Filter>
</ClCompile>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace AppInstaller::CLI

void Argument::ValidatePackageSelectionArgumentSupplied(const Execution::Args& args)
{
for (Args::Type type : { Args::Type::Query, Args::Type::Manifest, Args::Type::Id, Args::Type::Name, Args::Type::Moniker, Args::Type::Tag, Args::Type::Command })
for (Args::Type type : { Args::Type::Query, Args::Type::Manifest, Args::Type::Id, Args::Type::Name, Args::Type::Moniker, Args::Type::ProductCode, Args::Type::Tag, Args::Type::Command })
{
if (args.Contains(type))
{
Expand Down
10 changes: 10 additions & 0 deletions src/AppInstallerCLICore/Commands/UninstallCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ namespace AppInstaller::CLI
Argument::ForType(Args::Type::Id),
Argument::ForType(Args::Type::Name),
Argument::ForType(Args::Type::Moniker),
Argument::ForType(Args::Type::ProductCode),
Argument::ForType(Args::Type::Version),
Argument::ForType(Args::Type::Channel),
Argument::ForType(Args::Type::Source),
Argument::ForType(Args::Type::Exact),
Argument::ForType(Args::Type::Interactive),
Argument::ForType(Args::Type::Silent),
Argument::ForType(Args::Type::Purge),
Argument::ForType(Args::Type::Preserve),
ryfu-msft marked this conversation as resolved.
Show resolved Hide resolved
Argument::ForType(Args::Type::Log),
Argument::ForType(Args::Type::CustomHeader),
Argument::ForType(Args::Type::AcceptSourceAgreements),
Expand Down Expand Up @@ -70,6 +73,7 @@ namespace AppInstaller::CLI
case Execution::Args::Type::Version:
case Execution::Args::Type::Channel:
case Execution::Args::Type::Source:
case Execution::Args::Type::ProductCode:
context <<
Workflow::CompleteWithSingleSemanticsForValueUsingExistingSource(valueType);
break;
Expand All @@ -90,13 +94,19 @@ namespace AppInstaller::CLI
execArgs.Contains(Execution::Args::Type::Id) ||
execArgs.Contains(Execution::Args::Type::Name) ||
execArgs.Contains(Execution::Args::Type::Moniker) ||
execArgs.Contains(Execution::Args::Type::ProductCode) ||
execArgs.Contains(Execution::Args::Type::Version) ||
execArgs.Contains(Execution::Args::Type::Channel) ||
execArgs.Contains(Execution::Args::Type::Source) ||
execArgs.Contains(Execution::Args::Type::Exact)))
{
throw CommandException(Resource::String::BothManifestAndSearchQueryProvided, "");
}

if (execArgs.Contains(Execution::Args::Type::Purge) && execArgs.Contains(Execution::Args::Type::Preserve))
{
throw CommandException(Resource::String::BothPurgeAndPreserveFlagsProvided, "");
}
ryfu-msft marked this conversation as resolved.
Show resolved Hide resolved
}

void UninstallCommand::ExecuteInternal(Execution::Context& context) const
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 @@ -93,6 +93,7 @@ namespace AppInstaller::CLI
Argument::ForType(Args::Type::Exact),
Argument::ForType(Args::Type::Interactive),
Argument::ForType(Args::Type::Silent),
Argument::ForType(Args::Type::Purge),
Argument::ForType(Args::Type::Log),
Argument::ForType(Args::Type::Override),
Argument::ForType(Args::Type::InstallLocation),
Expand Down
8 changes: 8 additions & 0 deletions src/AppInstallerCLICore/ExecutionContextData.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <winget/RepositorySource.h>
#include <winget/Manifest.h>
#include <winget/ARPCorrelation.h>
#include <winget/PortableARPEntry.h>
#include "CompletionData.h"
#include "PackageCollection.h"
#include "Workflows/WorkflowBase.h"
Expand Down Expand Up @@ -52,6 +53,7 @@ namespace AppInstaller::CLI::Execution
Dependencies,
DependencySource,
AllowedArchitectures,
PortableARPEntry,
Max
};

Expand Down Expand Up @@ -214,5 +216,11 @@ namespace AppInstaller::CLI::Execution
{
using value_t = std::vector<Utility::Architecture>;
};

template <>
struct DataMapping<Data::PortableARPEntry>
{
using value_t = Registry::Portable::PortableARPEntry;
};
}
}
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(AvailableSubcommands);
WINGET_DEFINE_RESOURCE_STRINGID(AvailableUpgrades);
WINGET_DEFINE_RESOURCE_STRINGID(BothManifestAndSearchQueryProvided);
WINGET_DEFINE_RESOURCE_STRINGID(BothPurgeAndPreserveFlagsProvided);
WINGET_DEFINE_RESOURCE_STRINGID(Cancelled);
WINGET_DEFINE_RESOURCE_STRINGID(ChannelArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(Command);
Expand Down Expand Up @@ -82,6 +83,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(FeaturesProperty);
WINGET_DEFINE_RESOURCE_STRINGID(FeaturesStatus);
WINGET_DEFINE_RESOURCE_STRINGID(FileArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(FilesRemainInInstallDirectory);
WINGET_DEFINE_RESOURCE_STRINGID(FlagContainAdjoinedError);
WINGET_DEFINE_RESOURCE_STRINGID(GetManifestResultVersionNotFound);
WINGET_DEFINE_RESOURCE_STRINGID(HashCommandLongDescription);
Expand Down Expand Up @@ -210,6 +212,9 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(PoliciesEnabled);
WINGET_DEFINE_RESOURCE_STRINGID(PoliciesPolicy);
WINGET_DEFINE_RESOURCE_STRINGID(PoliciesState);
WINGET_DEFINE_RESOURCE_STRINGID(PortableHashMismatchOverridden);
WINGET_DEFINE_RESOURCE_STRINGID(PortableHashMismatchOverrideRequired);
WINGET_DEFINE_RESOURCE_STRINGID(PortableInstallFailed);
WINGET_DEFINE_RESOURCE_STRINGID(PortableRegistryCollisionOverridden);
WINGET_DEFINE_RESOURCE_STRINGID(PositionArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(PreserveArgumentDescription);
Expand All @@ -218,6 +223,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(PromptOptionNo);
WINGET_DEFINE_RESOURCE_STRINGID(PromptOptionYes);
WINGET_DEFINE_RESOURCE_STRINGID(PurgeArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(PurgeInstallDirectory);
WINGET_DEFINE_RESOURCE_STRINGID(QueryArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(RainbowArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(RenameArgumentDescription);
Expand Down
9 changes: 8 additions & 1 deletion src/AppInstallerCLICore/Workflows/InstallFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "ShellExecuteInstallerHandler.h"
#include "MSStoreInstallerHandler.h"
#include "MsiInstallFlow.h"
#include "PortableInstallFlow.h"
#include "PortableFlow.h"
#include "WorkflowBase.h"
#include "Workflows/DependenciesFlow.h"
#include <AppInstallerDeployment.h>
Expand Down Expand Up @@ -269,6 +269,13 @@ namespace AppInstaller::CLI::Workflow
(isUpdate ? MSStoreUpdate : MSStoreInstall);
break;
case InstallerTypeEnum::Portable:
if (isUpdate && installer.UpdateBehavior == UpdateBehaviorEnum::UninstallPrevious)
ryfu-msft marked this conversation as resolved.
Show resolved Hide resolved
{
context <<
GetUninstallInfo <<
ExecuteUninstaller;
ryfu-msft marked this conversation as resolved.
Show resolved Hide resolved
context.ClearFlags(Execution::ContextFlag::InstallerExecutionUseUpdate);
}
context << PortableInstall;
break;
default:
Expand Down
Loading