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
5 changes: 5 additions & 0 deletions doc/release-notes/1.31/6516-upgrade-all-skip-reason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Bug Fixes

### Minor Bug Fixes

* `winget upgrade --all` now reports how many available upgrades were skipped because they do not apply to the selected scope or other requirements.
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(UpgradeIsPinned);
WINGET_DEFINE_RESOURCE_STRINGID(UpgradePinnedByUserCount);
WINGET_DEFINE_RESOURCE_STRINGID(UpgradeRequireExplicitCount);
WINGET_DEFINE_RESOURCE_STRINGID(UpgradeNotApplicableCount);
WINGET_DEFINE_RESOURCE_STRINGID(UpgradeUnknownVersionCount);
WINGET_DEFINE_RESOURCE_STRINGID(UpgradeUnknownVersionExplanation);
WINGET_DEFINE_RESOURCE_STRINGID(UriNotWellFormed);
Expand Down
8 changes: 8 additions & 0 deletions src/AppInstallerCLICore/Workflows/UpdateFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ namespace AppInstaller::CLI::Workflow
int packagesWithUnknownVersionSkipped = 0;
int packagesThatRequireExplicitSkipped = 0;
int packagesSkippedInstallTechnologyMismatch = 0;
int packagesSkippedNotApplicable = 0;

for (const auto& match : matches)
{
Expand Down Expand Up @@ -253,6 +254,7 @@ namespace AppInstaller::CLI::Workflow

if (updateContext.GetTerminationHR() == APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE)
{
++packagesSkippedNotApplicable;
continue;
}

Expand Down Expand Up @@ -314,6 +316,12 @@ namespace AppInstaller::CLI::Workflow
AICLI_LOG(CLI, Info, << packagesSkippedInstallTechnologyMismatch << " package(s) skipped due to install technology mismatch");
context.Reporter.Info() << Resource::String::UpgradeInstallTechnologyMismatchCount(packagesSkippedInstallTechnologyMismatch) << std::endl;
}

if (packagesSkippedNotApplicable > 0)
{
AICLI_LOG(CLI, Info, << packagesSkippedNotApplicable << " package(s) skipped because the available upgrade was not applicable");
context.Reporter.Info() << Resource::String::UpgradeNotApplicableCount(packagesSkippedNotApplicable) << std::endl;
}
}

void SelectSinglePackageVersionForInstallOrUpgrade::operator()(Execution::Context& context) const
Expand Down
4 changes: 4 additions & 0 deletions src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,10 @@ Please specify one of them using the --source option to proceed.</value>
<value>{0} package(s) are pinned and need to be explicitly upgraded.</value>
<comment>{Locked="{0}"} {0} is a placeholder that is replaced by an integer number of packages that require explicit upgrades.</comment>
</data>
<data name="UpgradeNotApplicableCount" xml:space="preserve">
<value>{0} package(s) were skipped because an available upgrade does not apply to the selected scope or other requirements.</value>
<comment>{Locked="{0}"} {0} is the number of packages skipped for this reason during winget upgrade --all.</comment>
</data>
<data name="InvalidArgumentWithoutQueryError" xml:space="preserve">
<value>The arguments provided can only be used with a query.</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/AppInstallerCLITests/AppInstallerCLITests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,9 @@
<CopyFileToFolders Include="TestData\UpdateFlowTest_Exe.yaml">
<DeploymentContent>true</DeploymentContent>
</CopyFileToFolders>
<CopyFileToFolders Include="TestData\UpdateFlowTest_Exe_MachineScope.yaml">
<DeploymentContent>true</DeploymentContent>
</CopyFileToFolders>
<CopyFileToFolders Include="TestData\UpdateFlowTest_Exe_ARPInstallerType.yaml">
<DeploymentContent>true</DeploymentContent>
</CopyFileToFolders>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,9 @@
<CopyFileToFolders Include="TestData\UpdateFlowTest_Exe.yaml">
<Filter>TestData</Filter>
</CopyFileToFolders>
<CopyFileToFolders Include="TestData\UpdateFlowTest_Exe_MachineScope.yaml">
<Filter>TestData</Filter>
</CopyFileToFolders>
<CopyFileToFolders Include="TestData\UpdateFlowTest_Exe_ARPInstallerType.yaml">
<Filter>TestData</Filter>
</CopyFileToFolders>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Update manifest with only a machine-scope installer.
Id: AppInstallerCliTest.TestExeInstaller
Version: 2.0.0.0
Name: AppInstaller Test Installer Machine Scope
Publisher: Microsoft Corporation
AppMoniker: AICLITestExeMachineScope
License: Test
Switches:
Custom: /custom
SilentWithProgress: /silentwithprogress
Silent: /silence
Update: /update
Installers:
- Arch: x64
Url: https://ThisIsNotUsed
InstallerType: exe
Scope: machine
Sha256: 65DB2F2AC2686C7F2FD69D4A4C6683B888DC55BFA20A0E32CA9F838B51689A3B
ManifestVersion: 0.1.0
17 changes: 17 additions & 0 deletions src/AppInstallerCLITests/UpdateFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ TEST_CASE("UpdateFlow_UpdateAllApplicable", "[UpdateFlow][workflow]")
OverrideForMSStore(context, true);
OverrideForPortableInstall(context);
context.Args.AddArg(Execution::Args::Type::All);
context.Args.AddArg(Execution::Args::Type::InstallScope, "user"sv);

