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

WinGet COM API for Repair #4736

Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2ee3cd6
Add Skeleton Implementation for Repair COM APIs Invocable from E2E Tests
Madhusudhan-MSFT Aug 7, 2024
24bd7a0
Implement Sample Interop Test for Winget Repair COM API
Madhusudhan-MSFT Aug 7, 2024
c9b38a4
[Updates to PackageManager.idl :] Add DownloadError status and rename…
Madhusudhan-MSFT Aug 15, 2024
b208c30
Added integration logic for Repair COM APIs:
Madhusudhan-MSFT Aug 15, 2024
79a4220
Added E2E tests for Winget COM Repair API:
Madhusudhan-MSFT Aug 15, 2024
1ab97db
Fix test failure in RepairCommand for NonstoreMSIX machine scope repair
Madhusudhan-MSFT Aug 15, 2024
fa8c6d5
Fix for RepairNonStoreMsixPackageWithMachineScope test failure
Madhusudhan-MSFT Aug 16, 2024
0e43224
Test failure fix for: RepairNonStoreMsixPackageWithMachineScope
Madhusudhan-MSFT Aug 16, 2024
7d112a4
Fix OOP COM Repair Test Failures
Madhusudhan-MSFT Aug 16, 2024
b34ad4b
Remove DownloadDirectory parameter and related logic
Madhusudhan-MSFT Aug 19, 2024
e6d2830
Merge branch 'master' of https://github.com/Madhusudhan-MSFT/winget-c…
Madhusudhan-MSFT Aug 20, 2024
01beb24
Add CLSID for RepairOptions in Microsoft.Management.Deployment.OutOf…
Madhusudhan-MSFT Aug 20, 2024
97d48e8
Remove DownloadDirectory methods from RepairOptions.h
Madhusudhan-MSFT Aug 20, 2024
ec3822f
Add Repair-WinGetPackage powershell cmdlet to Microsoft.WinGet.Client
Madhusudhan-MSFT Aug 23, 2024
752766b
Fix parameter name in RepairPackageCommand constructor to address Spe…
Madhusudhan-MSFT Aug 23, 2024
ffc4f8f
Fix Format.ps1xml formatting issue.
Madhusudhan-MSFT Aug 24, 2024
673e930
Add test case for Repair-WinGetPackage cmdlet
Madhusudhan-MSFT Aug 24, 2024
dc7b1aa
Refactor and optimize Repair-WinGetPackage tests
Madhusudhan-MSFT Aug 24, 2024
db2bc39
Fixed repair scenario test failures
Madhusudhan-MSFT Aug 24, 2024
e8e3013
Add BeforeEach blocks to initialize $expectedResult in tests, fixing …
Madhusudhan-MSFT Aug 25, 2024
4f68812
Refactored test cases for Install|Update|Uninstall-WinGetPackage cmdl…
Madhusudhan-MSFT Aug 25, 2024
dce2094
Expand Repair test scenario to include Installer-based Repair scenario.
Madhusudhan-MSFT Aug 25, 2024
995bd58
Correct comment in PackageManager.cpp for package repair
Madhusudhan-MSFT Aug 27, 2024
442a7a5
Refactor namespace for PSPackageRepairMode enum
Madhusudhan-MSFT Aug 27, 2024
828284f
Add Repair-WinGetPackage cmdlet documentation
Madhusudhan-MSFT Aug 27, 2024
d8553a4
Fix typo in -Confirm parameter type in Repair-WinGetPackage.md & Spel…
Madhusudhan-MSFT Aug 27, 2024
55efd2c
Add missing interfaces for RepairOptions and RepairResult collections
Madhusudhan-MSFT Sep 4, 2024
859cd04
Update `PackageManager.idl` comments and refactor powershell repair m…
Madhusudhan-MSFT Sep 6, 2024
08cb8fe
Merge branch 'master' into user/masudars/WinGet_Repair_COMAPI
Madhusudhan-MSFT Sep 7, 2024
84cadf0
Update contract version to 12 in PackageManager.idl
Madhusudhan-MSFT Sep 7, 2024
f9c3ecd
Revert "Update contract version to 12 in PackageManager.idl"
Madhusudhan-MSFT Sep 9, 2024
05220c8
Merge branch 'microsoft:master' into user/masudars/WinGet_Repair_COMAPI
Madhusudhan-MSFT Sep 10, 2024
3d3b435
Remove GetRepairProgress method from PackageManager
Madhusudhan-MSFT Sep 13, 2024
c3a2ccb
Merge branch 'user/masudars/WinGet_Repair_COMAPI' of https://github.c…
Madhusudhan-MSFT Sep 13, 2024
e915dde
Add new repair options and rename error codes (API Review Feedback)
Madhusudhan-MSFT Sep 28, 2024
d00a2aa
Update GUID and XML docs in ManagementDeploymentFactory
Madhusudhan-MSFT Oct 2, 2024
4f87879
Enhance error handling for Repair-WinGetPackage command-let
Madhusudhan-MSFT Oct 2, 2024
309e40e
PR Feedback implementation:
Madhusudhan-MSFT Oct 5, 2024
c0f12f3
Follow up PR feedback fixes:
Madhusudhan-MSFT Oct 5, 2024
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
1 change: 1 addition & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ florelis
FLUSHEACHLINE
forcerestart
gdi
GDK
Madhusudhan-MSFT marked this conversation as resolved.
Show resolved Hide resolved
HCCE
hcertstore
HCRYPTMSG
Expand Down
10 changes: 9 additions & 1 deletion src/AppInstallerCLICore/Commands/COMCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include "Workflows/PromptFlow.h"
#include "Workflows/UninstallFlow.h"
#include "Workflows/WorkflowBase.h"
#include "Workflows/DependenciesFlow.h"
#include "Workflows/DependenciesFlow.h"
#include "Workflows/RepairFlow.h"

