Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion doc/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## New in v1.29

Nothing yet.
### `--ignore-unavailable` flag for `install`

Added a new `--ignore-unavailable` flag to the `install` command. When installing multiple packages, this flag allows the operation to continue with the remaining packages instead of failing entirely when one or more packages are not found in the configured sources. This brings the same behavior previously available with `import --ignore-unavailable` to direct multi-package installs.

## Bug Fixes

Expand Down
1 change: 1 addition & 0 deletions doc/windows/package-manager/winget/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ The options allow you to customize the install experience to meet your needs.
| **--ignore-security-hash** | Ignore the installer hash check failure |
| **--skip-dependencies** | Skip processing package dependencies and Windows features |
| **--ignore-local-archive-malware-scan** | Ignore the malware scan performed as part of installing an archive-type package from a local manifest |
| **--ignore-unavailable** | Ignore unavailable packages when installing multiple packages; remaining packages continue to install |
| **--dependency-source** | Find package dependencies using the specified source |
| **--accept-package-agreements** | Accept all license agreements for packages |
| **--no-upgrade** | Skip upgrade if an installed version already exists |
Expand Down
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ namespace AppInstaller::CLI
return Argument{ type, Resource::String::DependenciesOnlyArgumentDescription, ArgumentType::Flag, false };
case Args::Type::IgnoreLocalArchiveMalwareScan:
return Argument{ type, Resource::String::IgnoreLocalArchiveMalwareScanArgumentDescription, ArgumentType::Flag, Settings::TogglePolicy::Policy::LocalArchiveMalwareScanOverride, Settings::BoolAdminSetting::LocalArchiveMalwareScanOverride };
case Args::Type::IgnoreUnavailable:
return Argument{ type, Resource::String::IgnoreUnavailableArgumentDescription, ArgumentType::Flag };
case Args::Type::SourceName:
return Argument{ type, Resource::String::SourceNameArgumentDescription, ArgumentType::Positional, false };
case Args::Type::SourceArg:
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Commands/ImportCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace AppInstaller::CLI
{
return {
Argument{ Execution::Args::Type::ImportFile, Resource::String::ImportFileArgumentDescription, ArgumentType::Positional, true },
Argument{ Execution::Args::Type::IgnoreUnavailable, Resource::String::ImportIgnoreUnavailableArgumentDescription, ArgumentType::Flag },
Argument::ForType(Execution::Args::Type::IgnoreUnavailable),
Argument{ Execution::Args::Type::IgnoreVersions, Resource::String::ImportIgnorePackageVersionsArgumentDescription, ArgumentType::Flag },
Argument::ForType(Execution::Args::Type::NoUpgrade),
Argument::ForType(Execution::Args::Type::AcceptPackageAgreements),
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 @@ -58,6 +58,7 @@ namespace AppInstaller::CLI
Argument::ForType(Args::Type::UninstallPrevious),
Argument::ForType(Args::Type::Force),
Argument{ Args::Type::IncludeUnknown, Resource::String::IncludeUnknownArgumentDescription, ArgumentType::Flag, Argument::Visibility::Hidden},
Argument::ForType(Args::Type::IgnoreUnavailable),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but we really need to sort all these arguments...

};
}

Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,14 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(IdArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(IgnoreLocalArchiveMalwareScanArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(IgnoreResumeLimitArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(IgnoreUnavailableArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(IgnoreWarningsArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(ImportCommandLongDescription);
WINGET_DEFINE_RESOURCE_STRINGID(ImportCommandReportDependencies);
WINGET_DEFINE_RESOURCE_STRINGID(ImportCommandShortDescription);
WINGET_DEFINE_RESOURCE_STRINGID(ImportFileArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(ImportFileHasInvalidSchema);
WINGET_DEFINE_RESOURCE_STRINGID(ImportIgnorePackageVersionsArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(ImportIgnoreUnavailableArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(ImportInstallFailed);
WINGET_DEFINE_RESOURCE_STRINGID(ImportSourceNotInstalled);
WINGET_DEFINE_RESOURCE_STRINGID(IncludePinnedArgumentDescription);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ They can be configured through the settings file 'winget settings'.</value>
<value>Package is already installed: {0}</value>
<comment>{Locked="{0}"} Message displayed to inform the user that an application package is already installed. {0} is a placeholder replaced by the package identifier or search query.</comment>
</data>
<data name="ImportIgnoreUnavailableArgumentDescription" xml:space="preserve">
<data name="IgnoreUnavailableArgumentDescription" xml:space="preserve">
<value>Ignore unavailable packages</value>
</data>
<data name="ExportIncludeVersionsArgumentDescription" xml:space="preserve">
Expand Down
25 changes: 24 additions & 1 deletion src/AppInstallerCLITests/InstallFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ TEST_CASE("InstallFlow_UnsupportedArguments_Error", "[InstallFlow][workflow]")
install.Execute(context);
INFO(installOutput.str());

// Verify unsupported arguments error message is shown
// Verify unsupported arguments error message is shown
REQUIRE(context.GetTerminationHR() == APPINSTALLER_CLI_ERROR_UNSUPPORTED_ARGUMENT);
REQUIRE(!std::filesystem::exists(installResultPath.GetPath()));
REQUIRE(installOutput.str().find(Resource::LocString(Resource::String::UnsupportedArgument).get()) != std::string::npos);
Expand Down Expand Up @@ -1343,6 +1343,29 @@ TEST_CASE("InstallFlow_InstallMultiple_SearchFailed", "[InstallFlow][workflow][M
REQUIRE_TERMINATED_WITH(context, APPINSTALLER_CLI_ERROR_NOT_ALL_QUERIES_FOUND_SINGLE);
}

TEST_CASE("InstallFlow_InstallMultiple_IgnoreUnavailable", "[InstallFlow][workflow][MultiQuery]")
{
TestCommon::TempFile exeInstallResultPath("TestExeInstalled.txt");

std::ostringstream installOutput;
TestContext context{ installOutput, std::cin };
auto previousThreadGlobals = context.SetForCurrentThread();
OverrideForShellExecute(context);
OverrideForOpenSource(context, CreateTestSource({ TSR::TestInstaller_Exe }), true);
context.Args.AddArg(Execution::Args::Type::MultiQuery, TSR::TestInstaller_Exe.Query);
context.Args.AddArg(Execution::Args::Type::MultiQuery, TSR::TestInstaller_Msix.Query);
context.Args.AddArg(Execution::Args::Type::IgnoreUnavailable);

InstallCommand installCommand({});
installCommand.Execute(context);
INFO(installOutput.str());

// Verify the available package was installed despite the missing one,
// and the unavailable package was reported as not found.
REQUIRE(std::filesystem::exists(exeInstallResultPath.GetPath()));
REQUIRE(installOutput.str().find(Resource::LocString(Resource::String::MultiQueryPackageNotFound(LocIndString{ TSR::TestInstaller_Msix.Query })).get()) != std::string::npos);
}

TEST_CASE("InstallFlow_InstallAcquiresLock", "[InstallFlow][workflow]")
{
TestCommon::TempFile installResultPath("TestExeInstalled.txt");
Expand Down
Loading