UpgradeCommand update({});
update.Execute(context);
Expand All @@ -556,6 +557,22 @@ TEST_CASE("UpdateFlow_UpdateAllApplicable", "[UpdateFlow][workflow]")
REQUIRE(std::filesystem::exists(updatePortableResultPath.GetPath()));
}

TEST_CASE("UpdateFlow_UpdateAll_ReportsNotApplicable", "[UpdateFlow][workflow]")
{
std::ostringstream updateOutput;
TestContext context{ updateOutput, std::cin };
auto previousThreadGlobals = context.SetForCurrentThread();
OverrideForCompositeInstalledSource(context, CreateTestSource({ TSR::TestInstaller_Exe_NotApplicable }));
context.Args.AddArg(Execution::Args::Type::All);
context.Args.AddArg(Execution::Args::Type::InstallScope, "user"sv);

UpgradeCommand update({});
update.Execute(context);
INFO(updateOutput.str());

REQUIRE(updateOutput.str().find(Resource::String::UpgradeNotApplicableCount(1)) != std::string::npos);
}

TEST_CASE("UpdateFlow_UpdateAll_IncludeUnknown", "[UpdateFlow][workflow]")
{
TestCommon::TempFile updateExeResultPath("TestExeInstalled.txt");
Expand Down
16 changes: 16 additions & 0 deletions src/AppInstallerCLITests/WorkflowCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,22 @@ namespace TestCommon
PackageMatchFilter(PackageMatchField::Id, MatchType::Exact, "AppInstallerCliTest.TestExeInstaller")));
});

const TestSourceResult TestInstaller_Exe_NotApplicable(
"TestExeInstallerNotApplicable"sv,
[](std::vector<ResultMatch>& matches, std::weak_ptr<const ISource> source) {
auto manifest = YamlParser::CreateFromPath(TestDataFile("InstallFlowTest_Exe.yaml"));
auto manifest2 = YamlParser::CreateFromPath(TestDataFile("UpdateFlowTest_Exe_MachineScope.yaml"));
matches.emplace_back(
ResultMatch(
TestCompositePackage::Make(
manifest,
TestCompositePackage::MetadataMap{ { PackageVersionMetadata::InstalledType, "Exe" } },
std::vector<Manifest>{ manifest2, manifest },
source
),
PackageMatchFilter(PackageMatchField::Id, MatchType::Exact, "AppInstallerCliTest.TestExeInstaller")));
});

const TestSourceResult TestInstaller_Exe_DifferentInstallerType(
"TestExeInstallerWithDifferentInstalledType"sv,
[](std::vector<ResultMatch>& matches, std::weak_ptr<const ISource> source) {
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLITests/WorkflowCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace TestCommon
const extern TestSourceResult TestQuery_ReturnOne;
const extern TestSourceResult TestQuery_ReturnTwo;
const extern TestSourceResult TestInstaller_Exe;
const extern TestSourceResult TestInstaller_Exe_NotApplicable;
const extern TestSourceResult TestInstaller_Exe_Dependencies;
const extern TestSourceResult TestInstaller_Exe_DifferentInstallerType;
const extern TestSourceResult TestInstaller_Exe_ExpectedReturnCodes;
Expand Down
Loading