namespace AppInstaller::CLI
{
Expand Down Expand Up @@ -45,4 +46,11 @@ namespace AppInstaller::CLI
context <<
Workflow::UninstallSinglePackage;
}

Madhusudhan-MSFT marked this conversation as resolved.
Show resolved Hide resolved
void COMRepairCommand::ExecuteInternal(Execution::Context& context) const
{
context <<
Workflow::SelectApplicableInstallerIfNecessary <<
Workflow::RepairSinglePackage;
}
}
10 changes: 10 additions & 0 deletions src/AppInstallerCLICore/Commands/COMCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,15 @@ namespace AppInstaller::CLI

protected:
void ExecuteInternal(Execution::Context& context) const override;
};

// IMPORTANT: To use this command, the caller should have already retrieved the InstalledPackageVersion and added it to the Context Data
struct COMRepairCommand final : public Command
{
constexpr static std::string_view CommandName = "repair"sv;
COMRepairCommand(std::string_view parent) : Command(CommandName, parent) {}

protected:
void ExecuteInternal(Execution::Context& context) const override;
};
}
10 changes: 9 additions & 1 deletion src/AppInstallerCLICore/ContextOrchestrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace AppInstaller::CLI::Execution
// Get command queue name based on command name.
std::string_view GetCommandQueueName(std::string_view commandName)
{
if (commandName == COMInstallCommand::CommandName || commandName == COMUninstallCommand::CommandName)
if (commandName == COMInstallCommand::CommandName || commandName == COMUninstallCommand::CommandName || commandName == COMRepairCommand::CommandName)
Madhusudhan-MSFT marked this conversation as resolved.
Show resolved Hide resolved
{
return OperationCommandQueueName;
}
Expand Down Expand Up @@ -363,6 +363,7 @@ namespace AppInstaller::CLI::Execution
case PackageOperationType::Upgrade: return "root:upgrade"sv;
case PackageOperationType::Uninstall: return "root:uninstall"sv;
case PackageOperationType::Download: return "root:download"sv;
case PackageOperationType::Repair: return "root:repair"sv;
default: return "unknown";
}
}
Expand Down Expand Up @@ -394,4 +395,11 @@ namespace AppInstaller::CLI::Execution
item->AddCommand(std::make_unique<::AppInstaller::CLI::COMDownloadCommand>(RootCommand::CommandName));
return item;
}

std::unique_ptr<OrchestratorQueueItem> OrchestratorQueueItemFactory::CreateItemForRepair(std::wstring packageId, std::wstring sourceId, std::unique_ptr<COMContext> context)
{
std::unique_ptr<OrchestratorQueueItem> item = std::make_unique<OrchestratorQueueItem>(OrchestratorQueueItemId(std::move(packageId), std::move(sourceId)), std::move(context), PackageOperationType::Repair);
item->AddCommand(std::make_unique<::AppInstaller::CLI::COMRepairCommand>(RootCommand::CommandName));
return item;
}
}
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/ContextOrchestrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace AppInstaller::CLI::Execution
Upgrade,
Uninstall,
Download,
Repair,
};

