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
Changes from 1 commit
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
Next Next commit
Add Skeleton Implementation for Repair COM APIs Invocable from E2E Tests
This commit includes:
1. Necessary additions and updates to PackageManager.idl to define repair-specific COM API contracts and runtime class declarations.
2. Implementation of repair-specific runtime class and PackageManager runtime class repair contract methods skeleton.
3. GUID mapping for In-proc and Out-of-proc COM API class definitions.
4. Updates to `Package.appxmanifest` and `Microsoft.Management.Deployment.InProc.dll.manifest` to include new COM class entries for `RepairOptions`.
5. Updates to `ComClsids.cpp` and `ComClsids.h` to include CLSID definitions and redirection logic for `RepairOptions`.
6. Modifications to `ClassesDefinition.cs` and `WinGetProjectionFactory.cs` to define and create instances of `RepairOptions`and repair com api support for C# winrt projection interop library.
Madhusudhan-MSFT committed Aug 7, 2024
commit 2ee3cd6e33153afc1a872a5575a170b5d6fcad28
2 changes: 2 additions & 0 deletions src/AppInstallerCLIPackage/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -78,6 +78,8 @@
</com:Class>
<com:Class Id ="6484A61D-50FA-41F0-B71E-F4370C6EB37C" DisplayName="AuthenticationArguments Server">
</com:Class>
<com:Class Id ="E62BB1E7-C7B2-4AEC-9E28-FB649B30FF03" DisplayName="RepairOptions Server">
</com:Class>
</com:ExeServer>
</com:ComServer>
</com:Extension>
Original file line number Diff line number Diff line change
@@ -43,6 +43,9 @@
clsid="{80CF9D63-5505-4342-B9B4-BB87895CA8BB}"
threadingModel="Both"
description="PackageManagerSettings"/>
<comClass
clsid="{30C024C4-852C-4DD4-9810-1348C51EF9BB}"
threadingModel="Both"
description="RepairOptions"/>
</file>

</assembly>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.Management.Deployment.Projection
@@ -114,6 +114,18 @@ internal static class ClassesDefinition
{
[ClsidContext.InProc] = new Guid("80CF9D63-5505-4342-B9B4-BB87895CA8BB"),
}
},

[typeof(RepairOptions)] = new ()
{
ProjectedClassType = typeof(RepairOptions),
InterfaceType = typeof(IRepairOptions),
Clsids = new Dictionary<ClsidContext, Guid>()
{
[ClsidContext.InProc] = new Guid("30C024C4-852C-4DD4-9810-1348C51EF9BB"),
[ClsidContext.OutOfProc] = new Guid("0498F441-3097-455F-9CAF-148F28293865"),
[ClsidContext.OutOfProcDev] = new Guid("E62BB1E7-C7B2-4AEC-9E28-FB649B30FF03"),
}
}
};

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.Management.Deployment.Projection
@@ -33,6 +33,8 @@ public WinGetProjectionFactory(IInstanceInitializer instanceInitializer)

public AuthenticationArguments CreateAuthenticationArguments() => InstanceInitializer.CreateInstance<AuthenticationArguments>();

public PackageManagerSettings CreatePackageManagerSettings() => InstanceInitializer.CreateInstance<PackageManagerSettings>();
public PackageManagerSettings CreatePackageManagerSettings() => InstanceInitializer.CreateInstance<PackageManagerSettings>();

public RepairOptions CreateRepairOptions() => InstanceInitializer.CreateInstance<RepairOptions>();
}
}
9 changes: 7 additions & 2 deletions src/Microsoft.Management.Deployment/ComClsids.cpp
Original file line number Diff line number Diff line change
@@ -13,7 +13,8 @@
#include "PackageMatchFilter.h"
#include "PackageManagerSettings.h"
#include "DownloadOptions.h"
#include "AuthenticationArguments.h"
#include "AuthenticationArguments.h"
#include "RepairOptions.h"
#pragma warning( pop )

namespace winrt::Microsoft::Management::Deployment
@@ -55,10 +56,14 @@ namespace winrt::Microsoft::Management::Deployment
else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_PackageManagerSettings))
{
return __uuidof(winrt::Microsoft::Management::Deployment::implementation::PackageManagerSettings);
}
else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_RepairOptions))
{
return __uuidof(winrt::Microsoft::Management::Deployment::implementation::RepairOptions);
}
else
{
return CLSID_NULL;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -217,6 +217,8 @@
<ClInclude Include="pch.h" />
<ClInclude Include="Public\CoCreatableMicrosoftManagementDeploymentClass.h" />
<ClInclude Include="Public\ComClsids.h" />
<ClInclude Include="RepairOptions.h" />
<ClInclude Include="RepairResult.h" />
<ClInclude Include="SourceAgreement.h" />
<ClInclude Include="UninstallOptions.h" />
<ClInclude Include="UninstallResult.h" />
@@ -257,6 +259,8 @@
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="RepairOptions.cpp" />
<ClCompile Include="RepairResult.cpp" />
<ClCompile Include="SourceAgreement.cpp" />
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
<ClCompile Include="UninstallOptions.cpp" />
Original file line number Diff line number Diff line change
@@ -38,6 +38,8 @@
<ClCompile Include="AuthenticationArguments.cpp" />
<ClCompile Include="AuthenticationInfo.cpp" />
<ClCompile Include="MicrosoftEntraIdAuthenticationInfo.cpp" />
<ClCompile Include="RepairResult.cpp" />
<ClCompile Include="RepairOptions.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CatalogPackage.h" />
@@ -81,6 +83,8 @@
<ClInclude Include="AuthenticationArguments.h" />
<ClInclude Include="AuthenticationInfo.h" />
<ClInclude Include="MicrosoftEntraIdAuthenticationInfo.h" />
<ClInclude Include="RepairResult.h" />
<ClInclude Include="RepairOptions.h" />
</ItemGroup>
<ItemGroup>
<Midl Include="PackageManager.idl" />
@@ -95,4 +99,7 @@
<UniqueIdentifier>{9c3907ed-84d9-4485-9b15-04c50717f0ab}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
Madhusudhan-MSFT marked this conversation as resolved.
Show resolved Hide resolved
<Natvis Include="$(MSBuildThisFileDirectory)..\..\natvis\wil.natvis" />
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions src/Microsoft.Management.Deployment/PackageManager.cpp
Original file line number Diff line number Diff line change
@@ -1066,5 +1066,14 @@ namespace winrt::Microsoft::Management::Deployment::implementation
return GetPackageOperation<Deployment::DownloadResult, Deployment::PackageDownloadProgress, Deployment::DownloadOptions, Deployment::PackageDownloadProgressState>(true, std::move(queueItem));
}

winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Management::Deployment::RepairResult, winrt::Microsoft::Management::Deployment::RepairProgress> PackageManager::RepairPackageAsync(winrt::Microsoft::Management::Deployment::CatalogPackage package, winrt::Microsoft::Management::Deployment::RepairOptions options)
{
return winrt::Windows::Foundation::IAsyncOperationWithProgress<Deployment::RepairResult, winrt::Microsoft::Management::Deployment::RepairProgress>();
}

winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Management::Deployment::RepairResult, winrt::Microsoft::Management::Deployment::RepairProgress> PackageManager::GetRepairProgress(winrt::Microsoft::Management::Deployment::CatalogPackage package, winrt::Microsoft::Management::Deployment::PackageCatalogInfo catalogInfo)
{
return winrt::Windows::Foundation::IAsyncOperationWithProgress<Deployment::RepairResult, winrt::Microsoft::Management::Deployment::RepairProgress>();
}
CoCreatableMicrosoftManagementDeploymentClass(PackageManager);
Madhusudhan-MSFT marked this conversation as resolved.
Show resolved Hide resolved
}
128 changes: 127 additions & 1 deletion src/Microsoft.Management.Deployment/PackageManager.idl
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
namespace Microsoft.Management.Deployment
{
[contractversion(10)]
[contractversion(11)]
apicontract WindowsPackageManagerContract{};

/// State of the install
@@ -151,6 +151,72 @@ namespace Microsoft.Management.Deployment
UInt32 UninstallerErrorCode { get; };
}