struct OrchestratorQueueItem
Expand Down Expand Up @@ -101,6 +102,7 @@ namespace AppInstaller::CLI::Execution
static std::unique_ptr<OrchestratorQueueItem> CreateItemForSearch(std::wstring packageId, std::wstring sourceId, std::unique_ptr<COMContext> context);
// Create queue item for download
static std::unique_ptr<OrchestratorQueueItem> CreateItemForDownload(std::wstring packageId, std::wstring sourceId, std::unique_ptr<COMContext> context);
static std::unique_ptr<OrchestratorQueueItem> CreateItemForRepair(std::wstring packageId, std::wstring sourceId, std::unique_ptr<COMContext> context);
Madhusudhan-MSFT marked this conversation as resolved.
Show resolved Hide resolved
};

struct ContextOrchestrator
Expand Down
29 changes: 24 additions & 5 deletions src/AppInstallerCLIE2ETests/Interop/GroupPolicyForInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace AppInstallerCLIE2ETests.Interop
{
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using AppInstallerCLIE2ETests.Helpers;
using Microsoft.Management.Deployment;
Expand Down Expand Up @@ -86,6 +87,10 @@ public void DisableWinGetPolicy()
Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message);
Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult);

groupPolicyException = Assert.Catch<GroupPolicyException>(() => { RepairOptions repairOptions = this.TestFactory.CreateRepairOptions(); });
Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message);
Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult);

// PackageManagerSettings is not implemented in context OutOfProcDev
if (this.TestFactory.Context == ClsidContext.InProc)
{
Expand Down Expand Up @@ -115,34 +120,48 @@ public async Task DisableWinGetCommandLineInterfacesPolicy()
options.CompositeSearchBehavior = CompositeSearchBehavior.AllCatalogs;
PackageCatalogReference compositeSource = packageManager.CreateCompositePackageCatalog(options);

string testPackageId = "AppInstallerTest.TestModifyRepair";
Madhusudhan-MSFT marked this conversation as resolved.
Show resolved Hide resolved

// Find package
var searchResult = this.FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.ExeInstallerPackageId);
var searchResult = this.FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, testPackageId);

// Configure installation
var installOptions = this.TestFactory.CreateInstallOptions();
installOptions.PackageInstallMode = PackageInstallMode.Silent;
Madhusudhan-MSFT marked this conversation as resolved.
Show resolved Hide resolved
installOptions.PreferredInstallLocation = installDir;
installOptions.AcceptPackageAgreements = true;
installOptions.ReplacementInstallerArguments = $"/InstallDir {installDir} /Version 2.0.0.0 /DisplayName TestModifyRepair /UseHKLM";

// Install
var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);
Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);

// Find package again, but this time it should detect the installed version
searchResult = this.FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.ExeInstallerPackageId);
searchResult = this.FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, testPackageId);
Assert.NotNull(searchResult.CatalogPackage.InstalledVersion);

// Repair
var repairOptions = this.TestFactory.CreateRepairOptions();
repairOptions.PackageRepairMode = PackageRepairMode.Silent;
var repairResult = await packageManager.RepairPackageAsync(searchResult.CatalogPackage, repairOptions);
Assert.AreEqual(RepairResultStatus.Ok, repairResult.Status);

// Uninstall
var uninstallResult = await packageManager.UninstallPackageAsync(searchResult.CatalogPackage, this.TestFactory.CreateUninstallOptions());
Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status);
Assert.True(TestCommon.VerifyTestExeUninstalled(installDir));

// Clean up.
if (Directory.Exists(installDir))
{
Directory.Delete(installDir, true);
}

// Download
var downloadResult = await packageManager.DownloadPackageAsync(searchResult.CatalogPackage, this.TestFactory.CreateDownloadOptions());
Assert.AreEqual(DownloadResultStatus.Ok, downloadResult.Status);
var packageVersion = "2.0.0.0";
string downloadDir = Path.Combine(TestCommon.GetDefaultDownloadDirectory(), $"{Constants.ExeInstallerPackageId}_{packageVersion}");
Assert.True(TestCommon.VerifyInstallerDownload(downloadDir, "TestExeInstaller", packageVersion, ProcessorArchitecture.X86, TestCommon.Scope.Unknown, PackageInstallerType.Exe));
string downloadDir = Path.Combine(TestCommon.GetDefaultDownloadDirectory(), $"{testPackageId}_{packageVersion}");
Assert.True(TestCommon.VerifyInstallerDownload(downloadDir, "TestModifyRepair", packageVersion, ProcessorArchitecture.X86, TestCommon.Scope.Unknown, PackageInstallerType.Burn, "en-US"));
}
}
}
Loading
Loading