/// State of the repair
[contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 11)]
enum PackageRepairProgressState
{
/// The repair is queued but not yet active. Cancellation of the IAsyncOperationWithProgress in this
/// state will prevent the package from repairing.
Queued,
/// The repair is in progress. Cancellation of the IAsyncOperationWithProgress in this state will not
/// stop the repair or the post repair steps.
Repairing,
/// The repair has completed and cleanup actions are in progress. Cancellation of the
/// IAsyncOperationWithProgress in this state will not stop cleanup or roll back the repair.
PostRepair,
/// The operation has completed.
Finished,
};

/// Progress object for the repair
[contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 11)]
struct RepairProgress
{
/// State of the repair
PackageRepairProgressState State;

/// Repair percentage if known.
Double RepairCompletionProgress;
};

/// Status of the repair call
/// Implementation Note: Errors mapped from AppInstallerErrors.h
/// DESIGN NOTE: RepairResultStatus from AppInstallerErrors.h is not implemented in V1.
[contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 11)]
enum RepairResultStatus
{
Ok,
BlockedByPolicy,
CatalogError,
InternalError,
InvalidOptions,
RepairError,
ManifestError,
NoApplicableInstallers,
PackageAgreementsNotAccepted,
};

/// Result of the repair
[contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 11)]
runtimeclass RepairResult
{
/// Used by a caller to correlate the repair with a caller's data.
String CorrelationData { get; };

/// Whether a restart is required to complete the repair.
Boolean RebootRequired { get; };

/// Batched error code, example APPINSTALLER_CLI_ERROR_SHELLEXEC_INSTALL_FAILED
RepairResultStatus Status { get; };

/// The error code of the overall operation.
HRESULT ExtendedErrorCode { get; };

/// The error code from the repair attempt. Only valid if the Status is RepairError.
/// This value's meaning will require knowledge of the specific repairer or repair technology.
UInt32 InstallerErrorCode { get; };
}

/// State of the download
[contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 7)]
enum PackageDownloadProgressState
@@ -1071,6 +1137,57 @@ namespace Microsoft.Management.Deployment
String CorrelationData;
}

[contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 11)]
enum PackageRepairMode
{
/// The default experience for the installer. Installer may show some UI.
Default,
/// Runs the installer in silent mode. This suppresses the installer's UI to the extent
/// possible (installer may still show some required UI).
Silent,
/// Runs the installer in interactive mode.
Interactive,
};

[contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 11)]
enum PackageRepairScope
{
/// Use default repair behavior.
Any,
/// Repair for current user. Currently only applicable to msix.
User,
/// Repair for all users.
System,
};

[contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 11)]
runtimeclass RepairOptions
{
RepairOptions();

/// Optionally specifies the version from the package to repair. If unspecified the version matching
/// CatalogPackage.GetLatestVersion() is used.
PackageVersionId PackageVersionId;

/// The package Repair scope.
PackageRepairScope PackageRepairScope;

/// The package repair mode.
PackageRepairMode PackageRepairMode;

/// Optional parameter specifying the directory where installers are downloaded when the repair behavior is of type Installer.
Madhusudhan-MSFT marked this conversation as resolved.
Show resolved Hide resolved
String DownloadDirectory;

/// Optional parameter specifying Accept the package agreements required for download.
Boolean AcceptPackageAgreements;

/// Used by a caller to correlate the download with a caller's data.
/// The string must be JSON encoded.
String CorrelationData;

String LogOutputPath;
}

/// IMPLEMENTATION NOTE: Documentation from AppInstaller::Manifest::Documentation
[contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)]
runtimeclass Documentation
@@ -1256,6 +1373,15 @@ namespace Microsoft.Management.Deployment
// Get download progress
Windows.Foundation.IAsyncOperationWithProgress<DownloadResult, PackageDownloadProgress> GetDownloadProgress(CatalogPackage package, PackageCatalogInfo catalogInfo);
}

[contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 11)]
{
// Repair the specified package
Windows.Foundation.IAsyncOperationWithProgress<RepairResult, RepairProgress> RepairPackageAsync(CatalogPackage package, RepairOptions options);

// Get repair progress
Windows.Foundation.IAsyncOperationWithProgress<RepairResult, RepairProgress> GetRepairProgress(CatalogPackage package, PackageCatalogInfo catalogInfo);
}
Copy link
Contributor

@yao-msft yao-msft Oct 4, 2024

Choose a reason for hiding this comment

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

Missing GetRepairProgress #WontFix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

During the API review process, we decided against including GetRepairProgress as we couldn't identify a scenario where another client would need to track the asynchronous operation for repair.

}

/// Global settings for PackageManager operations.
5 changes: 4 additions & 1 deletion src/Microsoft.Management.Deployment/Public/ComClsids.h
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
#define WINGET_OUTOFPROC_COM_CLSID_ConfigurationStaticFunctions "73D763B7-2937-432F-A97A-D98A4A596126"
#define WINGET_OUTOFPROC_COM_CLSID_DownloadOptions "4CBABE76-7322-4BE4-9CEA-2589A80682DC"
#define WINGET_OUTOFPROC_COM_CLSID_AuthenticationArguments "BA580786-BDE3-4F6C-B8F3-44698AC8711A"
#define WINGET_OUTOFPROC_COM_CLSID_RepairOptions "0498F441-3097-455F-9CAF-148F28293865"
#else
#define WINGET_OUTOFPROC_COM_CLSID_PackageManager "74CB3139-B7C5-4B9E-9388-E6616DEA288C"
#define WINGET_OUTOFPROC_COM_CLSID_FindPackagesOptions "1BD8FF3A-EC50-4F69-AEEE-DF4C9D3BAA96"
@@ -24,6 +25,7 @@
#define WINGET_OUTOFPROC_COM_CLSID_ConfigurationStaticFunctions "C9ED7917-66AB-4E31-A92A-F65F18EF7933"
#define WINGET_OUTOFPROC_COM_CLSID_DownloadOptions "8EF324ED-367C-4880-83E5-BB2ABD0B72F6"
#define WINGET_OUTOFPROC_COM_CLSID_AuthenticationArguments "6484A61D-50FA-41F0-B71E-F4370C6EB37C"
#define WINGET_OUTOFPROC_COM_CLSID_RepairOptions "E62BB1E7-C7B2-4AEC-9E28-FB649B30FF03"
#endif

// Clsids only used in in-proc invocation
@@ -41,6 +43,7 @@ namespace winrt::Microsoft::Management::Deployment
const CLSID WINGET_INPROC_COM_CLSID_PackageManagerSettings = { 0x80CF9D63, 0x5505, 0x4342, 0xB9, 0xB4, 0xBB, 0x87, 0x89, 0x5C, 0xA8, 0xBB }; // 80CF9D63-5505-4342-B9B4-BB87895CA8BB
const CLSID WINGET_INPROC_COM_CLSID_DownloadOptions = { 0x4288DF96, 0xFDC9, 0x4B68, 0xB4, 0x03, 0x19, 0x3D, 0xBB, 0xF5, 0x6A, 0x24 }; // 4288DF96-FDC9-4B68-B403-193DBBF56A24
const CLSID WINGET_INPROC_COM_CLSID_AuthenticationArguments = { 0x8D593114, 0x1CF1, 0x43B9, 0x87, 0x22, 0x4D, 0xBB, 0x30, 0x10, 0x32, 0x96 }; // 8D593114-1CF1-43B9-8722-4DBB30103296
const CLSID WINGET_INPROC_COM_CLSID_RepairOptions = { 0x30c024c4, 0x852c, 0x4dd4, 0x98, 0x10, 0x13, 0x48, 0xc5, 0x1e, 0xf9, 0xbb }; // {30C024C4-852C-4DD4-9810-1348C51EF9BB}

CLSID GetRedirectedClsidFromInProcClsid(REFCLSID clsid);
}
}
Loading