From 514b611734bb4cec28682381599ab0b35fcb2083 Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Tue, 24 Jan 2023 11:11:22 -0800 Subject: [PATCH 01/17] add source agreements --- .../Interop/FindPackagesInterop.cs | 14 ++++++++ .../TestExeInstaller_Agreements.yaml | 26 +++++++++++++++ .../Public/winget/RepositorySource.h | 8 +++-- ....Management.Deployment.InProc.dll.manifest | 4 +++ .../ClassesDefinition.cs | 12 +++++++ .../WinGetProjectionFactory.cs | 2 ++ .../ComClsids.cpp | 5 +++ .../ConnectOptions.cpp | 30 +++++++++++++++++ .../ConnectOptions.h | 33 +++++++++++++++++++ .../Microsoft.Management.Deployment.vcxproj | 4 +++ ...soft.Management.Deployment.vcxproj.filters | 4 +++ .../PackageCatalogReference.cpp | 13 ++++++++ .../PackageCatalogReference.h | 2 ++ .../PackageManager.idl | 32 ++++++++++++++++-- .../Public/ComClsids.h | 3 ++ .../SourceAgreement.cpp | 27 +++++++++++++++ .../SourceAgreement.h | 27 +++++++++++++++ src/WindowsPackageManager/main.cpp | 1 + 18 files changed, 242 insertions(+), 5 deletions(-) create mode 100644 src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_Agreements.yaml create mode 100644 src/Microsoft.Management.Deployment/ConnectOptions.cpp create mode 100644 src/Microsoft.Management.Deployment/ConnectOptions.h create mode 100644 src/Microsoft.Management.Deployment/SourceAgreement.cpp create mode 100644 src/Microsoft.Management.Deployment/SourceAgreement.h diff --git a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs index aa9d6788d2..80109517cd 100644 --- a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs @@ -64,5 +64,19 @@ public void FindPackagesMultipleMatchingQuery() // Assert Assert.AreEqual(2, searchResult.Count); } + + /// + /// Test to find a package with agreements and verify COM output. + /// + [Test] + public void FindPackagesVerifyAgreements() + { + // Find package + var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.PackageAgreements"); + + // Assert + Assert.AreEqual(1, searchResult.Count); + //searchResult[0].CatalogPackage.Agreements. + } } } \ No newline at end of file diff --git a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_Agreements.yaml b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_Agreements.yaml new file mode 100644 index 0000000000..d164dcfc87 --- /dev/null +++ b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_Agreements.yaml @@ -0,0 +1,26 @@ +PackageIdentifier: AppInstallerTest.PackageAgreements +PackageVersion: 2.0.0.0 +PackageName: TestPortableExe +PackageLocale: en-US +Publisher: AppInstallerTest +License: Test +ShortDescription: E2E test for portable install. +Installers: + - Architecture: x64 + InstallerUrl: https://localhost:5001/TestKit/AppInstallerTestExeInstaller/AppInstallerTestExeInstaller.exe + InstallerType: exe + InstallerSha256: + InstallerSwitches: + Custom: /execustom + SilentWithProgress: /exeswp + Silent: /exesilent + Interactive: /exeinteractive + Language: /exeenus + Log: /LogFile + InstallLocation: /InstallDir +Agreements: + - AgreementLabel: DefaultLabel + Agreement: DefaultText + AgreementUrl: https://DefaultAgreementUrl.net +ManifestType: singleton +ManifestVersion: 1.2.0 \ No newline at end of file diff --git a/src/AppInstallerRepositoryCore/Public/winget/RepositorySource.h b/src/AppInstallerRepositoryCore/Public/winget/RepositorySource.h index 435e2879c4..d34fd616ea 100644 --- a/src/AppInstallerRepositoryCore/Public/winget/RepositorySource.h +++ b/src/AppInstallerRepositoryCore/Public/winget/RepositorySource.h @@ -126,12 +126,14 @@ namespace AppInstaller::Repository // Individual source agreement entry. Label will be highlighted in the display as the key of the agreement entry. struct SourceAgreement { - std::string Label; - std::string Text; - std::string Url; + SourceAgreement() = default; SourceAgreement(std::string label, std::string text, std::string url) : Label(std::move(label)), Text(std::move(text)), Url(std::move(url)) {} + + std::string Label; + std::string Text; + std::string Url; }; // Interface for retrieving information about a source after opening the source. diff --git a/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest b/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest index 0ed258d962..089d50ac57 100644 --- a/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest +++ b/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest @@ -27,6 +27,10 @@ clsid="{869CB959-EB54-425C-A1E4-1A1C291C64E9}" threadingModel="Both" description="UninstallOptions"/> + () + { + [ClsidContext.InProc] = new Guid("D026FDDC-44D3-443A-8DAB-A4DD969943B3"), + [ClsidContext.OutOfProc] = new Guid("B5033698-79D1-4B94-9C39-0EC4EF1C7853"), + [ClsidContext.OutOfProcDev] = new Guid("6C4F68AC-F601-42FC-8CAF-87D3B3321783"), + } }, [typeof(InstallOptions)] = new() diff --git a/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs b/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs index 9d846510a7..53b8c9424c 100644 --- a/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs +++ b/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs @@ -23,6 +23,8 @@ public WinGetProjectionFactory(IInstanceInitializer instanceInitializer) public CreateCompositePackageCatalogOptions CreateCreateCompositePackageCatalogOptions() => InstanceInitializer.CreateInstance(); + public ConnectOptions CreateConnectOptions() => InstanceInitializer.CreateInstance(); + public InstallOptions CreateInstallOptions() => InstanceInitializer.CreateInstance(); public UninstallOptions CreateUninstallOptions() => InstanceInitializer.CreateInstance(); diff --git a/src/Microsoft.Management.Deployment/ComClsids.cpp b/src/Microsoft.Management.Deployment/ComClsids.cpp index 35e774070f..e510ff2b3f 100644 --- a/src/Microsoft.Management.Deployment/ComClsids.cpp +++ b/src/Microsoft.Management.Deployment/ComClsids.cpp @@ -8,6 +8,7 @@ #include "PackageManager.h" #include "FindPackagesOptions.h" #include "CreateCompositePackageCatalogOptions.h" +#include "ConnectOptions.h" #include "InstallOptions.h" #include "UninstallOptions.h" #include "PackageMatchFilter.h" @@ -30,6 +31,10 @@ namespace winrt::Microsoft::Management::Deployment { return __uuidof(winrt::Microsoft::Management::Deployment::implementation::CreateCompositePackageCatalogOptions); } + else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_ConnectOptions)) + { + return __uuidof(winrt::Microsoft::Management::Deployment::implementation::ConnectOptions); + } else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_InstallOptions)) { return __uuidof(winrt::Microsoft::Management::Deployment::implementation::InstallOptions); diff --git a/src/Microsoft.Management.Deployment/ConnectOptions.cpp b/src/Microsoft.Management.Deployment/ConnectOptions.cpp new file mode 100644 index 0000000000..c8e24a6d25 --- /dev/null +++ b/src/Microsoft.Management.Deployment/ConnectOptions.cpp @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#pragma warning( push ) +#pragma warning ( disable : 4467 6388) +// 6388 Allow CreateInstance. +#include +// 4467 Allow use of uuid attribute for com object creation. +#include "ConnectOptions.h" +#pragma warning( pop ) +#include "ConnectOptions.g.cpp" +#include "Helpers.h" + + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + ConnectOptions::ConnectOptions() + { + } + winrt::Windows::Foundation::Collections::IVector ConnectOptions::SourceAgreements() + { + return m_sourceAgreements; + } + void ConnectOptions::SourceAgreements(winrt::Windows::Foundation::Collections::IVector const& value) + { + m_sourceAgreements = value; + } + + CoCreatableMicrosoftManagementDeploymentClass(ConnectOptions); +} diff --git a/src/Microsoft.Management.Deployment/ConnectOptions.h b/src/Microsoft.Management.Deployment/ConnectOptions.h new file mode 100644 index 0000000000..134ab65603 --- /dev/null +++ b/src/Microsoft.Management.Deployment/ConnectOptions.h @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once +#include "ConnectOptions.g.h" +#include "SourceAgreement.h" +#include "Public/ComClsids.h" + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + [uuid(WINGET_OUTOFPROC_COM_CLSID_ConnectOptions)] + struct ConnectOptions : ConnectOptionsT + { + ConnectOptions(); + + winrt::Windows::Foundation::Collections::IVector SourceAgreements(); + + void SourceAgreements(winrt::Windows::Foundation::Collections::IVector const& value); + +#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) + private: + Windows::Foundation::Collections::IVector m_sourceAgreements{ winrt::single_threaded_vector() }; +#endif + }; +} + +#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) +namespace winrt::Microsoft::Management::Deployment::factory_implementation +{ + struct ConnectOptions : ConnectOptionsT + { + }; +} +#endif diff --git a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj index a535079108..812b7336f7 100644 --- a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj +++ b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj @@ -138,6 +138,7 @@ + @@ -160,6 +161,7 @@ + @@ -167,6 +169,7 @@ + @@ -190,6 +193,7 @@ Create + diff --git a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters index a204e95804..109143ce4c 100644 --- a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters +++ b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters @@ -2,6 +2,7 @@ + @@ -20,6 +21,7 @@ + @@ -31,6 +33,7 @@ + @@ -48,6 +51,7 @@ + diff --git a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp index 5833c1b765..e2267e7ed4 100644 --- a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp +++ b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp @@ -6,6 +6,7 @@ #include "PackageCatalogReference.g.cpp" #include "PackageCatalogInfo.h" #include "PackageCatalog.h" +#include "SourceAgreement.h" #include "ConnectResult.h" #include "Workflows/WorkflowBase.h" #include "Converters.h" @@ -125,6 +126,18 @@ namespace winrt::Microsoft::Management::Deployment::implementation return GetConnectCatalogErrorResult(); } + winrt::Windows::Foundation::Collections::IVectorView PackageCatalogReference::SourceAgreements() + { + for (auto const& agreement : m_sourceReference.GetInformation().SourceAgreements) + { + auto sourceAgreement = winrt::make_self>(); + sourceAgreement->Initialize(agreement); + m_sourceAgreements.Append(*sourceAgreement); + } + + return m_sourceAgreements.GetView(); + } + hstring PackageCatalogReference::AdditionalPackageCatalogArguments() { if (!IsComposite()) diff --git a/src/Microsoft.Management.Deployment/PackageCatalogReference.h b/src/Microsoft.Management.Deployment/PackageCatalogReference.h index f703dfc334..1ddac4a1fc 100644 --- a/src/Microsoft.Management.Deployment/PackageCatalogReference.h +++ b/src/Microsoft.Management.Deployment/PackageCatalogReference.h @@ -19,6 +19,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation winrt::Microsoft::Management::Deployment::PackageCatalogInfo Info(); winrt::Windows::Foundation::IAsyncOperation ConnectAsync(); winrt::Microsoft::Management::Deployment::ConnectResult Connect(); + winrt::Windows::Foundation::Collections::IVectorView SourceAgreements(); hstring AdditionalPackageCatalogArguments(); void AdditionalPackageCatalogArguments(hstring const& value); @@ -26,6 +27,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation private: winrt::Microsoft::Management::Deployment::CreateCompositePackageCatalogOptions m_compositePackageCatalogOptions{ nullptr }; winrt::Microsoft::Management::Deployment::PackageCatalogInfo m_info{ nullptr }; + winrt::Windows::Foundation::Collections::IVector m_sourceAgreements{ winrt::single_threaded_vector() }; ::AppInstaller::Repository::Source m_sourceReference; std::optional m_additionalPackageCatalogArguments; #endif diff --git a/src/Microsoft.Management.Deployment/PackageManager.idl b/src/Microsoft.Management.Deployment/PackageManager.idl index 87c15c62cf..055cabda11 100644 --- a/src/Microsoft.Management.Deployment/PackageManager.idl +++ b/src/Microsoft.Management.Deployment/PackageManager.idl @@ -2,7 +2,7 @@ // Licensed under the MIT License. namespace Microsoft.Management.Deployment { - [contractversion(6)] + [contractversion(7)] apicontract WindowsPackageManagerContract{}; /// State of the install @@ -558,7 +558,7 @@ namespace Microsoft.Management.Deployment /// If true, the results were truncated by the given ResultLimit /// USAGE NOTE: Windows Package Manager does not support result pagination, there is no way to continue /// getting more results. - Boolean WasLimitExceeded{ get; }; + Boolean WasLimitExceeded { get; }; } /// Options for FindPackages @@ -643,6 +643,12 @@ namespace Microsoft.Management.Deployment /// A string that will be passed to the source server if using a REST source String AdditionalPackageCatalogArguments; } + + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 7)] + { + /// Gets the required agreements for connecting to the package catalog (source). + Windows.Foundation.Collections.IVectorView SourceAgreements{ get; }; + } } /// Catalogs with PackageCatalogOrigin Predefined @@ -826,6 +832,26 @@ namespace Microsoft.Management.Deployment } } + /// Options when connecting to a package catalog. + /// Intended to allow agreements to be exposed and passed when connecting to the package catalog. + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 7)] + runtimeclass ConnectOptions + { + ConnectOptions(); + + Windows.Foundation.Collections.IVector SourceAgreements; + } + + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 7)] + runtimeclass SourceAgreement + { + String Label { get; }; + + String Text{ get; }; + + String Url{ get; }; + } + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 1)] runtimeclass PackageManager { @@ -934,5 +960,7 @@ namespace Microsoft.Management.Deployment interface Windows.Foundation.Collections.IVectorView; interface Windows.Foundation.Collections.IVector; interface Windows.Foundation.Collections.IVectorView; + interface Windows.Foundation.Collections.IVector; + interface Windows.Foundation.Collections.IVectorView; } } diff --git a/src/Microsoft.Management.Deployment/Public/ComClsids.h b/src/Microsoft.Management.Deployment/Public/ComClsids.h index 144ddb351e..4406e08faf 100644 --- a/src/Microsoft.Management.Deployment/Public/ComClsids.h +++ b/src/Microsoft.Management.Deployment/Public/ComClsids.h @@ -11,6 +11,7 @@ #define WINGET_OUTOFPROC_COM_CLSID_InstallOptions "1095F097-EB96-453B-B4E6-1613637F3B14" #define WINGET_OUTOFPROC_COM_CLSID_UninstallOptions "E1D9A11E-9F85-4D87-9C17-2B93143ADB8D" #define WINGET_OUTOFPROC_COM_CLSID_PackageMatchFilter "D02C9DAF-99DC-429C-B503-4E504E4AB000" +#define WINGET_OUTOFPROC_COM_CLSID_ConnectOptions "B5033698-79D1-4B94-9C39-0EC4EF1C7853" #else #define WINGET_OUTOFPROC_COM_CLSID_PackageManager "74CB3139-B7C5-4B9E-9388-E6616DEA288C" #define WINGET_OUTOFPROC_COM_CLSID_FindPackagesOptions "1BD8FF3A-EC50-4F69-AEEE-DF4C9D3BAA96" @@ -18,6 +19,7 @@ #define WINGET_OUTOFPROC_COM_CLSID_InstallOptions "44FE0580-62F7-44D4-9E91-AA9614AB3E86" #define WINGET_OUTOFPROC_COM_CLSID_UninstallOptions "AA2A5C04-1AD9-46C4-B74F-6B334AD7EB8C" #define WINGET_OUTOFPROC_COM_CLSID_PackageMatchFilter "3F85B9F4-487A-4C48-9035-2903F8A6D9E8" +#define WINGET_OUTOFPROC_COM_CLSID_ConnectOptions "6C4F68AC-F601-42FC-8CAF-87D3B3321783" #endif // Clsids only used in in-proc invocation @@ -33,6 +35,7 @@ namespace winrt::Microsoft::Management::Deployment const CLSID WINGET_INPROC_COM_CLSID_UninstallOptions = { 0x869CB959, 0xEB54, 0x425C, 0xA1, 0xE4, 0x1A, 0x1C, 0x29, 0x1C, 0x64, 0xE9 }; // 869CB959-EB54-425C-A1E4-1A1C291C64E9 const CLSID WINGET_INPROC_COM_CLSID_PackageMatchFilter = { 0x57DC8962, 0x7343, 0x42CD, 0xB9, 0x1C, 0x04, 0xF6, 0xA2, 0x5D, 0xB1, 0xD0 }; // 57DC8962-7343-42CD-B91C-04F6A25DB1D0 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_ConnectOptions = { 0xD026FDDC, 0x44D3, 0x443A, 0x8D, 0xAB, 0xA4, 0xDD, 0x96, 0x99, 0x43, 0xB3 }; //D026FDDC-44D3-443A-8DAB-A4DD969943B3 CLSID GetRedirectedClsidFromInProcClsid(REFCLSID clsid); } \ No newline at end of file diff --git a/src/Microsoft.Management.Deployment/SourceAgreement.cpp b/src/Microsoft.Management.Deployment/SourceAgreement.cpp new file mode 100644 index 0000000000..83d7c507fd --- /dev/null +++ b/src/Microsoft.Management.Deployment/SourceAgreement.cpp @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#include +#include "SourceAgreement.h" +#include "SourceAgreement.g.cpp" +#include + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + void SourceAgreement::Initialize(::AppInstaller::Repository::SourceAgreement sourceAgreement) + { + m_sourceAgreement = sourceAgreement; + } + hstring SourceAgreement::Label() + { + return winrt::to_hstring(m_sourceAgreement.Label); + } + hstring SourceAgreement::Text() + { + return winrt::to_hstring(m_sourceAgreement.Text); + } + hstring SourceAgreement::Url() + { + return winrt::to_hstring(m_sourceAgreement.Url); + } +} diff --git a/src/Microsoft.Management.Deployment/SourceAgreement.h b/src/Microsoft.Management.Deployment/SourceAgreement.h new file mode 100644 index 0000000000..465fcf64ca --- /dev/null +++ b/src/Microsoft.Management.Deployment/SourceAgreement.h @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once +#include "pch.h" +#include "SourceAgreement.g.h" +#include + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + struct SourceAgreement : SourceAgreementT + { + SourceAgreement() = default; + +#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) + void Initialize(::AppInstaller::Repository::SourceAgreement sourceAgreement); +#endif + + hstring Label(); + hstring Text(); + hstring Url(); + +#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) + private: + ::AppInstaller::Repository::SourceAgreement m_sourceAgreement{}; +#endif + }; +} diff --git a/src/WindowsPackageManager/main.cpp b/src/WindowsPackageManager/main.cpp index 8ee8a3bc52..56453ff034 100644 --- a/src/WindowsPackageManager/main.cpp +++ b/src/WindowsPackageManager/main.cpp @@ -21,6 +21,7 @@ using namespace winrt::Microsoft::Management::Deployment; CoCreatableClassWrlCreatorMapInclude(PackageManager); CoCreatableClassWrlCreatorMapInclude(FindPackagesOptions); CoCreatableClassWrlCreatorMapInclude(CreateCompositePackageCatalogOptions); +CoCreatableClassWrlCreatorMapInclude(ConnectOptions); CoCreatableClassWrlCreatorMapInclude(InstallOptions); CoCreatableClassWrlCreatorMapInclude(UninstallOptions); CoCreatableClassWrlCreatorMapInclude(PackageMatchFilter); From b23ffd2a26f3c704ec81bc23841afe09c368f859 Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Wed, 25 Jan 2023 16:24:38 -0800 Subject: [PATCH 02/17] Add accept package agreements bool --- azure-pipelines.yml | 98 +++++++++---------- src/AppInstallerCLICore/COMContext.h | 2 - .../AppInstallerCLIE2ETests.csproj | 4 + .../Interop/FindPackagesInterop.cs | 12 ++- .../Interop/InstallInterop.cs | 23 +++++ .../ClassesDefinition.cs | 6 +- .../WinGetProjectionFactory.cs | 2 +- .../CatalogPackage.cpp | 16 +++ .../CatalogPackage.h | 4 + .../ComClsids.cpp | 6 +- .../ConnectOptions.cpp | 30 ------ .../ConnectOptions.h | 33 ------- .../InstallOptions.cpp | 9 +- .../InstallOptions.h | 5 + .../Microsoft.Management.Deployment.vcxproj | 6 +- ...soft.Management.Deployment.vcxproj.filters | 6 +- .../PackageAgreement.cpp | 26 +++++ .../PackageAgreement.h | 27 +++++ .../PackageCatalogConnectOptions.cpp | 27 +++++ .../PackageCatalogConnectOptions.h | 31 ++++++ .../PackageManager.cpp | 8 ++ .../PackageManager.idl | 42 ++++++-- .../Public/ComClsids.h | 4 +- src/WindowsPackageManager/main.cpp | 2 +- 24 files changed, 290 insertions(+), 139 deletions(-) delete mode 100644 src/Microsoft.Management.Deployment/ConnectOptions.cpp delete mode 100644 src/Microsoft.Management.Deployment/ConnectOptions.h create mode 100644 src/Microsoft.Management.Deployment/PackageAgreement.cpp create mode 100644 src/Microsoft.Management.Deployment/PackageAgreement.h create mode 100644 src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.cpp create mode 100644 src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.h diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ec5edba4d8..7b23ebacc8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -146,28 +146,28 @@ jobs: inputs: secureFile: 'PsExec.exe' - - task: CmdLine@2 - displayName: Run Unit Tests Unpackaged Under System Context - inputs: - script: | - $(PsExec.secureFilePath) -accepteula -s -i $(buildOutDir)\AppInstallerCLITests\AppInstallerCLITests.exe -logto $(artifactsDir)\AICLI-Unpackaged-System.log -s -r junit -o $(artifactsDir)\TEST-AppInstallerCLI-Unpackaged-System.xml - workingDirectory: '$(buildOutDir)\AppInstallerCLITests' - continueOnError: true - - - task: PowerShell@2 - displayName: Run Unit Tests Packaged - inputs: - filePath: 'src\AppInstallerCLITests\Run-TestsInPackage.ps1' - arguments: '-Args "~[pips]" -BuildRoot $(buildOutDir) -PackageRoot AppInstallerCLIPackage\bin\$(buildPlatform)\$(buildConfiguration) -LogTarget $(artifactsDir)\AICLI-Packaged.log -TestResultsTarget $(artifactsDir)\TEST-AppInstallerCLI-Packaged.xml -ScriptWait' - workingDirectory: 'src' - continueOnError: true - - - task: PublishTestResults@2 - displayName: Publish Unit Test Results - inputs: - testResultsFormat: 'JUnit' - testResultsFiles: '$(artifactsDir)\TEST-*.xml' - failTaskOnFailedTests: true + # - task: CmdLine@2 + # displayName: Run Unit Tests Unpackaged Under System Context + # inputs: + # script: | + # $(PsExec.secureFilePath) -accepteula -s -i $(buildOutDir)\AppInstallerCLITests\AppInstallerCLITests.exe -logto $(artifactsDir)\AICLI-Unpackaged-System.log -s -r junit -o $(artifactsDir)\TEST-AppInstallerCLI-Unpackaged-System.xml + # workingDirectory: '$(buildOutDir)\AppInstallerCLITests' + # continueOnError: true + + # - task: PowerShell@2 + # displayName: Run Unit Tests Packaged + # inputs: + # filePath: 'src\AppInstallerCLITests\Run-TestsInPackage.ps1' + # arguments: '-Args "~[pips]" -BuildRoot $(buildOutDir) -PackageRoot AppInstallerCLIPackage\bin\$(buildPlatform)\$(buildConfiguration) -LogTarget $(artifactsDir)\AICLI-Packaged.log -TestResultsTarget $(artifactsDir)\TEST-AppInstallerCLI-Packaged.xml -ScriptWait' + # workingDirectory: 'src' + # continueOnError: true + + # - task: PublishTestResults@2 + # displayName: Publish Unit Test Results + # inputs: + # testResultsFormat: 'JUnit' + # testResultsFiles: '$(artifactsDir)\TEST-*.xml' + # failTaskOnFailedTests: true - task: DownloadSecureFile@1 name: AppInstallerTest @@ -248,11 +248,11 @@ jobs: TargetFolder: 'src\AppInstallerCLIPackage\bin\$(buildPlatform)\$(buildConfiguration)' Contents: Microsoft.Management.Deployment.winmd - - template: templates/e2e-test.template.yml - parameters: - title: "E2E Tests Packaged" - isPackaged: true - filter: "TestCategory!=InProcess&TestCategory!=OutOfProcess" + # - template: templates/e2e-test.template.yml + # parameters: + # title: "E2E Tests Packaged" + # isPackaged: true + # filter: "TestCategory!=InProcess&TestCategory!=OutOfProcess" - template: templates/e2e-test.template.yml parameters: @@ -313,28 +313,28 @@ jobs: targetPath: '$(artifactsDir)' condition: always() - - task: ComponentGovernanceComponentDetection@0 - displayName: Component Governance - inputs: - scanType: 'Register' - verbosity: 'Verbose' - alertWarningLevel: 'High' - - # Run BimSkim for all the binaries - - task: BinSkim@3 - displayName: 'Run BinSkim ' - inputs: - arguments: 'analyze - "$(buildOutDir)\AppInstallerCLI\winget.exe" - "$(buildOutDir)\WinGetUtil\WinGetUtil.dll" - "$(buildOutDir)\WindowsPackageManager\WindowsPackageManager.dll" - "$(buildOutDir)\Microsoft.Management.Deployment.InProc\Microsoft.Management.Deployment.InProc.dll" - "$(Build.SourcesDirectory)\src\WinGetUtilInterop\bin\WinGetUtil*Interop.dll" - "$(buildOutDir)\UndockedRegFreeWinRT\winrtact.dll" - "$(buildOutDir)\Microsoft.WinGet.Client\Microsoft.WinGet.*Client.dll" --config default --recurse' - - - task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2 - displayName: 'Publish Security Analysis Logs' + # - task: ComponentGovernanceComponentDetection@0 + # displayName: Component Governance + # inputs: + # scanType: 'Register' + # verbosity: 'Verbose' + # alertWarningLevel: 'High' + + # # Run BimSkim for all the binaries + # - task: BinSkim@3 + # displayName: 'Run BinSkim ' + # inputs: + # arguments: 'analyze + # "$(buildOutDir)\AppInstallerCLI\winget.exe" + # "$(buildOutDir)\WinGetUtil\WinGetUtil.dll" + # "$(buildOutDir)\WindowsPackageManager\WindowsPackageManager.dll" + # "$(buildOutDir)\Microsoft.Management.Deployment.InProc\Microsoft.Management.Deployment.InProc.dll" + # "$(Build.SourcesDirectory)\src\WinGetUtilInterop\bin\WinGetUtil*Interop.dll" + # "$(buildOutDir)\UndockedRegFreeWinRT\winrtact.dll" + # "$(buildOutDir)\Microsoft.WinGet.Client\Microsoft.WinGet.*Client.dll" --config default --recurse' + + # - task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2 + # displayName: 'Publish Security Analysis Logs' - job: 'BuildPowerShellModule' timeoutInMinutes: 120 diff --git a/src/AppInstallerCLICore/COMContext.h b/src/AppInstallerCLICore/COMContext.h index fa282661cc..c458f4570c 100644 --- a/src/AppInstallerCLICore/COMContext.h +++ b/src/AppInstallerCLICore/COMContext.h @@ -40,14 +40,12 @@ namespace AppInstaller::CLI::Execution { Reporter.SetChannel(Reporter::Channel::Disabled); Reporter.SetProgressSink(this); - SetFlags(CLI::Execution::ContextFlag::AgreementsAcceptedByCaller); SetFlags(CLI::Execution::ContextFlag::DisableInteractivity); } COMContext(std::ostream& out, std::istream& in) : CLI::Execution::Context(out, in) { Reporter.SetProgressSink(this); - SetFlags(CLI::Execution::ContextFlag::AgreementsAcceptedByCaller); SetFlags(CLI::Execution::ContextFlag::DisableInteractivity); } diff --git a/src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj b/src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj index e2288ba35e..8f86246921 100644 --- a/src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj +++ b/src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj @@ -46,6 +46,10 @@ + + + + PreserveNewest diff --git a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs index 80109517cd..772a6c125f 100644 --- a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs @@ -76,7 +76,17 @@ public void FindPackagesVerifyAgreements() // Assert Assert.AreEqual(1, searchResult.Count); - //searchResult[0].CatalogPackage.Agreements. + + var catalogPackage = searchResult[0].CatalogPackage; + var packageVersionId = catalogPackage.AvailableVersions[0]; + var packageAgreements = catalogPackage.GetPackageAgreements(packageVersionId); + + Assert.AreEqual(1, packageAgreements.Count); + + var agreement = packageAgreements[0]; + Assert.AreEqual("DefaultLabel", agreement.Label); + Assert.AreEqual("DefaultText", agreement.Text); + Assert.AreEqual("https://DefaultAgreementUrl.net", agreement.Url); } } } \ No newline at end of file diff --git a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs index cbb814e519..c5f941fe86 100644 --- a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs @@ -516,5 +516,28 @@ public async Task InstallRequireUserScopeAndUnknown() // Assert Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); } + + /// + /// Test installing package with agreements and accepting those agreements. + /// + /// A representing the asynchronous unit test. + [Test] + public async Task InstallWithAgreementsAccepted() + { + // Find package + var searchResult = this.FindOnePackage(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.PackageAgreements"); + + // Configure installation + var installOptions = this.TestFactory.CreateInstallOptions(); + installOptions.PackageInstallMode = PackageInstallMode.Silent; + installOptions.PreferredInstallLocation = this.installDir; + installOptions.AcceptPackageAgreements = true; + + // Install + var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); + + // Assert + Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + } } } \ No newline at end of file diff --git a/src/Microsoft.Management.Deployment.Projection/ClassesDefinition.cs b/src/Microsoft.Management.Deployment.Projection/ClassesDefinition.cs index 40be562e4f..a39f0f2088 100644 --- a/src/Microsoft.Management.Deployment.Projection/ClassesDefinition.cs +++ b/src/Microsoft.Management.Deployment.Projection/ClassesDefinition.cs @@ -46,10 +46,10 @@ internal static class ClassesDefinition } }, - [typeof(ConnectOptions)] = new() + [typeof(PackageCatalogConnectOptions)] = new() { - ProjectedClassType = typeof(ConnectOptions), - InterfaceType = typeof(IConnectOptions), + ProjectedClassType = typeof(PackageCatalogConnectOptions), + InterfaceType = typeof(IPackageCatalogConnectOptions), Clsids = new Dictionary() { [ClsidContext.InProc] = new Guid("D026FDDC-44D3-443A-8DAB-A4DD969943B3"), diff --git a/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs b/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs index 53b8c9424c..3c4afce9a3 100644 --- a/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs +++ b/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs @@ -23,7 +23,7 @@ public WinGetProjectionFactory(IInstanceInitializer instanceInitializer) public CreateCompositePackageCatalogOptions CreateCreateCompositePackageCatalogOptions() => InstanceInitializer.CreateInstance(); - public ConnectOptions CreateConnectOptions() => InstanceInitializer.CreateInstance(); + public PackageCatalogConnectOptions CreateConnectOptions() => InstanceInitializer.CreateInstance(); public InstallOptions CreateInstallOptions() => InstanceInitializer.CreateInstance(); diff --git a/src/Microsoft.Management.Deployment/CatalogPackage.cpp b/src/Microsoft.Management.Deployment/CatalogPackage.cpp index 16abdd270b..1b603d5dee 100644 --- a/src/Microsoft.Management.Deployment/CatalogPackage.cpp +++ b/src/Microsoft.Management.Deployment/CatalogPackage.cpp @@ -146,4 +146,20 @@ namespace winrt::Microsoft::Management::Deployment::implementation { return m_package; } + Windows::Foundation::Collections::IVectorView CatalogPackage::GetPackageAgreements(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey) + { + ::AppInstaller::Repository::PackageVersionKey internalVersionKey(winrt::to_string(versionKey.PackageCatalogId()), winrt::to_string(versionKey.Version()), winrt::to_string(versionKey.Channel())); + std::shared_ptr<::AppInstaller::Repository::IPackageVersion> availableVersion = m_package.get()->GetAvailableVersion(internalVersionKey); + + auto agreements = availableVersion->GetManifest().CurrentLocalization.Get(); + + for (auto const& agreement : agreements) + { + auto packageAgreement = winrt::make_self>(); + packageAgreement->Initialize(agreement); + m_packageAgreements.Append(*packageAgreement); + } + + return m_packageAgreements.GetView(); + } } diff --git a/src/Microsoft.Management.Deployment/CatalogPackage.h b/src/Microsoft.Management.Deployment/CatalogPackage.h index 291e2cb393..d13d8b4eda 100644 --- a/src/Microsoft.Management.Deployment/CatalogPackage.h +++ b/src/Microsoft.Management.Deployment/CatalogPackage.h @@ -2,6 +2,7 @@ // Licensed under the MIT License. #pragma once #include "CatalogPackage.g.h" +#include namespace winrt::Microsoft::Management::Deployment::implementation { @@ -30,12 +31,15 @@ namespace winrt::Microsoft::Management::Deployment::implementation winrt::Microsoft::Management::Deployment::InstalledStatusType checkTypes); winrt::Windows::Foundation::IAsyncOperation CheckInstalledStatusAsync(); winrt::Microsoft::Management::Deployment::CheckInstalledStatusResult CheckInstalledStatus(); + // Contract 7.0 + winrt::Windows::Foundation::Collections::IVectorView GetPackageAgreements(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey); #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) private: ::AppInstaller::Repository::Source m_source; std::shared_ptr<::AppInstaller::Repository::IPackage> m_package; Windows::Foundation::Collections::IVector m_availableVersions{ winrt::single_threaded_vector() }; + Windows::Foundation::Collections::IVector m_packageAgreements{ winrt::single_threaded_vector() }; winrt::Microsoft::Management::Deployment::PackageVersionInfo m_installedVersion{ nullptr }; winrt::Microsoft::Management::Deployment::PackageVersionInfo m_defaultInstallVersion{ nullptr }; std::once_flag m_installedVersionOnceFlag; diff --git a/src/Microsoft.Management.Deployment/ComClsids.cpp b/src/Microsoft.Management.Deployment/ComClsids.cpp index e510ff2b3f..500a70c796 100644 --- a/src/Microsoft.Management.Deployment/ComClsids.cpp +++ b/src/Microsoft.Management.Deployment/ComClsids.cpp @@ -8,7 +8,7 @@ #include "PackageManager.h" #include "FindPackagesOptions.h" #include "CreateCompositePackageCatalogOptions.h" -#include "ConnectOptions.h" +#include "PackageCatalogConnectOptions.h" #include "InstallOptions.h" #include "UninstallOptions.h" #include "PackageMatchFilter.h" @@ -31,9 +31,9 @@ namespace winrt::Microsoft::Management::Deployment { return __uuidof(winrt::Microsoft::Management::Deployment::implementation::CreateCompositePackageCatalogOptions); } - else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_ConnectOptions)) + else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_PackageCatalogConnectOptions)) { - return __uuidof(winrt::Microsoft::Management::Deployment::implementation::ConnectOptions); + return __uuidof(winrt::Microsoft::Management::Deployment::implementation::PackageCatalogConnectOptions); } else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_InstallOptions)) { diff --git a/src/Microsoft.Management.Deployment/ConnectOptions.cpp b/src/Microsoft.Management.Deployment/ConnectOptions.cpp deleted file mode 100644 index c8e24a6d25..0000000000 --- a/src/Microsoft.Management.Deployment/ConnectOptions.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -#include "pch.h" -#pragma warning( push ) -#pragma warning ( disable : 4467 6388) -// 6388 Allow CreateInstance. -#include -// 4467 Allow use of uuid attribute for com object creation. -#include "ConnectOptions.h" -#pragma warning( pop ) -#include "ConnectOptions.g.cpp" -#include "Helpers.h" - - -namespace winrt::Microsoft::Management::Deployment::implementation -{ - ConnectOptions::ConnectOptions() - { - } - winrt::Windows::Foundation::Collections::IVector ConnectOptions::SourceAgreements() - { - return m_sourceAgreements; - } - void ConnectOptions::SourceAgreements(winrt::Windows::Foundation::Collections::IVector const& value) - { - m_sourceAgreements = value; - } - - CoCreatableMicrosoftManagementDeploymentClass(ConnectOptions); -} diff --git a/src/Microsoft.Management.Deployment/ConnectOptions.h b/src/Microsoft.Management.Deployment/ConnectOptions.h deleted file mode 100644 index 134ab65603..0000000000 --- a/src/Microsoft.Management.Deployment/ConnectOptions.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -#pragma once -#include "ConnectOptions.g.h" -#include "SourceAgreement.h" -#include "Public/ComClsids.h" - -namespace winrt::Microsoft::Management::Deployment::implementation -{ - [uuid(WINGET_OUTOFPROC_COM_CLSID_ConnectOptions)] - struct ConnectOptions : ConnectOptionsT - { - ConnectOptions(); - - winrt::Windows::Foundation::Collections::IVector SourceAgreements(); - - void SourceAgreements(winrt::Windows::Foundation::Collections::IVector const& value); - -#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) - private: - Windows::Foundation::Collections::IVector m_sourceAgreements{ winrt::single_threaded_vector() }; -#endif - }; -} - -#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) -namespace winrt::Microsoft::Management::Deployment::factory_implementation -{ - struct ConnectOptions : ConnectOptionsT - { - }; -} -#endif diff --git a/src/Microsoft.Management.Deployment/InstallOptions.cpp b/src/Microsoft.Management.Deployment/InstallOptions.cpp index c60913ee7b..46f3e64707 100644 --- a/src/Microsoft.Management.Deployment/InstallOptions.cpp +++ b/src/Microsoft.Management.Deployment/InstallOptions.cpp @@ -128,6 +128,13 @@ namespace winrt::Microsoft::Management::Deployment::implementation { m_force = value; } - + void InstallOptions::AcceptPackageAgreements(bool value) + { + m_acceptPackageAgreements = value; + } + bool InstallOptions::AcceptPackageAgreements() + { + return m_acceptPackageAgreements; + } CoCreatableMicrosoftManagementDeploymentClass(InstallOptions); } diff --git a/src/Microsoft.Management.Deployment/InstallOptions.h b/src/Microsoft.Management.Deployment/InstallOptions.h index cd4914e7b3..9802e7931b 100644 --- a/src/Microsoft.Management.Deployment/InstallOptions.h +++ b/src/Microsoft.Management.Deployment/InstallOptions.h @@ -36,6 +36,8 @@ namespace winrt::Microsoft::Management::Deployment::implementation void AllowUpgradeToUnknownVersion(bool value); bool Force(); void Force(bool value); + bool AcceptPackageAgreements(); + void AcceptPackageAgreements(bool value); #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) private: @@ -51,8 +53,11 @@ namespace winrt::Microsoft::Management::Deployment::implementation std::wstring m_additionalPackageCatalogArguments = L""; Windows::Foundation::Collections::IVector m_allowedArchitectures{ winrt::single_threaded_vector() }; + Windows::Foundation::Collections::IVector m_packageAgreements{ + winrt::single_threaded_vector() }; bool m_allowUpgradeToUnknownVersion = false; bool m_force = false; + bool m_acceptPackageAgreements = false; #endif }; } diff --git a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj index 812b7336f7..58e6c70c6a 100644 --- a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj +++ b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj @@ -138,7 +138,6 @@ - @@ -149,7 +148,9 @@ + + @@ -169,7 +170,6 @@ - @@ -180,7 +180,9 @@ + + diff --git a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters index 109143ce4c..bcde4cd1b2 100644 --- a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters +++ b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters @@ -2,7 +2,6 @@ - @@ -12,7 +11,9 @@ + + @@ -33,7 +34,6 @@ - @@ -43,7 +43,9 @@ + + diff --git a/src/Microsoft.Management.Deployment/PackageAgreement.cpp b/src/Microsoft.Management.Deployment/PackageAgreement.cpp new file mode 100644 index 0000000000..2410039905 --- /dev/null +++ b/src/Microsoft.Management.Deployment/PackageAgreement.cpp @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#include "PackageAgreement.h" +#include "PackageAgreement.g.cpp" +#include + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + void PackageAgreement::Initialize(::AppInstaller::Manifest::Agreement packageAgreement) + { + m_packageAgreement = packageAgreement; + } + hstring PackageAgreement::Label() + { + return winrt::to_hstring(m_packageAgreement.Label); + } + hstring PackageAgreement::Text() + { + return winrt::to_hstring(m_packageAgreement.AgreementText); + } + hstring PackageAgreement::Url() + { + return winrt::to_hstring(m_packageAgreement.AgreementUrl); + } +} diff --git a/src/Microsoft.Management.Deployment/PackageAgreement.h b/src/Microsoft.Management.Deployment/PackageAgreement.h new file mode 100644 index 0000000000..da7d3ca2e4 --- /dev/null +++ b/src/Microsoft.Management.Deployment/PackageAgreement.h @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once +#include "pch.h" +#include "PackageAgreement.g.h" +#include + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + struct PackageAgreement : PackageAgreementT + { + PackageAgreement() = default; + +#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) + void Initialize(::AppInstaller::Manifest::Agreement packageAgreement); +#endif + + hstring Label(); + hstring Text(); + hstring Url(); + +#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) + private: + ::AppInstaller::Manifest::Agreement m_packageAgreement{}; +#endif + }; +} diff --git a/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.cpp b/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.cpp new file mode 100644 index 0000000000..68a01b080c --- /dev/null +++ b/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.cpp @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#pragma warning( push ) +#pragma warning ( disable : 4467 6388) +// 6388 Allow CreateInstance. +#include +// 4467 Allow use of uuid attribute for com object creation. +#include "PackageCatalogConnectOptions.h" +#pragma warning( pop ) +#include "PackageCatalogConnectOptions.g.cpp" +#include "Helpers.h" + + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + bool PackageCatalogConnectOptions::AcceptSourceAgreements() + { + return m_acceptSourceAgreements; + } + void PackageCatalogConnectOptions::AcceptSourceAgreements(bool value) + { + m_acceptSourceAgreements = value; + } + + CoCreatableMicrosoftManagementDeploymentClass(PackageCatalogConnectOptions); +} diff --git a/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.h b/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.h new file mode 100644 index 0000000000..1e60f5b87d --- /dev/null +++ b/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.h @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once +#include "PackageCatalogConnectOptions.g.h" +#include "Public/ComClsids.h" + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + [uuid(WINGET_OUTOFPROC_COM_CLSID_PackageCatalogConnectOptions)] + struct PackageCatalogConnectOptions : PackageCatalogConnectOptionsT + { + PackageCatalogConnectOptions() = default; + + bool AcceptSourceAgreements(); + void AcceptSourceAgreements(bool value); + +#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) + private: + bool m_acceptSourceAgreements = false; +#endif + }; +} + +#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) +namespace winrt::Microsoft::Management::Deployment::factory_implementation +{ + struct PackageCatalogConnectOptions : PackageCatalogConnectOptionsT + { + }; +} +#endif diff --git a/src/Microsoft.Management.Deployment/PackageManager.cpp b/src/Microsoft.Management.Deployment/PackageManager.cpp index a3f219d8f4..d7331b6bba 100644 --- a/src/Microsoft.Management.Deployment/PackageManager.cpp +++ b/src/Microsoft.Management.Deployment/PackageManager.cpp @@ -547,6 +547,14 @@ namespace winrt::Microsoft::Management::Deployment::implementation THROW_HR(APPINSTALLER_CLI_ERROR_UPGRADE_VERSION_NOT_NEWER); } + // TODO: Replace the line below with the commented block once we have determined if we need to verify whether package agreements have been accepted. + //if (options.AcceptPackageAgreements()) + //{ + // comContext->SetFlags(AppInstaller::CLI::Execution::ContextFlag::AgreementsAcceptedByCaller); + //} + + comContext->SetFlags(AppInstaller::CLI::Execution::ContextFlag::AgreementsAcceptedByCaller); + // Set upgrade flag comContext->SetFlags(AppInstaller::CLI::Execution::ContextFlag::InstallerExecutionUseUpdate); // Add installed version diff --git a/src/Microsoft.Management.Deployment/PackageManager.idl b/src/Microsoft.Management.Deployment/PackageManager.idl index 055cabda11..7d5ad95bad 100644 --- a/src/Microsoft.Management.Deployment/PackageManager.idl +++ b/src/Microsoft.Management.Deployment/PackageManager.idl @@ -2,7 +2,7 @@ // Licensed under the MIT License. namespace Microsoft.Management.Deployment { - [contractversion(7)] + [contractversion(6)] apicontract WindowsPackageManagerContract{}; /// State of the install @@ -459,6 +459,12 @@ namespace Microsoft.Management.Deployment /// IsSame from IPackage in winget/RepositorySearch is not implemented in V1. /// Determines if the given IPackage refers to the same package as this one. /// virtual bool IsSame(const IPackage*) const = 0; + + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] + { + /// Gets the agreements of this package. + Windows.Foundation.Collections.IVectorView GetPackageAgreements(PackageVersionId versionKey); + } } /// IMPLEMENTATION NOTE: CompositeSearchBehavior from winget/RepositorySource.h @@ -644,7 +650,7 @@ namespace Microsoft.Management.Deployment String AdditionalPackageCatalogArguments; } - [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 7)] + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] { /// Gets the required agreements for connecting to the package catalog (source). Windows.Foundation.Collections.IVectorView SourceAgreements{ get; }; @@ -777,6 +783,9 @@ namespace Microsoft.Management.Deployment /// A string that will be passed to the installer /// IMPLEMENTATION NOTE: maps to "--custom" in the winget cmd line String AdditionalInstallerArguments; + + /// Accept the package agreements required for installation. + Boolean AcceptPackageAgreements; } } @@ -833,16 +842,18 @@ namespace Microsoft.Management.Deployment } /// Options when connecting to a package catalog. - /// Intended to allow agreements to be exposed and passed when connecting to the package catalog. - [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 7)] - runtimeclass ConnectOptions + /// Intended to allow source agreements to be accepted connecting to the package catalog. + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] + runtimeclass PackageCatalogConnectOptions { - ConnectOptions(); + PackageCatalogConnectOptions(); - Windows.Foundation.Collections.IVector SourceAgreements; + /// Accept the source agreements required when connecting to a package catalog. + Boolean AcceptSourceAgreements; } - - [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 7)] + + /// IMPLEMENTATION NOTE: SourceOrigin from AppInstaller::Repository::SourceAgreement + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] runtimeclass SourceAgreement { String Label { get; }; @@ -852,6 +863,17 @@ namespace Microsoft.Management.Deployment String Url{ get; }; } + /// IMPLEMENTATION NOTE: SourceOrigin from AppInstaller::Manifest::Agreement + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] + runtimeclass PackageAgreement + { + String Label { get; }; + + String Text{ get; }; + + String Url{ get; }; + } + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 1)] runtimeclass PackageManager { @@ -962,5 +984,7 @@ namespace Microsoft.Management.Deployment interface Windows.Foundation.Collections.IVectorView; interface Windows.Foundation.Collections.IVector; interface Windows.Foundation.Collections.IVectorView; + interface Windows.Foundation.Collections.IVector; + interface Windows.Foundation.Collections.IVectorView; } } diff --git a/src/Microsoft.Management.Deployment/Public/ComClsids.h b/src/Microsoft.Management.Deployment/Public/ComClsids.h index 4406e08faf..12055244a7 100644 --- a/src/Microsoft.Management.Deployment/Public/ComClsids.h +++ b/src/Microsoft.Management.Deployment/Public/ComClsids.h @@ -19,7 +19,7 @@ #define WINGET_OUTOFPROC_COM_CLSID_InstallOptions "44FE0580-62F7-44D4-9E91-AA9614AB3E86" #define WINGET_OUTOFPROC_COM_CLSID_UninstallOptions "AA2A5C04-1AD9-46C4-B74F-6B334AD7EB8C" #define WINGET_OUTOFPROC_COM_CLSID_PackageMatchFilter "3F85B9F4-487A-4C48-9035-2903F8A6D9E8" -#define WINGET_OUTOFPROC_COM_CLSID_ConnectOptions "6C4F68AC-F601-42FC-8CAF-87D3B3321783" +#define WINGET_OUTOFPROC_COM_CLSID_PackageCatalogConnectOptions "6C4F68AC-F601-42FC-8CAF-87D3B3321783" #endif // Clsids only used in in-proc invocation @@ -35,7 +35,7 @@ namespace winrt::Microsoft::Management::Deployment const CLSID WINGET_INPROC_COM_CLSID_UninstallOptions = { 0x869CB959, 0xEB54, 0x425C, 0xA1, 0xE4, 0x1A, 0x1C, 0x29, 0x1C, 0x64, 0xE9 }; // 869CB959-EB54-425C-A1E4-1A1C291C64E9 const CLSID WINGET_INPROC_COM_CLSID_PackageMatchFilter = { 0x57DC8962, 0x7343, 0x42CD, 0xB9, 0x1C, 0x04, 0xF6, 0xA2, 0x5D, 0xB1, 0xD0 }; // 57DC8962-7343-42CD-B91C-04F6A25DB1D0 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_ConnectOptions = { 0xD026FDDC, 0x44D3, 0x443A, 0x8D, 0xAB, 0xA4, 0xDD, 0x96, 0x99, 0x43, 0xB3 }; //D026FDDC-44D3-443A-8DAB-A4DD969943B3 + const CLSID WINGET_INPROC_COM_CLSID_PackageCatalogConnectOptions = { 0xD026FDDC, 0x44D3, 0x443A, 0x8D, 0xAB, 0xA4, 0xDD, 0x96, 0x99, 0x43, 0xB3 }; //D026FDDC-44D3-443A-8DAB-A4DD969943B3 CLSID GetRedirectedClsidFromInProcClsid(REFCLSID clsid); } \ No newline at end of file diff --git a/src/WindowsPackageManager/main.cpp b/src/WindowsPackageManager/main.cpp index 56453ff034..dba52c0098 100644 --- a/src/WindowsPackageManager/main.cpp +++ b/src/WindowsPackageManager/main.cpp @@ -21,7 +21,7 @@ using namespace winrt::Microsoft::Management::Deployment; CoCreatableClassWrlCreatorMapInclude(PackageManager); CoCreatableClassWrlCreatorMapInclude(FindPackagesOptions); CoCreatableClassWrlCreatorMapInclude(CreateCompositePackageCatalogOptions); -CoCreatableClassWrlCreatorMapInclude(ConnectOptions); +CoCreatableClassWrlCreatorMapInclude(PackageCatalogConnectOptions); CoCreatableClassWrlCreatorMapInclude(InstallOptions); CoCreatableClassWrlCreatorMapInclude(UninstallOptions); CoCreatableClassWrlCreatorMapInclude(PackageMatchFilter); From 8f12aa0bdb13308661ad1a2e975e038109207b36 Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Thu, 26 Jan 2023 11:14:26 -0800 Subject: [PATCH 03/17] save work --- .../Interop/FindPackagesInterop.cs | 3 +- .../CatalogPackage.cpp | 47 +++++-- .../CatalogPackage.h | 7 +- .../Documentation.cpp | 22 ++++ .../Documentation.h | 26 ++++ .../Microsoft.Management.Deployment.vcxproj | 4 + ...soft.Management.Deployment.vcxproj.filters | 4 + .../PackageLocale.cpp | 115 ++++++++++++++++++ .../PackageLocale.h | 61 ++++++++++ .../PackageManager.idl | 61 +++++++++- 10 files changed, 332 insertions(+), 18 deletions(-) create mode 100644 src/Microsoft.Management.Deployment/Documentation.cpp create mode 100644 src/Microsoft.Management.Deployment/Documentation.h create mode 100644 src/Microsoft.Management.Deployment/PackageLocale.cpp create mode 100644 src/Microsoft.Management.Deployment/PackageLocale.h diff --git a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs index 772a6c125f..9b38bf58a2 100644 --- a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs @@ -79,7 +79,8 @@ public void FindPackagesVerifyAgreements() var catalogPackage = searchResult[0].CatalogPackage; var packageVersionId = catalogPackage.AvailableVersions[0]; - var packageAgreements = catalogPackage.GetPackageAgreements(packageVersionId); + var defaultLocale = catalogPackage.GetDefaultLocale(packageVersionId); + var packageAgreements = defaultLocale.Agreements; Assert.AreEqual(1, packageAgreements.Count); diff --git a/src/Microsoft.Management.Deployment/CatalogPackage.cpp b/src/Microsoft.Management.Deployment/CatalogPackage.cpp index 1b603d5dee..bf0e1ef722 100644 --- a/src/Microsoft.Management.Deployment/CatalogPackage.cpp +++ b/src/Microsoft.Management.Deployment/CatalogPackage.cpp @@ -6,12 +6,14 @@ #include "CatalogPackage.h" #include "CatalogPackage.g.cpp" #include "PackageCatalog.h" +#include "PackageLocale.h" #include "PackageVersionInfo.h" #include "PackageVersionId.h" #include "PackageInstallerInstalledStatus.h" #include "CheckInstalledStatusResult.h" #include + namespace winrt::Microsoft::Management::Deployment::implementation { void CatalogPackage::Initialize( @@ -146,20 +148,43 @@ namespace winrt::Microsoft::Management::Deployment::implementation { return m_package; } - Windows::Foundation::Collections::IVectorView CatalogPackage::GetPackageAgreements(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey) + winrt::Microsoft::Management::Deployment::PackageLocale CatalogPackage::GetDefaultLocale(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey) { - ::AppInstaller::Repository::PackageVersionKey internalVersionKey(winrt::to_string(versionKey.PackageCatalogId()), winrt::to_string(versionKey.Version()), winrt::to_string(versionKey.Channel())); + ::AppInstaller::Repository::PackageVersionKey internalVersionKey(winrt::to_string(versionKey.PackageCatalogId()), winrt::to_string(versionKey.Version()), winrt::to_string(versionKey.Channel())); + auto defaultLocale = winrt::make_self>(); + std::shared_ptr<::AppInstaller::Repository::IPackageVersion> availableVersion = m_package.get()->GetAvailableVersion(internalVersionKey); + if (availableVersion) + { + defaultLocale->Initialize(availableVersion->GetManifest().DefaultLocalization); + } - auto agreements = availableVersion->GetManifest().CurrentLocalization.Get(); - - for (auto const& agreement : agreements) - { - auto packageAgreement = winrt::make_self>(); - packageAgreement->Initialize(agreement); - m_packageAgreements.Append(*packageAgreement); - } + return *defaultLocale; + } + winrt::Microsoft::Management::Deployment::PackageLocale CatalogPackage::GetLocale(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey, hstring locale) + { + ::AppInstaller::Repository::PackageVersionKey internalVersionKey(winrt::to_string(versionKey.PackageCatalogId()), winrt::to_string(versionKey.Version()), winrt::to_string(versionKey.Channel())); + auto currentLocale = winrt::make_self>(); - return m_packageAgreements.GetView(); + std::shared_ptr<::AppInstaller::Repository::IPackageVersion> availableVersion = m_package.get()->GetAvailableVersion(internalVersionKey); + if (availableVersion) + { + availableVersion->GetManifest().ApplyLocale(winrt::to_string(locale)); + currentLocale->Initialize(availableVersion->GetManifest().CurrentLocalization); + } + + return *currentLocale; + } + winrt::Windows::Foundation::Collections::IVectorView CatalogPackage::AvailableLocales(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey) + { + Windows::Foundation::Collections::IVector locales{ winrt::single_threaded_vector() }; + ::AppInstaller::Repository::PackageVersionKey internalVersionKey(winrt::to_string(versionKey.PackageCatalogId()), winrt::to_string(versionKey.Version()), winrt::to_string(versionKey.Channel())); + + for (auto const& localization : m_package.get()->GetAvailableVersion(internalVersionKey)->GetManifest().Localizations) + { + locales.Append(winrt::to_hstring(localization.Locale)); + } + + return locales.GetView(); } } diff --git a/src/Microsoft.Management.Deployment/CatalogPackage.h b/src/Microsoft.Management.Deployment/CatalogPackage.h index d13d8b4eda..71afee3801 100644 --- a/src/Microsoft.Management.Deployment/CatalogPackage.h +++ b/src/Microsoft.Management.Deployment/CatalogPackage.h @@ -2,7 +2,7 @@ // Licensed under the MIT License. #pragma once #include "CatalogPackage.g.h" -#include +#include "PackageLocale.h" namespace winrt::Microsoft::Management::Deployment::implementation { @@ -32,14 +32,15 @@ namespace winrt::Microsoft::Management::Deployment::implementation winrt::Windows::Foundation::IAsyncOperation CheckInstalledStatusAsync(); winrt::Microsoft::Management::Deployment::CheckInstalledStatusResult CheckInstalledStatus(); // Contract 7.0 - winrt::Windows::Foundation::Collections::IVectorView GetPackageAgreements(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey); + winrt::Microsoft::Management::Deployment::PackageLocale GetDefaultLocale(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey); + winrt::Microsoft::Management::Deployment::PackageLocale GetLocale(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey, hstring locale); + winrt::Windows::Foundation::Collections::IVectorView AvailableLocales(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey); #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) private: ::AppInstaller::Repository::Source m_source; std::shared_ptr<::AppInstaller::Repository::IPackage> m_package; Windows::Foundation::Collections::IVector m_availableVersions{ winrt::single_threaded_vector() }; - Windows::Foundation::Collections::IVector m_packageAgreements{ winrt::single_threaded_vector() }; winrt::Microsoft::Management::Deployment::PackageVersionInfo m_installedVersion{ nullptr }; winrt::Microsoft::Management::Deployment::PackageVersionInfo m_defaultInstallVersion{ nullptr }; std::once_flag m_installedVersionOnceFlag; diff --git a/src/Microsoft.Management.Deployment/Documentation.cpp b/src/Microsoft.Management.Deployment/Documentation.cpp new file mode 100644 index 0000000000..87f56a1c43 --- /dev/null +++ b/src/Microsoft.Management.Deployment/Documentation.cpp @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#include "Documentation.g.cpp" +#include "Documentation.h" +#include + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + void Documentation::Initialize(::AppInstaller::Manifest::Documentation documentation) + { + m_documentation = documentation; + } + hstring Documentation::DocumentLabel() + { + return winrt::to_hstring(m_documentation.DocumentLabel); + } + hstring Documentation::DocumentUrl() + { + return winrt::to_hstring(m_documentation.DocumentUrl); + } +} diff --git a/src/Microsoft.Management.Deployment/Documentation.h b/src/Microsoft.Management.Deployment/Documentation.h new file mode 100644 index 0000000000..585aff8249 --- /dev/null +++ b/src/Microsoft.Management.Deployment/Documentation.h @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once +#include "pch.h" +#include "Documentation.g.h" +#include + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + struct Documentation : DocumentationT + { + Documentation() = default; + +#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) + void Initialize(::AppInstaller::Manifest::Documentation documentation); +#endif + + hstring DocumentLabel(); + hstring DocumentUrl(); + +#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) + private: + ::AppInstaller::Manifest::Documentation m_documentation{}; +#endif + }; +} diff --git a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj index 58e6c70c6a..925edc5923 100644 --- a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj +++ b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj @@ -141,6 +141,7 @@ + @@ -155,6 +156,7 @@ + @@ -173,6 +175,7 @@ + @@ -187,6 +190,7 @@ + diff --git a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters index bcde4cd1b2..99cbbccf14 100644 --- a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters +++ b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters @@ -5,6 +5,7 @@ + @@ -16,6 +17,7 @@ + @@ -37,6 +39,7 @@ + @@ -48,6 +51,7 @@ + diff --git a/src/Microsoft.Management.Deployment/PackageLocale.cpp b/src/Microsoft.Management.Deployment/PackageLocale.cpp new file mode 100644 index 0000000000..93fa1389d6 --- /dev/null +++ b/src/Microsoft.Management.Deployment/PackageLocale.cpp @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#include +#include "PackageLocale.h" +#include "PackageLocale.g.cpp" +#include "Documentation.h" +#include + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + using Localization = ::AppInstaller::Manifest::Localization; + + void PackageLocale::Initialize(::AppInstaller::Manifest::ManifestLocalization manifestLocalization) + { + m_manifestLocalization = manifestLocalization; + } + + hstring PackageLocale::Publisher() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::PublisherSupportUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::PrivacyUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::Author() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::PackageName() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::PackageUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::License() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::LicenseUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::Copyright() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::CopyrightUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::ShortDescription() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::Description() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::ReleaseNotes() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::ReleaseNotesUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring PackageLocale::InstallationNotes() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + winrt::Windows::Foundation::Collections::IVectorView PackageLocale::Agreements() + { + for (auto const& agreement : m_manifestLocalization.Get()) + { + auto packageAgreement = winrt::make_self>(); + packageAgreement->Initialize(agreement); + m_packageAgreements.Append(*packageAgreement); + } + + return m_packageAgreements.GetView(); + } + winrt::Windows::Foundation::Collections::IVectorView PackageLocale::Tags() + { + if (!m_tags) + { + // Vector hasn't been created yet, create and populate it. + auto tags = winrt::single_threaded_vector(); + for (auto&& tag : m_manifestLocalization.Get()) + { + tags.Append(winrt::to_hstring(tag)); + } + m_tags = tags; + } + return m_tags.GetView(); + } + winrt::Windows::Foundation::Collections::IVectorView PackageLocale::Documentations() + { + for (auto const& documentation : m_manifestLocalization.Get()) + { + auto documentationImpl = winrt::make_self>(); + documentationImpl->Initialize(documentation); + m_documentations.Append(*documentationImpl); + } + + return m_documentations.GetView(); + } +} diff --git a/src/Microsoft.Management.Deployment/PackageLocale.h b/src/Microsoft.Management.Deployment/PackageLocale.h new file mode 100644 index 0000000000..29632e40b4 --- /dev/null +++ b/src/Microsoft.Management.Deployment/PackageLocale.h @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once +#include "PackageLocale.g.h" +#include "PackageAgreement.h" +#include "Documentation.h" + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + struct PackageLocale : PackageLocaleT + { + PackageLocale() = default; + +#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) + void Initialize(::AppInstaller::Manifest::ManifestLocalization manifestLocalization); +#endif + hstring Publisher(); + + hstring PublisherSupportUrl(); + + hstring PrivacyUrl(); + + hstring Author(); + + hstring PackageName(); + + hstring PackageUrl(); + + hstring License(); + + hstring LicenseUrl(); + + hstring Copyright(); + + hstring CopyrightUrl(); + + hstring ShortDescription(); + + hstring Description(); + + winrt::Windows::Foundation::Collections::IVectorView Tags(); + + winrt::Windows::Foundation::Collections::IVectorView Agreements(); + + winrt::Windows::Foundation::Collections::IVectorView Documentations(); + + hstring ReleaseNotes(); + + hstring ReleaseNotesUrl(); + + hstring InstallationNotes(); + +#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) + private: + ::AppInstaller::Manifest::ManifestLocalization m_manifestLocalization; + Windows::Foundation::Collections::IVector m_packageAgreements{ winrt::single_threaded_vector() }; + Windows::Foundation::Collections::IVector m_documentations{ winrt::single_threaded_vector() }; + Windows::Foundation::Collections::IVector m_tags{ nullptr }; +#endif + }; +} diff --git a/src/Microsoft.Management.Deployment/PackageManager.idl b/src/Microsoft.Management.Deployment/PackageManager.idl index 7d5ad95bad..9524146a14 100644 --- a/src/Microsoft.Management.Deployment/PackageManager.idl +++ b/src/Microsoft.Management.Deployment/PackageManager.idl @@ -462,8 +462,11 @@ namespace Microsoft.Management.Deployment [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] { - /// Gets the agreements of this package. - Windows.Foundation.Collections.IVectorView GetPackageAgreements(PackageVersionId versionKey); + PackageLocale GetDefaultLocale(PackageVersionId versionKey); + + PackageLocale GetLocale(PackageVersionId versionKey, String locale); + + Windows.Foundation.Collections.IVectorView AvailableLocales(PackageVersionId versionKey); } } @@ -851,7 +854,16 @@ namespace Microsoft.Management.Deployment /// Accept the source agreements required when connecting to a package catalog. Boolean AcceptSourceAgreements; } - + + /// IMPLEMENTATION NOTE: SourceOrigin from AppInstaller::Repository::Documentation + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] + runtimeclass Documentation + { + String DocumentLabel { get; }; + + String DocumentUrl{ get; }; + } + /// IMPLEMENTATION NOTE: SourceOrigin from AppInstaller::Repository::SourceAgreement [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] runtimeclass SourceAgreement @@ -874,6 +886,47 @@ namespace Microsoft.Management.Deployment String Url{ get; }; } + /// IMPLEMENTATION NOTE: SourceOrigin from AppInstaller::Manifest::Localization + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] + runtimeclass PackageLocale + { + String Publisher { get; }; + + String PublisherSupportUrl { get; }; + + String PrivacyUrl{ get; }; + + String Author{ get; }; + + String PackageName{ get; }; + + String PackageUrl{ get; }; + + String License{ get; }; + + String LicenseUrl{ get; }; + + String Copyright{ get; }; + + String CopyrightUrl{ get; }; + + String ShortDescription{ get; }; + + String Description{ get; }; + + Windows.Foundation.Collections.IVectorView Tags{ get; }; + + Windows.Foundation.Collections.IVectorView Agreements{ get; }; + + Windows.Foundation.Collections.IVectorView Documentations{ get; }; + + String ReleaseNotes{ get; }; + + String ReleaseNotesUrl{ get; }; + + String InstallationNotes{ get; }; + } + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 1)] runtimeclass PackageManager { @@ -986,5 +1039,7 @@ namespace Microsoft.Management.Deployment interface Windows.Foundation.Collections.IVectorView; interface Windows.Foundation.Collections.IVector; interface Windows.Foundation.Collections.IVectorView; + interface Windows.Foundation.Collections.IVector; + interface Windows.Foundation.Collections.IVectorView; } } From 39e7d35e2ddf89d8a7e540d9b96571e19686fb5f Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Fri, 27 Jan 2023 17:42:56 -0800 Subject: [PATCH 04/17] add E2E tests --- .../Workflows/PromptFlow.cpp | 2 +- .../AppInstallerCLIE2ETests.csproj | 6 +- .../Interop/BaseInterop.cs | 3 +- .../Interop/FindPackagesInterop.cs | 121 ++++++++++++++-- .../Interop/InstallInterop.cs | 5 +- .../TestExeInstaller_Agreements.yaml | 26 ---- ...stExeInstaller_CatalogPackageMetadata.yaml | 46 ++++++ .../TestExeInstaller_MultipleLocale.yaml | 54 +++++++ .../WinGetProjectionFactory.cs | 2 +- .../CatalogPackage.cpp | 56 +++++--- .../CatalogPackage.h | 9 +- .../CatalogPackageMetadata.cpp | 134 ++++++++++++++++++ ...ckageLocale.h => CatalogPackageMetadata.h} | 14 +- .../InstallOptions.h | 2 +- .../Microsoft.Management.Deployment.vcxproj | 4 +- ...soft.Management.Deployment.vcxproj.filters | 4 +- .../PackageCatalogConnectOptions.h | 2 +- .../PackageCatalogReference.cpp | 20 ++- .../PackageCatalogReference.h | 3 + .../PackageLocale.cpp | 115 --------------- .../PackageManager.cpp | 13 +- .../PackageManager.idl | 17 ++- 22 files changed, 436 insertions(+), 222 deletions(-) delete mode 100644 src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_Agreements.yaml create mode 100644 src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_CatalogPackageMetadata.yaml create mode 100644 src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml create mode 100644 src/Microsoft.Management.Deployment/CatalogPackageMetadata.cpp rename src/Microsoft.Management.Deployment/{PackageLocale.h => CatalogPackageMetadata.h} (81%) delete mode 100644 src/Microsoft.Management.Deployment/PackageLocale.cpp diff --git a/src/AppInstallerCLICore/Workflows/PromptFlow.cpp b/src/AppInstallerCLICore/Workflows/PromptFlow.cpp index 8ce6c9cb40..09f6aa80c7 100644 --- a/src/AppInstallerCLICore/Workflows/PromptFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/PromptFlow.cpp @@ -78,7 +78,7 @@ namespace AppInstaller::CLI::Workflow } // Show message for each individual implicit agreement field - auto fields = source.GetAgreementFieldsFromSourceInformation(); + auto fields = source.GetAgreementFieldsFromSourceInformation(); if (WI_IsFlagSet(fields, Repository::ImplicitAgreementFieldEnum::Market)) { context.Reporter.Info() << Resource::String::SourceAgreementsMarketMessage << std::endl; diff --git a/src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj b/src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj index 8f86246921..5dca17ff68 100644 --- a/src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj +++ b/src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj @@ -45,11 +45,7 @@ PreserveNewest - - - - - + PreserveNewest diff --git a/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs b/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs index cf8477189a..66f20fa788 100644 --- a/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs @@ -77,7 +77,8 @@ protected IReadOnlyList FindAllPackages( findPackageOptions.Filters.Add(filter); // Connect and find package - var source = packageCatalogReference.Connect().PackageCatalog; + var packageCatalogConnectOptions = this.TestFactory.CreatePackageCatalogConnectOptions(); + var source = packageCatalogReference.Connect(packageCatalogConnectOptions).PackageCatalog; return source.FindPackages(findPackageOptions).Matches; } } diff --git a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs index 9b38bf58a2..b8b6b80b8e 100644 --- a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs @@ -5,7 +5,7 @@ // ----------------------------------------------------------------------------- namespace AppInstallerCLIE2ETests.Interop -{ +{ using Microsoft.Management.Deployment; using Microsoft.Management.Deployment.Projection; using NUnit.Framework; @@ -36,7 +36,8 @@ public FindPackagesInterop(IInstanceInitializer initializer) public void SetUp() { this.packageManager = this.TestFactory.CreatePackageManager(); - this.testSource = this.packageManager.GetPackageCatalogByName(Constants.TestSourceName); + //this.testSource = this.packageManager.GetPackageCatalogByName(Constants.TestSourceName); + this.testSource = this.packageManager.GetPackageCatalogByName("msstore"); } /// @@ -66,28 +67,124 @@ public void FindPackagesMultipleMatchingQuery() } /// - /// Test to find a package with agreements and verify COM output. + /// Test to find a package and verify the CatalogPackageMetadata COM output. /// [Test] - public void FindPackagesVerifyAgreements() + public void FindPackagesVerifyDefaultLocaleFields() { - // Find package - var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.PackageAgreements"); + var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.CatalogPackageMetadata"); - // Assert Assert.AreEqual(1, searchResult.Count); var catalogPackage = searchResult[0].CatalogPackage; var packageVersionId = catalogPackage.AvailableVersions[0]; - var defaultLocale = catalogPackage.GetDefaultLocale(packageVersionId); - var packageAgreements = defaultLocale.Agreements; + var catalogPackageMetadata = catalogPackage.GetCatalogPackageMetadata(packageVersionId, string.Empty); + + Assert.AreEqual("testAuthor", catalogPackageMetadata.Author); + Assert.AreEqual("AppInstallerTest", catalogPackageMetadata.Publisher); + Assert.AreEqual("https://testPublisherUrl.com", catalogPackageMetadata.PublisherUrl); + Assert.AreEqual("https://testPublisherSupportUrl.com", catalogPackageMetadata.PublisherSupportUrl); + Assert.AreEqual("https://testPrivacyUrl.com", catalogPackageMetadata.PrivacyUrl); + + Assert.AreEqual("https://testPackageUrl.com", catalogPackageMetadata.PackageUrl); + Assert.AreEqual("testLicense", catalogPackageMetadata.License); + Assert.AreEqual("https://testLicenseUrl.com", catalogPackageMetadata.LicenseUrl); + Assert.AreEqual("testCopyright", catalogPackageMetadata.Copyright); + Assert.AreEqual("https://testCopyrightUrl.com", catalogPackageMetadata.CopyrightUrl); + Assert.AreEqual("testDescription", catalogPackageMetadata.Description); + Assert.AreEqual("testShortDescription", catalogPackageMetadata.ShortDescription); + + var tags = catalogPackageMetadata.Tags; + Assert.AreEqual(2, tags.Count); + Assert.AreEqual("tag1", tags[0]); + Assert.AreEqual("tag2", tags[1]); + Assert.AreEqual("testReleaseNotes", catalogPackageMetadata.ReleaseNotes); + Assert.AreEqual("https://testReleaseNotes.net", catalogPackageMetadata.ReleaseNotesUrl); + Assert.AreEqual("testInstallationNotes", catalogPackageMetadata.InstallationNotes); + + var packageAgreements = catalogPackageMetadata.Agreements; + Assert.AreEqual(1, packageAgreements.Count); + var agreement = packageAgreements[0]; + Assert.AreEqual("testAgreementLabel", agreement.Label); + Assert.AreEqual("testAgreementText", agreement.Text); + Assert.AreEqual("https://testAgreementUrl.net", agreement.Url); + + var documentations = catalogPackageMetadata.Documentations; + Assert.AreEqual(1, documentations.Count); + + var documentation = documentations[0]; + Assert.AreEqual("testDocumentLabel", documentation.DocumentLabel); + Assert.AreEqual("https://testDocumentUrl.com", documentation.DocumentUrl); + } + + /// + /// Verifies that an exception is thrown if the provided locale string is invalid. + /// + [Test] + public void FindPackagesInvalidLocale() + { + var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.CatalogPackageMetadata"); + var catalogPackage = searchResult[0].CatalogPackage; + var packageVersionId = catalogPackage.AvailableVersions[0]; + Assert.Throws(() => searchResult[0].CatalogPackage.GetCatalogPackageMetadata(packageVersionId, "badLocale")); + } + + /// + /// Verifies that the correct CatalogPackageMetadata is exposed when specifying a locale. + /// + [Test] + public void FindPackagesGetCatalogPackageMetadataLocale() + { + var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.MultipleLocale"); + Assert.AreEqual(1, searchResult.Count); + + var catalogPackage = searchResult[0].CatalogPackage; + var packageVersionId = catalogPackage.AvailableVersions[0]; + var catalogPackageMetadata = catalogPackage.GetCatalogPackageMetadata(packageVersionId, "zh-CN"); + + Assert.AreEqual("zh-CN", catalogPackageMetadata.Locale); + Assert.AreEqual("localeLicense", catalogPackageMetadata.License); + Assert.AreEqual("localePackageName", catalogPackageMetadata.PackageName); + Assert.AreEqual("localePublisher", catalogPackageMetadata.Publisher); + + var tags = catalogPackageMetadata.Tags; + Assert.AreEqual(2, tags.Count); + Assert.AreEqual("tag1", tags[0]); + Assert.AreEqual("tag2", tags[1]); + + var packageAgreements = catalogPackageMetadata.Agreements; Assert.AreEqual(1, packageAgreements.Count); var agreement = packageAgreements[0]; - Assert.AreEqual("DefaultLabel", agreement.Label); - Assert.AreEqual("DefaultText", agreement.Text); - Assert.AreEqual("https://DefaultAgreementUrl.net", agreement.Url); + Assert.AreEqual("localeAgreementLabel", agreement.Label); + Assert.AreEqual("localeAgreement", agreement.Text); + Assert.AreEqual("https://localeAgreementUrl.net", agreement.Url); + + var documentations = catalogPackageMetadata.Documentations; + Assert.AreEqual(1, documentations.Count); + + var documentation = documentations[0]; + Assert.AreEqual("localeDocumentLabel", documentation.DocumentLabel); + Assert.AreEqual("https://localeDocumentUrl.com", documentation.DocumentUrl); + } + + /// + /// Verifies that GetAllCatalogPackageMetadata() returns the correct number of CatalogPackageMetadata. + /// + [Test] + public void FindPackagesGetAllCatalogPackageMetadata() + { + var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.MultipleLocale"); + Assert.AreEqual(1, searchResult.Count); + + var catalogPackage = searchResult[0].CatalogPackage; + var packageVersionId = catalogPackage.AvailableVersions[0]; + var allCatalogPackageMetadata = catalogPackage.GetAllCatalogPackageMetadata(packageVersionId); + + Assert.AreEqual(2, allCatalogPackageMetadata.Count); + Assert.AreEqual("zh-CN", allCatalogPackageMetadata[0].Locale); + Assert.AreEqual("en-GB", allCatalogPackageMetadata[1].Locale); } } } \ No newline at end of file diff --git a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs index c5f941fe86..6cd07d9e10 100644 --- a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs @@ -525,7 +525,7 @@ public async Task InstallRequireUserScopeAndUnknown() public async Task InstallWithAgreementsAccepted() { // Find package - var searchResult = this.FindOnePackage(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.PackageAgreements"); + var searchResult = this.FindOnePackage(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.TestExeInstaller"); // Configure installation var installOptions = this.TestFactory.CreateInstallOptions(); @@ -535,9 +535,6 @@ public async Task InstallWithAgreementsAccepted() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - - // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); } } } \ No newline at end of file diff --git a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_Agreements.yaml b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_Agreements.yaml deleted file mode 100644 index d164dcfc87..0000000000 --- a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_Agreements.yaml +++ /dev/null @@ -1,26 +0,0 @@ -PackageIdentifier: AppInstallerTest.PackageAgreements -PackageVersion: 2.0.0.0 -PackageName: TestPortableExe -PackageLocale: en-US -Publisher: AppInstallerTest -License: Test -ShortDescription: E2E test for portable install. -Installers: - - Architecture: x64 - InstallerUrl: https://localhost:5001/TestKit/AppInstallerTestExeInstaller/AppInstallerTestExeInstaller.exe - InstallerType: exe - InstallerSha256: - InstallerSwitches: - Custom: /execustom - SilentWithProgress: /exeswp - Silent: /exesilent - Interactive: /exeinteractive - Language: /exeenus - Log: /LogFile - InstallLocation: /InstallDir -Agreements: - - AgreementLabel: DefaultLabel - Agreement: DefaultText - AgreementUrl: https://DefaultAgreementUrl.net -ManifestType: singleton -ManifestVersion: 1.2.0 \ No newline at end of file diff --git a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_CatalogPackageMetadata.yaml b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_CatalogPackageMetadata.yaml new file mode 100644 index 0000000000..63d581eb2d --- /dev/null +++ b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_CatalogPackageMetadata.yaml @@ -0,0 +1,46 @@ +# Manifest for verifying the output of the CatalogPackageMetadata COM object. +PackageIdentifier: AppInstallerTest.CatalogPackageMetadata +PackageVersion: 1.0.0.0 +PackageName: TestCatalogPackageMetadata +PackageLocale: en-US +Publisher: AppInstallerTest +License: testLicense +ShortDescription: testShortDescription +Installers: + - Architecture: x64 + InstallerUrl: https://localhost:5001/TestKit/AppInstallerTestExeInstaller/AppInstallerTestExeInstaller.exe + InstallerType: exe + InstallerSha256: + InstallerSwitches: + Custom: /execustom + SilentWithProgress: /exeswp + Silent: /exesilent + Interactive: /exeinteractive + Language: /exeenus + Log: /LogFile + InstallLocation: /InstallDir +Agreements: + - AgreementLabel: testAgreementLabel + Agreement: testAgreementText + AgreementUrl: https://testAgreementUrl.net +PublisherUrl: https://testPublisherUrl.com +PublisherSupportUrl: https://testPublisherSupportUrl.com +PrivacyUrl: https://testPrivacyUrl.com +Author: testAuthor +PackageUrl: https://testPackageUrl.com +LicenseUrl: https://testLicenseUrl.com +Copyright: testCopyright +CopyrightUrl: https://testCopyrightUrl.com +Description: testDescription +Tags: + - "tag1" + - "tag2" +ReleaseNotes: testReleaseNotes +ReleaseNotesUrl: https://testReleaseNotes.net +PurchaseUrl: https://testPurchaseUrl.com +InstallationNotes: testInstallationNotes +Documentations: + - DocumentLabel: testDocumentLabel + DocumentUrl: https://testDocumentUrl.com +ManifestType: singleton +ManifestVersion: 1.2.0 \ No newline at end of file diff --git a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml new file mode 100644 index 0000000000..d0ce94223e --- /dev/null +++ b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml @@ -0,0 +1,54 @@ +# Manifest for verifying multiple locales +PackageIdentifier: AppInstallerTest.MultipleLocale +PackageVersion: 1.0.0.0 +PackageName: TestMultipleLocale +PackageLocale: en-US +Publisher: AppInstallerTest +License: testLicense +LicenseUrl: https://testLicenseUrl.com +ShortDescription: testShortDescription +Installers: + - Architecture: x64 + InstallerUrl: https://localhost:5001/TestKit/AppInstallerTestExeInstaller/AppInstallerTestExeInstaller.exe + InstallerType: exe + InstallerSha256: + InstallerSwitches: + Custom: /execustom + SilentWithProgress: /exeswp + Silent: /exesilent + Interactive: /exeinteractive + Language: /exeenus + Log: /LogFile + InstallLocation: /InstallDir +Agreements: + - AgreementLabel: testAgreementLabel + Agreement: testAgreementText + AgreementUrl: https://testAgreementUrl.net +Localization: +- Author: localeAuthor + Copyright: localeCopyright + License: localeLicense + LicenseUrl: https://localeLicenseUrl.com + PackageLocale: zh-CN + PackageName: localePackageName + PackageUrl: https://localePackageUrl.com + Publisher: localePublisher + PublisherSupportUrl: https://localePublisherSupportUrl.com + PublisherUrl: https://localePublisherUrl.com + ReleaseNotesUrl: https://localeReleaseNotesUrl.com + Agreements: + - AgreementLabel: localeAgreementLabel + Agreement: localeAgreement + AgreementUrl: https://localeAgreementUrl.net + Documentations: + - DocumentLabel: localeDocumentLabel + DocumentUrl: https://localeDocumentLabel.com + Tags: + - tag1 + - tag2 +- PackageLocale: en-GB + PackageName: packageNameUK + License: licenseUK + Publisher: publisherUK +ManifestType: merged +ManifestVersion: 1.2.0 \ No newline at end of file diff --git a/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs b/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs index 3c4afce9a3..782427f07b 100644 --- a/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs +++ b/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs @@ -23,7 +23,7 @@ public WinGetProjectionFactory(IInstanceInitializer instanceInitializer) public CreateCompositePackageCatalogOptions CreateCreateCompositePackageCatalogOptions() => InstanceInitializer.CreateInstance(); - public PackageCatalogConnectOptions CreateConnectOptions() => InstanceInitializer.CreateInstance(); + public PackageCatalogConnectOptions CreatePackageCatalogConnectOptions() => InstanceInitializer.CreateInstance(); public InstallOptions CreateInstallOptions() => InstanceInitializer.CreateInstance(); diff --git a/src/Microsoft.Management.Deployment/CatalogPackage.cpp b/src/Microsoft.Management.Deployment/CatalogPackage.cpp index bf0e1ef722..f4fba10dee 100644 --- a/src/Microsoft.Management.Deployment/CatalogPackage.cpp +++ b/src/Microsoft.Management.Deployment/CatalogPackage.cpp @@ -3,10 +3,11 @@ #include "pch.h" #include #include +#include #include "CatalogPackage.h" #include "CatalogPackage.g.cpp" +#include "CatalogPackageMetadata.h" #include "PackageCatalog.h" -#include "PackageLocale.h" #include "PackageVersionInfo.h" #include "PackageVersionId.h" #include "PackageInstallerInstalledStatus.h" @@ -148,43 +149,52 @@ namespace winrt::Microsoft::Management::Deployment::implementation { return m_package; } - winrt::Microsoft::Management::Deployment::PackageLocale CatalogPackage::GetDefaultLocale(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey) + Microsoft::Management::Deployment::CatalogPackageMetadata CatalogPackage::GetCatalogPackageMetadata(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey, const hstring& locale) { - ::AppInstaller::Repository::PackageVersionKey internalVersionKey(winrt::to_string(versionKey.PackageCatalogId()), winrt::to_string(versionKey.Version()), winrt::to_string(versionKey.Channel())); - auto defaultLocale = winrt::make_self>(); - - std::shared_ptr<::AppInstaller::Repository::IPackageVersion> availableVersion = m_package.get()->GetAvailableVersion(internalVersionKey); - if (availableVersion) - { - defaultLocale->Initialize(availableVersion->GetManifest().DefaultLocalization); - } + std::string localeString = winrt::to_string(locale); - return *defaultLocale; - } - winrt::Microsoft::Management::Deployment::PackageLocale CatalogPackage::GetLocale(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey, hstring locale) - { ::AppInstaller::Repository::PackageVersionKey internalVersionKey(winrt::to_string(versionKey.PackageCatalogId()), winrt::to_string(versionKey.Version()), winrt::to_string(versionKey.Channel())); - auto currentLocale = winrt::make_self>(); + auto catalogPackageMetadata = winrt::make_self>(); std::shared_ptr<::AppInstaller::Repository::IPackageVersion> availableVersion = m_package.get()->GetAvailableVersion(internalVersionKey); if (availableVersion) { - availableVersion->GetManifest().ApplyLocale(winrt::to_string(locale)); - currentLocale->Initialize(availableVersion->GetManifest().CurrentLocalization); + auto manifest = availableVersion->GetManifest(); + + if (localeString.empty()) + { + catalogPackageMetadata->Initialize(manifest.DefaultLocalization); + } + else + { + if (!::AppInstaller::Locale::IsWellFormedBcp47Tag(localeString)) + { + throw hresult_invalid_argument(); + } + + manifest.ApplyLocale(localeString); + catalogPackageMetadata->Initialize(manifest.CurrentLocalization); + } } - return *currentLocale; + return *catalogPackageMetadata; } - winrt::Windows::Foundation::Collections::IVectorView CatalogPackage::AvailableLocales(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey) + winrt::Windows::Foundation::Collections::IVectorView CatalogPackage::GetAllCatalogPackageMetadata(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey) { - Windows::Foundation::Collections::IVector locales{ winrt::single_threaded_vector() }; + Windows::Foundation::Collections::IVector allCatalogPackageMetadata{ winrt::single_threaded_vector() }; ::AppInstaller::Repository::PackageVersionKey internalVersionKey(winrt::to_string(versionKey.PackageCatalogId()), winrt::to_string(versionKey.Version()), winrt::to_string(versionKey.Channel())); - for (auto const& localization : m_package.get()->GetAvailableVersion(internalVersionKey)->GetManifest().Localizations) + std::shared_ptr<::AppInstaller::Repository::IPackageVersion> availableVersion = m_package.get()->GetAvailableVersion(internalVersionKey); + if (availableVersion) { - locales.Append(winrt::to_hstring(localization.Locale)); + for (auto const& localization : availableVersion->GetManifest().Localizations) + { + auto catalogPackageMetadata = winrt::make_self>(); + catalogPackageMetadata->Initialize(localization); + allCatalogPackageMetadata.Append(*catalogPackageMetadata); + } } - return locales.GetView(); + return allCatalogPackageMetadata.GetView(); } } diff --git a/src/Microsoft.Management.Deployment/CatalogPackage.h b/src/Microsoft.Management.Deployment/CatalogPackage.h index 71afee3801..5fc3643ae7 100644 --- a/src/Microsoft.Management.Deployment/CatalogPackage.h +++ b/src/Microsoft.Management.Deployment/CatalogPackage.h @@ -2,7 +2,7 @@ // Licensed under the MIT License. #pragma once #include "CatalogPackage.g.h" -#include "PackageLocale.h" +#include "CatalogPackageMetadata.h" namespace winrt::Microsoft::Management::Deployment::implementation { @@ -31,10 +31,9 @@ namespace winrt::Microsoft::Management::Deployment::implementation winrt::Microsoft::Management::Deployment::InstalledStatusType checkTypes); winrt::Windows::Foundation::IAsyncOperation CheckInstalledStatusAsync(); winrt::Microsoft::Management::Deployment::CheckInstalledStatusResult CheckInstalledStatus(); - // Contract 7.0 - winrt::Microsoft::Management::Deployment::PackageLocale GetDefaultLocale(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey); - winrt::Microsoft::Management::Deployment::PackageLocale GetLocale(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey, hstring locale); - winrt::Windows::Foundation::Collections::IVectorView AvailableLocales(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey); + // Contract 6.0 + winrt::Microsoft::Management::Deployment::CatalogPackageMetadata GetCatalogPackageMetadata(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey, const hstring& locale); + winrt::Windows::Foundation::Collections::IVectorView GetAllCatalogPackageMetadata(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey); #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) private: diff --git a/src/Microsoft.Management.Deployment/CatalogPackageMetadata.cpp b/src/Microsoft.Management.Deployment/CatalogPackageMetadata.cpp new file mode 100644 index 0000000000..84b6376b3d --- /dev/null +++ b/src/Microsoft.Management.Deployment/CatalogPackageMetadata.cpp @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#include +#include "CatalogPackageMetadata.h" +#include "CatalogPackageMetadata.g.cpp" +#include "Documentation.h" +#include + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + using Localization = ::AppInstaller::Manifest::Localization; + + void CatalogPackageMetadata::Initialize(::AppInstaller::Manifest::ManifestLocalization manifestLocalization) + { + m_manifestLocalization = manifestLocalization; + } + + hstring CatalogPackageMetadata::Locale() + { + return winrt::to_hstring(m_manifestLocalization.Locale); + } + hstring CatalogPackageMetadata::Publisher() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::PublisherUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::PublisherSupportUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::PrivacyUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::Author() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::PackageName() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::PackageUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::License() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::LicenseUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::Copyright() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::CopyrightUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::ShortDescription() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::Description() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::ReleaseNotes() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::ReleaseNotesUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + hstring CatalogPackageMetadata::InstallationNotes() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } + winrt::Windows::Foundation::Collections::IVectorView CatalogPackageMetadata::Agreements() + { + if (!m_packageAgreements) + { + auto agreements = winrt::single_threaded_vector(); + for (auto const& agreement : m_manifestLocalization.Get()) + { + auto packageAgreement = winrt::make_self>(); + packageAgreement->Initialize(agreement); + agreements.Append(*packageAgreement); + } + m_packageAgreements = agreements; + } + + return m_packageAgreements.GetView(); + } + winrt::Windows::Foundation::Collections::IVectorView CatalogPackageMetadata::Tags() + { + if (!m_tags) + { + // Vector hasn't been created yet, create and populate it. + auto tags = winrt::single_threaded_vector(); + for (auto&& tag : m_manifestLocalization.Get()) + { + tags.Append(winrt::to_hstring(tag)); + } + m_tags = tags; + } + + return m_tags.GetView(); + } + winrt::Windows::Foundation::Collections::IVectorView CatalogPackageMetadata::Documentations() + { + if (!m_documentations) + { + auto documentations = winrt::single_threaded_vector(); + for (auto const& documentation : m_manifestLocalization.Get()) + { + auto documentationImpl = winrt::make_self>(); + documentationImpl->Initialize(documentation); + documentations.Append(*documentationImpl); + } + m_documentations = documentations; + } + + return m_documentations.GetView(); + } +} diff --git a/src/Microsoft.Management.Deployment/PackageLocale.h b/src/Microsoft.Management.Deployment/CatalogPackageMetadata.h similarity index 81% rename from src/Microsoft.Management.Deployment/PackageLocale.h rename to src/Microsoft.Management.Deployment/CatalogPackageMetadata.h index 29632e40b4..aa2e4ca2a4 100644 --- a/src/Microsoft.Management.Deployment/PackageLocale.h +++ b/src/Microsoft.Management.Deployment/CatalogPackageMetadata.h @@ -1,21 +1,25 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. #pragma once -#include "PackageLocale.g.h" +#include "CatalogPackageMetadata.g.h" #include "PackageAgreement.h" #include "Documentation.h" namespace winrt::Microsoft::Management::Deployment::implementation { - struct PackageLocale : PackageLocaleT + struct CatalogPackageMetadata : CatalogPackageMetadataT { - PackageLocale() = default; + CatalogPackageMetadata() = default; #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) void Initialize(::AppInstaller::Manifest::ManifestLocalization manifestLocalization); #endif + hstring Locale(); + hstring Publisher(); + hstring PublisherUrl(); + hstring PublisherSupportUrl(); hstring PrivacyUrl(); @@ -53,8 +57,8 @@ namespace winrt::Microsoft::Management::Deployment::implementation #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) private: ::AppInstaller::Manifest::ManifestLocalization m_manifestLocalization; - Windows::Foundation::Collections::IVector m_packageAgreements{ winrt::single_threaded_vector() }; - Windows::Foundation::Collections::IVector m_documentations{ winrt::single_threaded_vector() }; + Windows::Foundation::Collections::IVector m_packageAgreements{ nullptr }; + Windows::Foundation::Collections::IVector m_documentations{ nullptr }; Windows::Foundation::Collections::IVector m_tags{ nullptr }; #endif }; diff --git a/src/Microsoft.Management.Deployment/InstallOptions.h b/src/Microsoft.Management.Deployment/InstallOptions.h index 9802e7931b..cdf1b09a34 100644 --- a/src/Microsoft.Management.Deployment/InstallOptions.h +++ b/src/Microsoft.Management.Deployment/InstallOptions.h @@ -57,7 +57,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation winrt::single_threaded_vector() }; bool m_allowUpgradeToUnknownVersion = false; bool m_force = false; - bool m_acceptPackageAgreements = false; + bool m_acceptPackageAgreements = true; #endif }; } diff --git a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj index 925edc5923..2b420eb51e 100644 --- a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj +++ b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj @@ -156,7 +156,7 @@ - + @@ -190,7 +190,7 @@ - + diff --git a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters index 99cbbccf14..8a8fa02a86 100644 --- a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters +++ b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters @@ -17,7 +17,7 @@ - + @@ -51,7 +51,7 @@ - + diff --git a/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.h b/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.h index 1e60f5b87d..782833ff50 100644 --- a/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.h +++ b/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.h @@ -16,7 +16,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) private: - bool m_acceptSourceAgreements = false; + bool m_acceptSourceAgreements = true; #endif }; } diff --git a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp index e2267e7ed4..0b26b1107a 100644 --- a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp +++ b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp @@ -39,6 +39,10 @@ namespace winrt::Microsoft::Management::Deployment::implementation { co_return Connect(); } + winrt::Windows::Foundation::IAsyncOperation PackageCatalogReference::ConnectAsync(winrt::Microsoft::Management::Deployment::PackageCatalogConnectOptions options) + { + co_return Connect(options); + } winrt::Microsoft::Management::Deployment::ConnectResult GetConnectCatalogErrorResult() { auto connectResult = winrt::make_self>(); @@ -46,6 +50,10 @@ namespace winrt::Microsoft::Management::Deployment::implementation return *connectResult; } winrt::Microsoft::Management::Deployment::ConnectResult PackageCatalogReference::Connect() + { + return Connect(NULL); + } + winrt::Microsoft::Management::Deployment::ConnectResult PackageCatalogReference::Connect(winrt::Microsoft::Management::Deployment::PackageCatalogConnectOptions options) { try { @@ -66,7 +74,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation auto catalog = m_compositePackageCatalogOptions.Catalogs().GetAt(i); winrt::Microsoft::Management::Deployment::implementation::PackageCatalogReference* catalogImpl = get_self(catalog); auto copy = catalogImpl->m_sourceReference; - copy.Open(progress); remoteSources.emplace_back(std::move(copy)); } @@ -104,9 +111,14 @@ namespace winrt::Microsoft::Management::Deployment::implementation source.Open(progress); } - if (!source) + if (options && options.AcceptSourceAgreements()) + { + source.SaveAcceptedSourceAgreements(); + } + + // Check that source agreements have been accepted before proceeding. + if (!source.CheckSourceAgreements()) { - // If source is null, return the error. There's no way to get the hresult that caused the error right now. return GetConnectCatalogErrorResult(); } @@ -125,7 +137,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation } return GetConnectCatalogErrorResult(); } - winrt::Windows::Foundation::Collections::IVectorView PackageCatalogReference::SourceAgreements() { for (auto const& agreement : m_sourceReference.GetInformation().SourceAgreements) @@ -137,7 +148,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation return m_sourceAgreements.GetView(); } - hstring PackageCatalogReference::AdditionalPackageCatalogArguments() { if (!IsComposite()) diff --git a/src/Microsoft.Management.Deployment/PackageCatalogReference.h b/src/Microsoft.Management.Deployment/PackageCatalogReference.h index 1ddac4a1fc..fd085a073d 100644 --- a/src/Microsoft.Management.Deployment/PackageCatalogReference.h +++ b/src/Microsoft.Management.Deployment/PackageCatalogReference.h @@ -22,6 +22,9 @@ namespace winrt::Microsoft::Management::Deployment::implementation winrt::Windows::Foundation::Collections::IVectorView SourceAgreements(); hstring AdditionalPackageCatalogArguments(); void AdditionalPackageCatalogArguments(hstring const& value); + // Contract 6.0 + winrt::Windows::Foundation::IAsyncOperation ConnectAsync(PackageCatalogConnectOptions options); + winrt::Microsoft::Management::Deployment::ConnectResult Connect(PackageCatalogConnectOptions options); #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) private: diff --git a/src/Microsoft.Management.Deployment/PackageLocale.cpp b/src/Microsoft.Management.Deployment/PackageLocale.cpp deleted file mode 100644 index 93fa1389d6..0000000000 --- a/src/Microsoft.Management.Deployment/PackageLocale.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -#include "pch.h" -#include -#include "PackageLocale.h" -#include "PackageLocale.g.cpp" -#include "Documentation.h" -#include - -namespace winrt::Microsoft::Management::Deployment::implementation -{ - using Localization = ::AppInstaller::Manifest::Localization; - - void PackageLocale::Initialize(::AppInstaller::Manifest::ManifestLocalization manifestLocalization) - { - m_manifestLocalization = manifestLocalization; - } - - hstring PackageLocale::Publisher() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::PublisherSupportUrl() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::PrivacyUrl() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::Author() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::PackageName() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::PackageUrl() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::License() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::LicenseUrl() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::Copyright() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::CopyrightUrl() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::ShortDescription() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::Description() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::ReleaseNotes() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::ReleaseNotesUrl() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - hstring PackageLocale::InstallationNotes() - { - return winrt::to_hstring(m_manifestLocalization.Get()); - } - winrt::Windows::Foundation::Collections::IVectorView PackageLocale::Agreements() - { - for (auto const& agreement : m_manifestLocalization.Get()) - { - auto packageAgreement = winrt::make_self>(); - packageAgreement->Initialize(agreement); - m_packageAgreements.Append(*packageAgreement); - } - - return m_packageAgreements.GetView(); - } - winrt::Windows::Foundation::Collections::IVectorView PackageLocale::Tags() - { - if (!m_tags) - { - // Vector hasn't been created yet, create and populate it. - auto tags = winrt::single_threaded_vector(); - for (auto&& tag : m_manifestLocalization.Get()) - { - tags.Append(winrt::to_hstring(tag)); - } - m_tags = tags; - } - return m_tags.GetView(); - } - winrt::Windows::Foundation::Collections::IVectorView PackageLocale::Documentations() - { - for (auto const& documentation : m_manifestLocalization.Get()) - { - auto documentationImpl = winrt::make_self>(); - documentationImpl->Initialize(documentation); - m_documentations.Append(*documentationImpl); - } - - return m_documentations.GetView(); - } -} diff --git a/src/Microsoft.Management.Deployment/PackageManager.cpp b/src/Microsoft.Management.Deployment/PackageManager.cpp index d7331b6bba..d251f4344c 100644 --- a/src/Microsoft.Management.Deployment/PackageManager.cpp +++ b/src/Microsoft.Management.Deployment/PackageManager.cpp @@ -528,6 +528,11 @@ namespace winrt::Microsoft::Management::Deployment::implementation Microsoft::Management::Deployment::PackageVersionInfo packageVersionInfo = GetPackageVersionInfo(package, options); AddPackageManifestToContext(packageVersionInfo, comContext.get()); + if (options.AcceptPackageAgreements()) + { + comContext->SetFlags(AppInstaller::CLI::Execution::ContextFlag::AgreementsAcceptedByCaller); + } + if (isUpgrade) { AppInstaller::Utility::VersionAndChannel installedVersion{ winrt::to_string(package.InstalledVersion().Version()), winrt::to_string(package.InstalledVersion().Channel()) }; @@ -547,14 +552,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation THROW_HR(APPINSTALLER_CLI_ERROR_UPGRADE_VERSION_NOT_NEWER); } - // TODO: Replace the line below with the commented block once we have determined if we need to verify whether package agreements have been accepted. - //if (options.AcceptPackageAgreements()) - //{ - // comContext->SetFlags(AppInstaller::CLI::Execution::ContextFlag::AgreementsAcceptedByCaller); - //} - - comContext->SetFlags(AppInstaller::CLI::Execution::ContextFlag::AgreementsAcceptedByCaller); - // Set upgrade flag comContext->SetFlags(AppInstaller::CLI::Execution::ContextFlag::InstallerExecutionUseUpdate); // Add installed version diff --git a/src/Microsoft.Management.Deployment/PackageManager.idl b/src/Microsoft.Management.Deployment/PackageManager.idl index 9524146a14..c8d6f954fb 100644 --- a/src/Microsoft.Management.Deployment/PackageManager.idl +++ b/src/Microsoft.Management.Deployment/PackageManager.idl @@ -462,11 +462,9 @@ namespace Microsoft.Management.Deployment [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] { - PackageLocale GetDefaultLocale(PackageVersionId versionKey); + CatalogPackageMetadata GetCatalogPackageMetadata(PackageVersionId versionKey, String locale); - PackageLocale GetLocale(PackageVersionId versionKey, String locale); - - Windows.Foundation.Collections.IVectorView AvailableLocales(PackageVersionId versionKey); + Windows.Foundation.Collections.IVectorView GetAllCatalogPackageMetadata(PackageVersionId versionKey); } } @@ -657,6 +655,9 @@ namespace Microsoft.Management.Deployment { /// Gets the required agreements for connecting to the package catalog (source). Windows.Foundation.Collections.IVectorView SourceAgreements{ get; }; + + Windows.Foundation.IAsyncOperation ConnectAsync(PackageCatalogConnectOptions packageCatalogConnectOptions); + ConnectResult Connect(PackageCatalogConnectOptions packageCatalogConnectOptions); } } @@ -888,10 +889,14 @@ namespace Microsoft.Management.Deployment /// IMPLEMENTATION NOTE: SourceOrigin from AppInstaller::Manifest::Localization [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] - runtimeclass PackageLocale + runtimeclass CatalogPackageMetadata { + String Locale { get; }; + String Publisher { get; }; + String PublisherUrl { get; }; + String PublisherSupportUrl { get; }; String PrivacyUrl{ get; }; @@ -1041,5 +1046,7 @@ namespace Microsoft.Management.Deployment interface Windows.Foundation.Collections.IVectorView; interface Windows.Foundation.Collections.IVector; interface Windows.Foundation.Collections.IVectorView; + interface Windows.Foundation.Collections.IVector; + interface Windows.Foundation.Collections.IVectorView; } } From 7676cfc2d41b37434c10a754634b3f83e5dca94d Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Fri, 27 Jan 2023 18:15:24 -0800 Subject: [PATCH 05/17] fix comment spacing --- src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs index b8b6b80b8e..597b910ee7 100644 --- a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs @@ -36,8 +36,7 @@ public FindPackagesInterop(IInstanceInitializer initializer) public void SetUp() { this.packageManager = this.TestFactory.CreatePackageManager(); - //this.testSource = this.packageManager.GetPackageCatalogByName(Constants.TestSourceName); - this.testSource = this.packageManager.GetPackageCatalogByName("msstore"); + this.testSource = this.packageManager.GetPackageCatalogByName(Constants.TestSourceName); } /// From 8f019d5b417596c478c0fdbc39700957a44d535b Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Mon, 30 Jan 2023 10:20:38 -0800 Subject: [PATCH 06/17] fix missing line --- src/AppInstallerCLICore/Workflows/PromptFlow.cpp | 2 +- src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj | 2 +- .../Microsoft.Management.Deployment.InProc.dll.manifest | 2 +- src/Microsoft.Management.Deployment/PackageCatalogReference.cpp | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/PromptFlow.cpp b/src/AppInstallerCLICore/Workflows/PromptFlow.cpp index 09f6aa80c7..8ce6c9cb40 100644 --- a/src/AppInstallerCLICore/Workflows/PromptFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/PromptFlow.cpp @@ -78,7 +78,7 @@ namespace AppInstaller::CLI::Workflow } // Show message for each individual implicit agreement field - auto fields = source.GetAgreementFieldsFromSourceInformation(); + auto fields = source.GetAgreementFieldsFromSourceInformation(); if (WI_IsFlagSet(fields, Repository::ImplicitAgreementFieldEnum::Market)) { context.Reporter.Info() << Resource::String::SourceAgreementsMarketMessage << std::endl; diff --git a/src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj b/src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj index 5dca17ff68..e2288ba35e 100644 --- a/src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj +++ b/src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj @@ -45,7 +45,7 @@ PreserveNewest - + PreserveNewest diff --git a/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest b/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest index 089d50ac57..d8f58a73e9 100644 --- a/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest +++ b/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest @@ -30,7 +30,7 @@ + description="PackageCatalogConnectOptions"/> (catalog); auto copy = catalogImpl->m_sourceReference; + copy.Open(progress); remoteSources.emplace_back(std::move(copy)); } From d8c8b9d37753c7fd897361072c140d9dec89cfb5 Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Mon, 30 Jan 2023 13:37:24 -0800 Subject: [PATCH 07/17] fix source agreements check --- .../Interop/InstallInterop.cs | 4 ++++ .../TestExeInstaller_MultipleLocale.yaml | 2 +- .../PackageCatalogReference.cpp | 19 ++++++++++--------- .../PackageManager.cpp | 14 +++++++++----- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs index 6cd07d9e10..1e5aca26d9 100644 --- a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs @@ -58,6 +58,7 @@ public async Task InstallExe() var installOptions = this.TestFactory.CreateInstallOptions(); installOptions.PackageInstallMode = PackageInstallMode.Silent; installOptions.PreferredInstallLocation = this.installDir; + installOptions.AcceptPackageAgreements = true; // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); @@ -535,6 +536,9 @@ public async Task InstallWithAgreementsAccepted() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); + + // Assert + Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); } } } \ No newline at end of file diff --git a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml index d0ce94223e..09c40c01d4 100644 --- a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml +++ b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml @@ -42,7 +42,7 @@ Localization: AgreementUrl: https://localeAgreementUrl.net Documentations: - DocumentLabel: localeDocumentLabel - DocumentUrl: https://localeDocumentLabel.com + DocumentUrl: https://localeDocumentUrl.com Tags: - tag1 - tag2 diff --git a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp index a039083463..b6eb0a56b2 100644 --- a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp +++ b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp @@ -110,17 +110,18 @@ namespace winrt::Microsoft::Management::Deployment::implementation { source = m_sourceReference; source.Open(progress); - } - if (options && options.AcceptSourceAgreements()) - { - source.SaveAcceptedSourceAgreements(); - } + // Check agreements for non-composite source. + if (options && options.AcceptSourceAgreements()) + { + source.SaveAcceptedSourceAgreements(); + } - // Check that source agreements have been accepted before proceeding. - if (!source.CheckSourceAgreements()) - { - return GetConnectCatalogErrorResult(); + // Check that source agreements have been accepted before proceeding. + if (!source.CheckSourceAgreements()) + { + return GetConnectCatalogErrorResult(); + } } // Have to make another package catalog info because source->GetDetails has more fields than m_info does. diff --git a/src/Microsoft.Management.Deployment/PackageManager.cpp b/src/Microsoft.Management.Deployment/PackageManager.cpp index d251f4344c..d5707695f3 100644 --- a/src/Microsoft.Management.Deployment/PackageManager.cpp +++ b/src/Microsoft.Management.Deployment/PackageManager.cpp @@ -401,6 +401,11 @@ namespace winrt::Microsoft::Management::Deployment::implementation } // Note: AdditionalPackageCatalogArguments is not needed during install since the manifest is already known so no additional calls to the source are needed. The property is deprecated. + + if (options.AcceptPackageAgreements()) + { + context->Args.AddArg(Execution::Args::Type::AcceptPackageAgreements); + } } } @@ -528,11 +533,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation Microsoft::Management::Deployment::PackageVersionInfo packageVersionInfo = GetPackageVersionInfo(package, options); AddPackageManifestToContext(packageVersionInfo, comContext.get()); - if (options.AcceptPackageAgreements()) - { - comContext->SetFlags(AppInstaller::CLI::Execution::ContextFlag::AgreementsAcceptedByCaller); - } - if (isUpgrade) { AppInstaller::Utility::VersionAndChannel installedVersion{ winrt::to_string(package.InstalledVersion().Version()), winrt::to_string(package.InstalledVersion().Channel()) }; @@ -567,6 +567,10 @@ namespace winrt::Microsoft::Management::Deployment::implementation { // Add installed version AddInstalledVersionToContext(package.InstalledVersion(), comContext.get()); + + // Uninstall should not require agreements acceptance. + comContext->SetFlags(AppInstaller::CLI::Execution::ContextFlag::AgreementsAcceptedByCaller); + // Add Package which is used by RecordUninstall later for removing from tracking catalog of correlated available sources as best effort winrt::Microsoft::Management::Deployment::implementation::CatalogPackage* catalogPackageImpl = get_self(package); std::shared_ptr<::AppInstaller::Repository::IPackage> internalPackage = catalogPackageImpl->GetRepositoryPackage(); From 876023f5e2e1e178a2df72c2d53f33dae630e2a7 Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Mon, 30 Jan 2023 14:42:17 -0800 Subject: [PATCH 08/17] fix clsid --- src/Microsoft.Management.Deployment/Public/ComClsids.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Management.Deployment/Public/ComClsids.h b/src/Microsoft.Management.Deployment/Public/ComClsids.h index 12055244a7..64e016712c 100644 --- a/src/Microsoft.Management.Deployment/Public/ComClsids.h +++ b/src/Microsoft.Management.Deployment/Public/ComClsids.h @@ -11,7 +11,7 @@ #define WINGET_OUTOFPROC_COM_CLSID_InstallOptions "1095F097-EB96-453B-B4E6-1613637F3B14" #define WINGET_OUTOFPROC_COM_CLSID_UninstallOptions "E1D9A11E-9F85-4D87-9C17-2B93143ADB8D" #define WINGET_OUTOFPROC_COM_CLSID_PackageMatchFilter "D02C9DAF-99DC-429C-B503-4E504E4AB000" -#define WINGET_OUTOFPROC_COM_CLSID_ConnectOptions "B5033698-79D1-4B94-9C39-0EC4EF1C7853" +#define WINGET_OUTOFPROC_COM_CLSID_PackageCatalogConnectOptions "B5033698-79D1-4B94-9C39-0EC4EF1C7853" #else #define WINGET_OUTOFPROC_COM_CLSID_PackageManager "74CB3139-B7C5-4B9E-9388-E6616DEA288C" #define WINGET_OUTOFPROC_COM_CLSID_FindPackagesOptions "1BD8FF3A-EC50-4F69-AEEE-DF4C9D3BAA96" From a201ecf215c13b01eede61e8ea7fbccd18c9740a Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Tue, 31 Jan 2023 10:17:53 -0800 Subject: [PATCH 09/17] restore pipeline --- azure-pipelines.yml | 98 +++++++++---------- .../Interop/BaseInterop.cs | 1 + .../Interop/InstallInterop.cs | 8 +- .../ClassesDefinition.cs | 24 ++--- .../PackageCatalogReference.cpp | 17 +--- 5 files changed, 71 insertions(+), 77 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7b23ebacc8..ec5edba4d8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -146,28 +146,28 @@ jobs: inputs: secureFile: 'PsExec.exe' - # - task: CmdLine@2 - # displayName: Run Unit Tests Unpackaged Under System Context - # inputs: - # script: | - # $(PsExec.secureFilePath) -accepteula -s -i $(buildOutDir)\AppInstallerCLITests\AppInstallerCLITests.exe -logto $(artifactsDir)\AICLI-Unpackaged-System.log -s -r junit -o $(artifactsDir)\TEST-AppInstallerCLI-Unpackaged-System.xml - # workingDirectory: '$(buildOutDir)\AppInstallerCLITests' - # continueOnError: true - - # - task: PowerShell@2 - # displayName: Run Unit Tests Packaged - # inputs: - # filePath: 'src\AppInstallerCLITests\Run-TestsInPackage.ps1' - # arguments: '-Args "~[pips]" -BuildRoot $(buildOutDir) -PackageRoot AppInstallerCLIPackage\bin\$(buildPlatform)\$(buildConfiguration) -LogTarget $(artifactsDir)\AICLI-Packaged.log -TestResultsTarget $(artifactsDir)\TEST-AppInstallerCLI-Packaged.xml -ScriptWait' - # workingDirectory: 'src' - # continueOnError: true - - # - task: PublishTestResults@2 - # displayName: Publish Unit Test Results - # inputs: - # testResultsFormat: 'JUnit' - # testResultsFiles: '$(artifactsDir)\TEST-*.xml' - # failTaskOnFailedTests: true + - task: CmdLine@2 + displayName: Run Unit Tests Unpackaged Under System Context + inputs: + script: | + $(PsExec.secureFilePath) -accepteula -s -i $(buildOutDir)\AppInstallerCLITests\AppInstallerCLITests.exe -logto $(artifactsDir)\AICLI-Unpackaged-System.log -s -r junit -o $(artifactsDir)\TEST-AppInstallerCLI-Unpackaged-System.xml + workingDirectory: '$(buildOutDir)\AppInstallerCLITests' + continueOnError: true + + - task: PowerShell@2 + displayName: Run Unit Tests Packaged + inputs: + filePath: 'src\AppInstallerCLITests\Run-TestsInPackage.ps1' + arguments: '-Args "~[pips]" -BuildRoot $(buildOutDir) -PackageRoot AppInstallerCLIPackage\bin\$(buildPlatform)\$(buildConfiguration) -LogTarget $(artifactsDir)\AICLI-Packaged.log -TestResultsTarget $(artifactsDir)\TEST-AppInstallerCLI-Packaged.xml -ScriptWait' + workingDirectory: 'src' + continueOnError: true + + - task: PublishTestResults@2 + displayName: Publish Unit Test Results + inputs: + testResultsFormat: 'JUnit' + testResultsFiles: '$(artifactsDir)\TEST-*.xml' + failTaskOnFailedTests: true - task: DownloadSecureFile@1 name: AppInstallerTest @@ -248,11 +248,11 @@ jobs: TargetFolder: 'src\AppInstallerCLIPackage\bin\$(buildPlatform)\$(buildConfiguration)' Contents: Microsoft.Management.Deployment.winmd - # - template: templates/e2e-test.template.yml - # parameters: - # title: "E2E Tests Packaged" - # isPackaged: true - # filter: "TestCategory!=InProcess&TestCategory!=OutOfProcess" + - template: templates/e2e-test.template.yml + parameters: + title: "E2E Tests Packaged" + isPackaged: true + filter: "TestCategory!=InProcess&TestCategory!=OutOfProcess" - template: templates/e2e-test.template.yml parameters: @@ -313,28 +313,28 @@ jobs: targetPath: '$(artifactsDir)' condition: always() - # - task: ComponentGovernanceComponentDetection@0 - # displayName: Component Governance - # inputs: - # scanType: 'Register' - # verbosity: 'Verbose' - # alertWarningLevel: 'High' - - # # Run BimSkim for all the binaries - # - task: BinSkim@3 - # displayName: 'Run BinSkim ' - # inputs: - # arguments: 'analyze - # "$(buildOutDir)\AppInstallerCLI\winget.exe" - # "$(buildOutDir)\WinGetUtil\WinGetUtil.dll" - # "$(buildOutDir)\WindowsPackageManager\WindowsPackageManager.dll" - # "$(buildOutDir)\Microsoft.Management.Deployment.InProc\Microsoft.Management.Deployment.InProc.dll" - # "$(Build.SourcesDirectory)\src\WinGetUtilInterop\bin\WinGetUtil*Interop.dll" - # "$(buildOutDir)\UndockedRegFreeWinRT\winrtact.dll" - # "$(buildOutDir)\Microsoft.WinGet.Client\Microsoft.WinGet.*Client.dll" --config default --recurse' - - # - task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2 - # displayName: 'Publish Security Analysis Logs' + - task: ComponentGovernanceComponentDetection@0 + displayName: Component Governance + inputs: + scanType: 'Register' + verbosity: 'Verbose' + alertWarningLevel: 'High' + + # Run BimSkim for all the binaries + - task: BinSkim@3 + displayName: 'Run BinSkim ' + inputs: + arguments: 'analyze + "$(buildOutDir)\AppInstallerCLI\winget.exe" + "$(buildOutDir)\WinGetUtil\WinGetUtil.dll" + "$(buildOutDir)\WindowsPackageManager\WindowsPackageManager.dll" + "$(buildOutDir)\Microsoft.Management.Deployment.InProc\Microsoft.Management.Deployment.InProc.dll" + "$(Build.SourcesDirectory)\src\WinGetUtilInterop\bin\WinGetUtil*Interop.dll" + "$(buildOutDir)\UndockedRegFreeWinRT\winrtact.dll" + "$(buildOutDir)\Microsoft.WinGet.Client\Microsoft.WinGet.*Client.dll" --config default --recurse' + + - task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2 + displayName: 'Publish Security Analysis Logs' - job: 'BuildPowerShellModule' timeoutInMinutes: 120 diff --git a/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs b/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs index 66f20fa788..fe662e1aaa 100644 --- a/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs @@ -79,6 +79,7 @@ protected IReadOnlyList FindAllPackages( // Connect and find package var packageCatalogConnectOptions = this.TestFactory.CreatePackageCatalogConnectOptions(); var source = packageCatalogReference.Connect(packageCatalogConnectOptions).PackageCatalog; + return source.FindPackages(findPackageOptions).Matches; } } diff --git a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs index 1e5aca26d9..1626d109f4 100644 --- a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs @@ -519,11 +519,11 @@ public async Task InstallRequireUserScopeAndUnknown() } /// - /// Test installing package with agreements and accepting those agreements. + /// Test installing package with agreements and not accepting those agreements. /// /// A representing the asynchronous unit test. [Test] - public async Task InstallWithAgreementsAccepted() + public async Task InstallWithAgreementsNotAccepted() { // Find package var searchResult = this.FindOnePackage(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.TestExeInstaller"); @@ -532,13 +532,13 @@ public async Task InstallWithAgreementsAccepted() var installOptions = this.TestFactory.CreateInstallOptions(); installOptions.PackageInstallMode = PackageInstallMode.Silent; installOptions.PreferredInstallLocation = this.installDir; - installOptions.AcceptPackageAgreements = true; + installOptions.AcceptPackageAgreements = false; // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.AreEqual(InstallResultStatus.CatalogError, installResult.Status); } } } \ No newline at end of file diff --git a/src/Microsoft.Management.Deployment.Projection/ClassesDefinition.cs b/src/Microsoft.Management.Deployment.Projection/ClassesDefinition.cs index a39f0f2088..a1faaa7218 100644 --- a/src/Microsoft.Management.Deployment.Projection/ClassesDefinition.cs +++ b/src/Microsoft.Management.Deployment.Projection/ClassesDefinition.cs @@ -44,18 +44,6 @@ internal static class ClassesDefinition [ClsidContext.OutOfProc] = new Guid("526534B8-7E46-47C8-8416-B1685C327D37"), [ClsidContext.OutOfProcDev] = new Guid("EE160901-B317-4EA7-9CC6-5355C6D7D8A7"), } - }, - - [typeof(PackageCatalogConnectOptions)] = new() - { - ProjectedClassType = typeof(PackageCatalogConnectOptions), - InterfaceType = typeof(IPackageCatalogConnectOptions), - Clsids = new Dictionary() - { - [ClsidContext.InProc] = new Guid("D026FDDC-44D3-443A-8DAB-A4DD969943B3"), - [ClsidContext.OutOfProc] = new Guid("B5033698-79D1-4B94-9C39-0EC4EF1C7853"), - [ClsidContext.OutOfProcDev] = new Guid("6C4F68AC-F601-42FC-8CAF-87D3B3321783"), - } }, [typeof(InstallOptions)] = new() @@ -92,6 +80,18 @@ internal static class ClassesDefinition [ClsidContext.OutOfProc] = new Guid("D02C9DAF-99DC-429C-B503-4E504E4AB000"), [ClsidContext.OutOfProcDev] = new Guid("3F85B9F4-487A-4C48-9035-2903F8A6D9E8"), } + }, + + [typeof(PackageCatalogConnectOptions)] = new() + { + ProjectedClassType = typeof(PackageCatalogConnectOptions), + InterfaceType = typeof(IPackageCatalogConnectOptions), + Clsids = new Dictionary() + { + [ClsidContext.InProc] = new Guid("D026FDDC-44D3-443A-8DAB-A4DD969943B3"), + [ClsidContext.OutOfProc] = new Guid("B5033698-79D1-4B94-9C39-0EC4EF1C7853"), + [ClsidContext.OutOfProcDev] = new Guid("6C4F68AC-F601-42FC-8CAF-87D3B3321783"), + } }, [typeof(PackageManagerSettings)] = new() diff --git a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp index b6eb0a56b2..a29adedadd 100644 --- a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp +++ b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp @@ -63,6 +63,11 @@ namespace winrt::Microsoft::Management::Deployment::implementation return GetConnectCatalogErrorResult(); } + if (options && !options.AcceptSourceAgreements()) + { + return GetConnectCatalogErrorResult(); + } + ::AppInstaller::ProgressCallback progress; ::AppInstaller::Repository::Source source; if (m_compositePackageCatalogOptions) @@ -110,18 +115,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation { source = m_sourceReference; source.Open(progress); - - // Check agreements for non-composite source. - if (options && options.AcceptSourceAgreements()) - { - source.SaveAcceptedSourceAgreements(); - } - - // Check that source agreements have been accepted before proceeding. - if (!source.CheckSourceAgreements()) - { - return GetConnectCatalogErrorResult(); - } } // Have to make another package catalog info because source->GetDetails has more fields than m_info does. From bf835b297b4e3c35169baf6a42d2045912d5a4c5 Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Tue, 31 Jan 2023 10:29:02 -0800 Subject: [PATCH 10/17] revert change --- .../PackageCatalogReference.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp index a29adedadd..9f86fc8c6f 100644 --- a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp +++ b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp @@ -117,6 +117,12 @@ namespace winrt::Microsoft::Management::Deployment::implementation source.Open(progress); } + if (!source) + { + // If source is null, return the error. There's no way to get the hresult that caused the error right now. + return GetConnectCatalogErrorResult(); + } + // Have to make another package catalog info because source->GetDetails has more fields than m_info does. // Specifically, Rest sources do not have the Ids filled in m_info since they only get the id from the rest server after being Opened. auto packageCatalogInfo = winrt::make_self>(); From c7600b35368c328fa50064d12354d19d86cb966a Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Tue, 31 Jan 2023 12:56:51 -0800 Subject: [PATCH 11/17] change name and add purchase url --- .../Interop/BaseInterop.cs | 2 +- .../Interop/FindPackagesInterop.cs | 3 ++ .../Interop/InstallInterop.cs | 2 +- .../TestExeInstaller_MultipleLocale.yaml | 2 + .../CatalogPackageMetadata.cpp | 4 ++ .../CatalogPackageMetadata.h | 2 + .../PackageCatalogReference.cpp | 8 ++-- .../PackageCatalogReference.h | 4 +- .../PackageManager.idl | 48 ++++++++++--------- 9 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs b/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs index fe662e1aaa..1ce4e5748d 100644 --- a/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs @@ -78,7 +78,7 @@ protected IReadOnlyList FindAllPackages( // Connect and find package var packageCatalogConnectOptions = this.TestFactory.CreatePackageCatalogConnectOptions(); - var source = packageCatalogReference.Connect(packageCatalogConnectOptions).PackageCatalog; + var source = packageCatalogReference.ConnectWithOptions(packageCatalogConnectOptions).PackageCatalog; return source.FindPackages(findPackageOptions).Matches; } diff --git a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs index 597b910ee7..27d1496cbd 100644 --- a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs @@ -146,6 +146,9 @@ public void FindPackagesGetCatalogPackageMetadataLocale() Assert.AreEqual("localeLicense", catalogPackageMetadata.License); Assert.AreEqual("localePackageName", catalogPackageMetadata.PackageName); Assert.AreEqual("localePublisher", catalogPackageMetadata.Publisher); + Assert.AreEqual("localeReleaseNotes", catalogPackageMetadata.ReleaseNotes); + Assert.AreEqual("https://localeReleaseNotesUrl.com", catalogPackageMetadata.ReleaseNotesUrl); + Assert.AreEqual("https://localePurchaseUrl.com", catalogPackageMetadata.PurchaseUrl); var tags = catalogPackageMetadata.Tags; Assert.AreEqual(2, tags.Count); diff --git a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs index 1626d109f4..80cd251b29 100644 --- a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs @@ -526,7 +526,7 @@ public async Task InstallRequireUserScopeAndUnknown() public async Task InstallWithAgreementsNotAccepted() { // Find package - var searchResult = this.FindOnePackage(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.TestExeInstaller"); + var searchResult = this.FindOnePackage(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.CatalogPackageMetadata"); // Configure installation var installOptions = this.TestFactory.CreateInstallOptions(); diff --git a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml index 09c40c01d4..13684213d7 100644 --- a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml +++ b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml @@ -35,6 +35,8 @@ Localization: Publisher: localePublisher PublisherSupportUrl: https://localePublisherSupportUrl.com PublisherUrl: https://localePublisherUrl.com + PurchaseUrl: https://localePurchaseUrl.com + ReleaseNotes: localeReleaseNotes ReleaseNotesUrl: https://localeReleaseNotesUrl.com Agreements: - AgreementLabel: localeAgreementLabel diff --git a/src/Microsoft.Management.Deployment/CatalogPackageMetadata.cpp b/src/Microsoft.Management.Deployment/CatalogPackageMetadata.cpp index 84b6376b3d..c3c66a266c 100644 --- a/src/Microsoft.Management.Deployment/CatalogPackageMetadata.cpp +++ b/src/Microsoft.Management.Deployment/CatalogPackageMetadata.cpp @@ -80,6 +80,10 @@ namespace winrt::Microsoft::Management::Deployment::implementation { return winrt::to_hstring(m_manifestLocalization.Get()); } + hstring CatalogPackageMetadata::PurchaseUrl() + { + return winrt::to_hstring(m_manifestLocalization.Get()); + } hstring CatalogPackageMetadata::InstallationNotes() { return winrt::to_hstring(m_manifestLocalization.Get()); diff --git a/src/Microsoft.Management.Deployment/CatalogPackageMetadata.h b/src/Microsoft.Management.Deployment/CatalogPackageMetadata.h index aa2e4ca2a4..52e76cba6d 100644 --- a/src/Microsoft.Management.Deployment/CatalogPackageMetadata.h +++ b/src/Microsoft.Management.Deployment/CatalogPackageMetadata.h @@ -52,6 +52,8 @@ namespace winrt::Microsoft::Management::Deployment::implementation hstring ReleaseNotesUrl(); + hstring PurchaseUrl(); + hstring InstallationNotes(); #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) diff --git a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp index 9f86fc8c6f..9c972dc125 100644 --- a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp +++ b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp @@ -39,9 +39,9 @@ namespace winrt::Microsoft::Management::Deployment::implementation { co_return Connect(); } - winrt::Windows::Foundation::IAsyncOperation PackageCatalogReference::ConnectAsync(winrt::Microsoft::Management::Deployment::PackageCatalogConnectOptions options) + winrt::Windows::Foundation::IAsyncOperation PackageCatalogReference::ConnectWithOptionsAsync(winrt::Microsoft::Management::Deployment::PackageCatalogConnectOptions options) { - co_return Connect(options); + co_return ConnectWithOptions(options); } winrt::Microsoft::Management::Deployment::ConnectResult GetConnectCatalogErrorResult() { @@ -51,9 +51,9 @@ namespace winrt::Microsoft::Management::Deployment::implementation } winrt::Microsoft::Management::Deployment::ConnectResult PackageCatalogReference::Connect() { - return Connect(NULL); + return ConnectWithOptions(NULL); } - winrt::Microsoft::Management::Deployment::ConnectResult PackageCatalogReference::Connect(winrt::Microsoft::Management::Deployment::PackageCatalogConnectOptions options) + winrt::Microsoft::Management::Deployment::ConnectResult PackageCatalogReference::ConnectWithOptions(winrt::Microsoft::Management::Deployment::PackageCatalogConnectOptions options) { try { diff --git a/src/Microsoft.Management.Deployment/PackageCatalogReference.h b/src/Microsoft.Management.Deployment/PackageCatalogReference.h index fd085a073d..f2a5e82b6d 100644 --- a/src/Microsoft.Management.Deployment/PackageCatalogReference.h +++ b/src/Microsoft.Management.Deployment/PackageCatalogReference.h @@ -23,8 +23,8 @@ namespace winrt::Microsoft::Management::Deployment::implementation hstring AdditionalPackageCatalogArguments(); void AdditionalPackageCatalogArguments(hstring const& value); // Contract 6.0 - winrt::Windows::Foundation::IAsyncOperation ConnectAsync(PackageCatalogConnectOptions options); - winrt::Microsoft::Management::Deployment::ConnectResult Connect(PackageCatalogConnectOptions options); + winrt::Windows::Foundation::IAsyncOperation ConnectWithOptionsAsync(PackageCatalogConnectOptions options); + winrt::Microsoft::Management::Deployment::ConnectResult ConnectWithOptions(PackageCatalogConnectOptions options); #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) private: diff --git a/src/Microsoft.Management.Deployment/PackageManager.idl b/src/Microsoft.Management.Deployment/PackageManager.idl index c8d6f954fb..eef9185ed1 100644 --- a/src/Microsoft.Management.Deployment/PackageManager.idl +++ b/src/Microsoft.Management.Deployment/PackageManager.idl @@ -656,8 +656,8 @@ namespace Microsoft.Management.Deployment /// Gets the required agreements for connecting to the package catalog (source). Windows.Foundation.Collections.IVectorView SourceAgreements{ get; }; - Windows.Foundation.IAsyncOperation ConnectAsync(PackageCatalogConnectOptions packageCatalogConnectOptions); - ConnectResult Connect(PackageCatalogConnectOptions packageCatalogConnectOptions); + Windows.Foundation.IAsyncOperation ConnectWithOptionsAsync(PackageCatalogConnectOptions packageCatalogConnectOptions); + ConnectResult ConnectWithOptions(PackageCatalogConnectOptions packageCatalogConnectOptions); } } @@ -862,7 +862,7 @@ namespace Microsoft.Management.Deployment { String DocumentLabel { get; }; - String DocumentUrl{ get; }; + String DocumentUrl { get; }; } /// IMPLEMENTATION NOTE: SourceOrigin from AppInstaller::Repository::SourceAgreement @@ -871,9 +871,9 @@ namespace Microsoft.Management.Deployment { String Label { get; }; - String Text{ get; }; + String Text { get; }; - String Url{ get; }; + String Url { get; }; } /// IMPLEMENTATION NOTE: SourceOrigin from AppInstaller::Manifest::Agreement @@ -882,9 +882,9 @@ namespace Microsoft.Management.Deployment { String Label { get; }; - String Text{ get; }; + String Text { get; }; - String Url{ get; }; + String Url { get; }; } /// IMPLEMENTATION NOTE: SourceOrigin from AppInstaller::Manifest::Localization @@ -899,37 +899,39 @@ namespace Microsoft.Management.Deployment String PublisherSupportUrl { get; }; - String PrivacyUrl{ get; }; + String PrivacyUrl { get; }; - String Author{ get; }; + String Author { get; }; - String PackageName{ get; }; + String PackageName { get; }; - String PackageUrl{ get; }; + String PackageUrl { get; }; - String License{ get; }; + String License { get; }; - String LicenseUrl{ get; }; + String LicenseUrl { get; }; - String Copyright{ get; }; + String Copyright { get; }; - String CopyrightUrl{ get; }; + String CopyrightUrl { get; }; - String ShortDescription{ get; }; + String ShortDescription { get; }; - String Description{ get; }; + String Description { get; }; - Windows.Foundation.Collections.IVectorView Tags{ get; }; + Windows.Foundation.Collections.IVectorView Tags { get; }; - Windows.Foundation.Collections.IVectorView Agreements{ get; }; + Windows.Foundation.Collections.IVectorView Agreements { get; }; - Windows.Foundation.Collections.IVectorView Documentations{ get; }; + Windows.Foundation.Collections.IVectorView Documentations { get; }; - String ReleaseNotes{ get; }; + String ReleaseNotes { get; }; - String ReleaseNotesUrl{ get; }; + String ReleaseNotesUrl { get; }; - String InstallationNotes{ get; }; + String PurchaseUrl { get; }; + + String InstallationNotes { get; }; } [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 1)] From 8e8bd50b623c1e125dc79761eb871c7d6989b948 Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Tue, 31 Jan 2023 14:19:02 -0800 Subject: [PATCH 12/17] add purchase URL --- .../Interop/FindPackagesInterop.cs | 1 + .../Interop/InstallInterop.cs | 23 +++++++++++++++++++ ...stExeInstaller_CatalogPackageMetadata.yaml | 3 ++- .../TestExeInstaller_MultipleLocale.yaml | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs index 27d1496cbd..9065e16397 100644 --- a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs @@ -92,6 +92,7 @@ public void FindPackagesVerifyDefaultLocaleFields() Assert.AreEqual("https://testCopyrightUrl.com", catalogPackageMetadata.CopyrightUrl); Assert.AreEqual("testDescription", catalogPackageMetadata.Description); Assert.AreEqual("testShortDescription", catalogPackageMetadata.ShortDescription); + Assert.AreEqual("https://testPurchaseUrl.com", catalogPackageMetadata.PurchaseUrl); var tags = catalogPackageMetadata.Tags; Assert.AreEqual(2, tags.Count); diff --git a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs index 80cd251b29..497e2ba356 100644 --- a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs @@ -518,6 +518,29 @@ public async Task InstallRequireUserScopeAndUnknown() Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); } + /// + /// Test installing package with agreements and accepting those agreements. + /// + /// A representing the asynchronous unit test. + [Test] + public async Task InstallWithAgreementsAccepted() + { + // Find package + var searchResult = this.FindOnePackage(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.CatalogPackageMetadata"); + + // Configure installation + var installOptions = this.TestFactory.CreateInstallOptions(); + installOptions.PackageInstallMode = PackageInstallMode.Silent; + installOptions.PreferredInstallLocation = this.installDir; + installOptions.AcceptPackageAgreements = true; + + // Install + var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); + + // Assert + Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + } + /// /// Test installing package with agreements and not accepting those agreements. /// diff --git a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_CatalogPackageMetadata.yaml b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_CatalogPackageMetadata.yaml index 63d581eb2d..852250ca30 100644 --- a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_CatalogPackageMetadata.yaml +++ b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_CatalogPackageMetadata.yaml @@ -32,12 +32,13 @@ LicenseUrl: https://testLicenseUrl.com Copyright: testCopyright CopyrightUrl: https://testCopyrightUrl.com Description: testDescription +Moniker: testMoniker +PurchaseUrl: https://testPurchaseUrl.com Tags: - "tag1" - "tag2" ReleaseNotes: testReleaseNotes ReleaseNotesUrl: https://testReleaseNotes.net -PurchaseUrl: https://testPurchaseUrl.com InstallationNotes: testInstallationNotes Documentations: - DocumentLabel: testDocumentLabel diff --git a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml index 13684213d7..37b629c510 100644 --- a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml +++ b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestExeInstaller_MultipleLocale.yaml @@ -35,6 +35,7 @@ Localization: Publisher: localePublisher PublisherSupportUrl: https://localePublisherSupportUrl.com PublisherUrl: https://localePublisherUrl.com + Moniker: localeMoniker PurchaseUrl: https://localePurchaseUrl.com ReleaseNotes: localeReleaseNotes ReleaseNotesUrl: https://localeReleaseNotesUrl.com From 92f5d25dd7e321a598ee3f9c86077a4eb5b06eb2 Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Wed, 1 Feb 2023 09:38:05 -0800 Subject: [PATCH 13/17] address PR comments --- .../Interop/BaseInterop.cs | 3 +- .../Interop/FindPackagesInterop.cs | 22 +++++---- ....Management.Deployment.InProc.dll.manifest | 4 -- .../ClassesDefinition.cs | 12 ----- .../WinGetProjectionFactory.cs | 2 - .../CatalogPackage.cpp | 48 ------------------- .../CatalogPackage.h | 3 -- .../ComClsids.cpp | 5 -- .../Microsoft.Management.Deployment.vcxproj | 2 - ...soft.Management.Deployment.vcxproj.filters | 2 - .../PackageCatalogConnectOptions.cpp | 27 ----------- .../PackageCatalogConnectOptions.h | 31 ------------ .../PackageCatalogReference.cpp | 18 +++---- .../PackageCatalogReference.h | 5 +- .../PackageManager.idl | 33 +++++-------- .../PackageVersionInfo.cpp | 30 ++++++++++++ .../PackageVersionInfo.h | 6 ++- .../Public/ComClsids.h | 3 -- src/WindowsPackageManager/main.cpp | 1 - 19 files changed, 74 insertions(+), 183 deletions(-) delete mode 100644 src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.cpp delete mode 100644 src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.h diff --git a/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs b/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs index 1ce4e5748d..b3633a37d4 100644 --- a/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs @@ -77,8 +77,7 @@ protected IReadOnlyList FindAllPackages( findPackageOptions.Filters.Add(filter); // Connect and find package - var packageCatalogConnectOptions = this.TestFactory.CreatePackageCatalogConnectOptions(); - var source = packageCatalogReference.ConnectWithOptions(packageCatalogConnectOptions).PackageCatalog; + var source = packageCatalogReference.Connect().PackageCatalog; return source.FindPackages(findPackageOptions).Matches; } diff --git a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs index 9065e16397..c10ea8779f 100644 --- a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs @@ -77,7 +77,8 @@ public void FindPackagesVerifyDefaultLocaleFields() var catalogPackage = searchResult[0].CatalogPackage; var packageVersionId = catalogPackage.AvailableVersions[0]; - var catalogPackageMetadata = catalogPackage.GetCatalogPackageMetadata(packageVersionId, string.Empty); + var packageVersionInfo = catalogPackage.GetPackageVersionInfo(packageVersionId); + var catalogPackageMetadata = packageVersionInfo.GetCatalogPackageMetadata(); Assert.AreEqual("testAuthor", catalogPackageMetadata.Author); Assert.AreEqual("AppInstallerTest", catalogPackageMetadata.Publisher); @@ -127,7 +128,8 @@ public void FindPackagesInvalidLocale() var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.CatalogPackageMetadata"); var catalogPackage = searchResult[0].CatalogPackage; var packageVersionId = catalogPackage.AvailableVersions[0]; - Assert.Throws(() => searchResult[0].CatalogPackage.GetCatalogPackageMetadata(packageVersionId, "badLocale")); + var packageVersionInfo = catalogPackage.GetPackageVersionInfo(packageVersionId); + Assert.Throws(() => packageVersionInfo.GetCatalogPackageMetadata("badLocale")); } /// @@ -141,7 +143,8 @@ public void FindPackagesGetCatalogPackageMetadataLocale() var catalogPackage = searchResult[0].CatalogPackage; var packageVersionId = catalogPackage.AvailableVersions[0]; - var catalogPackageMetadata = catalogPackage.GetCatalogPackageMetadata(packageVersionId, "zh-CN"); + var packageVersionInfo = catalogPackage.GetPackageVersionInfo(packageVersionId); + var catalogPackageMetadata = packageVersionInfo.GetCatalogPackageMetadata("zh-CN"); Assert.AreEqual("zh-CN", catalogPackageMetadata.Locale); Assert.AreEqual("localeLicense", catalogPackageMetadata.License); @@ -183,11 +186,14 @@ public void FindPackagesGetAllCatalogPackageMetadata() var catalogPackage = searchResult[0].CatalogPackage; var packageVersionId = catalogPackage.AvailableVersions[0]; - var allCatalogPackageMetadata = catalogPackage.GetAllCatalogPackageMetadata(packageVersionId); - - Assert.AreEqual(2, allCatalogPackageMetadata.Count); - Assert.AreEqual("zh-CN", allCatalogPackageMetadata[0].Locale); - Assert.AreEqual("en-GB", allCatalogPackageMetadata[1].Locale); + var packageVersionInfo = catalogPackage.GetPackageVersionInfo(packageVersionId); + + var catalogPackageMetadata1 = packageVersionInfo.GetCatalogPackageMetadata("zh-CN"); + Assert.AreEqual("zh-CN", catalogPackageMetadata1.Locale); + + var catalogPackageMetadata2 = packageVersionInfo.GetCatalogPackageMetadata("en-GB"); + Assert.AreEqual("en-GB", catalogPackageMetadata2.Locale); + Assert.AreEqual("packageNameUK", catalogPackageMetadata2.PackageName); } } } \ No newline at end of file diff --git a/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest b/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest index d8f58a73e9..0ed258d962 100644 --- a/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest +++ b/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest @@ -27,10 +27,6 @@ clsid="{869CB959-EB54-425C-A1E4-1A1C291C64E9}" threadingModel="Both" description="UninstallOptions"/> - () - { - [ClsidContext.InProc] = new Guid("D026FDDC-44D3-443A-8DAB-A4DD969943B3"), - [ClsidContext.OutOfProc] = new Guid("B5033698-79D1-4B94-9C39-0EC4EF1C7853"), - [ClsidContext.OutOfProcDev] = new Guid("6C4F68AC-F601-42FC-8CAF-87D3B3321783"), - } - }, - [typeof(PackageManagerSettings)] = new() { ProjectedClassType = typeof(PackageManagerSettings), diff --git a/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs b/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs index 782427f07b..9d846510a7 100644 --- a/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs +++ b/src/Microsoft.Management.Deployment.Projection/WinGetProjectionFactory.cs @@ -23,8 +23,6 @@ public WinGetProjectionFactory(IInstanceInitializer instanceInitializer) public CreateCompositePackageCatalogOptions CreateCreateCompositePackageCatalogOptions() => InstanceInitializer.CreateInstance(); - public PackageCatalogConnectOptions CreatePackageCatalogConnectOptions() => InstanceInitializer.CreateInstance(); - public InstallOptions CreateInstallOptions() => InstanceInitializer.CreateInstance(); public UninstallOptions CreateUninstallOptions() => InstanceInitializer.CreateInstance(); diff --git a/src/Microsoft.Management.Deployment/CatalogPackage.cpp b/src/Microsoft.Management.Deployment/CatalogPackage.cpp index f4fba10dee..1c7c465253 100644 --- a/src/Microsoft.Management.Deployment/CatalogPackage.cpp +++ b/src/Microsoft.Management.Deployment/CatalogPackage.cpp @@ -149,52 +149,4 @@ namespace winrt::Microsoft::Management::Deployment::implementation { return m_package; } - Microsoft::Management::Deployment::CatalogPackageMetadata CatalogPackage::GetCatalogPackageMetadata(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey, const hstring& locale) - { - std::string localeString = winrt::to_string(locale); - - ::AppInstaller::Repository::PackageVersionKey internalVersionKey(winrt::to_string(versionKey.PackageCatalogId()), winrt::to_string(versionKey.Version()), winrt::to_string(versionKey.Channel())); - auto catalogPackageMetadata = winrt::make_self>(); - - std::shared_ptr<::AppInstaller::Repository::IPackageVersion> availableVersion = m_package.get()->GetAvailableVersion(internalVersionKey); - if (availableVersion) - { - auto manifest = availableVersion->GetManifest(); - - if (localeString.empty()) - { - catalogPackageMetadata->Initialize(manifest.DefaultLocalization); - } - else - { - if (!::AppInstaller::Locale::IsWellFormedBcp47Tag(localeString)) - { - throw hresult_invalid_argument(); - } - - manifest.ApplyLocale(localeString); - catalogPackageMetadata->Initialize(manifest.CurrentLocalization); - } - } - - return *catalogPackageMetadata; - } - winrt::Windows::Foundation::Collections::IVectorView CatalogPackage::GetAllCatalogPackageMetadata(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey) - { - Windows::Foundation::Collections::IVector allCatalogPackageMetadata{ winrt::single_threaded_vector() }; - ::AppInstaller::Repository::PackageVersionKey internalVersionKey(winrt::to_string(versionKey.PackageCatalogId()), winrt::to_string(versionKey.Version()), winrt::to_string(versionKey.Channel())); - - std::shared_ptr<::AppInstaller::Repository::IPackageVersion> availableVersion = m_package.get()->GetAvailableVersion(internalVersionKey); - if (availableVersion) - { - for (auto const& localization : availableVersion->GetManifest().Localizations) - { - auto catalogPackageMetadata = winrt::make_self>(); - catalogPackageMetadata->Initialize(localization); - allCatalogPackageMetadata.Append(*catalogPackageMetadata); - } - } - - return allCatalogPackageMetadata.GetView(); - } } diff --git a/src/Microsoft.Management.Deployment/CatalogPackage.h b/src/Microsoft.Management.Deployment/CatalogPackage.h index 5fc3643ae7..520520bccb 100644 --- a/src/Microsoft.Management.Deployment/CatalogPackage.h +++ b/src/Microsoft.Management.Deployment/CatalogPackage.h @@ -31,9 +31,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation winrt::Microsoft::Management::Deployment::InstalledStatusType checkTypes); winrt::Windows::Foundation::IAsyncOperation CheckInstalledStatusAsync(); winrt::Microsoft::Management::Deployment::CheckInstalledStatusResult CheckInstalledStatus(); - // Contract 6.0 - winrt::Microsoft::Management::Deployment::CatalogPackageMetadata GetCatalogPackageMetadata(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey, const hstring& locale); - winrt::Windows::Foundation::Collections::IVectorView GetAllCatalogPackageMetadata(winrt::Microsoft::Management::Deployment::PackageVersionId const& versionKey); #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) private: diff --git a/src/Microsoft.Management.Deployment/ComClsids.cpp b/src/Microsoft.Management.Deployment/ComClsids.cpp index 500a70c796..35e774070f 100644 --- a/src/Microsoft.Management.Deployment/ComClsids.cpp +++ b/src/Microsoft.Management.Deployment/ComClsids.cpp @@ -8,7 +8,6 @@ #include "PackageManager.h" #include "FindPackagesOptions.h" #include "CreateCompositePackageCatalogOptions.h" -#include "PackageCatalogConnectOptions.h" #include "InstallOptions.h" #include "UninstallOptions.h" #include "PackageMatchFilter.h" @@ -31,10 +30,6 @@ namespace winrt::Microsoft::Management::Deployment { return __uuidof(winrt::Microsoft::Management::Deployment::implementation::CreateCompositePackageCatalogOptions); } - else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_PackageCatalogConnectOptions)) - { - return __uuidof(winrt::Microsoft::Management::Deployment::implementation::PackageCatalogConnectOptions); - } else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_InstallOptions)) { return __uuidof(winrt::Microsoft::Management::Deployment::implementation::InstallOptions); diff --git a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj index 2b420eb51e..30cbf10841 100644 --- a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj +++ b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj @@ -151,7 +151,6 @@ - @@ -185,7 +184,6 @@ - diff --git a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters index 8a8fa02a86..188586d820 100644 --- a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters +++ b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters @@ -14,7 +14,6 @@ - @@ -48,7 +47,6 @@ - diff --git a/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.cpp b/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.cpp deleted file mode 100644 index 68a01b080c..0000000000 --- a/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -#include "pch.h" -#pragma warning( push ) -#pragma warning ( disable : 4467 6388) -// 6388 Allow CreateInstance. -#include -// 4467 Allow use of uuid attribute for com object creation. -#include "PackageCatalogConnectOptions.h" -#pragma warning( pop ) -#include "PackageCatalogConnectOptions.g.cpp" -#include "Helpers.h" - - -namespace winrt::Microsoft::Management::Deployment::implementation -{ - bool PackageCatalogConnectOptions::AcceptSourceAgreements() - { - return m_acceptSourceAgreements; - } - void PackageCatalogConnectOptions::AcceptSourceAgreements(bool value) - { - m_acceptSourceAgreements = value; - } - - CoCreatableMicrosoftManagementDeploymentClass(PackageCatalogConnectOptions); -} diff --git a/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.h b/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.h deleted file mode 100644 index 782833ff50..0000000000 --- a/src/Microsoft.Management.Deployment/PackageCatalogConnectOptions.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -#pragma once -#include "PackageCatalogConnectOptions.g.h" -#include "Public/ComClsids.h" - -namespace winrt::Microsoft::Management::Deployment::implementation -{ - [uuid(WINGET_OUTOFPROC_COM_CLSID_PackageCatalogConnectOptions)] - struct PackageCatalogConnectOptions : PackageCatalogConnectOptionsT - { - PackageCatalogConnectOptions() = default; - - bool AcceptSourceAgreements(); - void AcceptSourceAgreements(bool value); - -#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) - private: - bool m_acceptSourceAgreements = true; -#endif - }; -} - -#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) -namespace winrt::Microsoft::Management::Deployment::factory_implementation -{ - struct PackageCatalogConnectOptions : PackageCatalogConnectOptionsT - { - }; -} -#endif diff --git a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp index 9c972dc125..e7c02508a1 100644 --- a/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp +++ b/src/Microsoft.Management.Deployment/PackageCatalogReference.cpp @@ -39,10 +39,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation { co_return Connect(); } - winrt::Windows::Foundation::IAsyncOperation PackageCatalogReference::ConnectWithOptionsAsync(winrt::Microsoft::Management::Deployment::PackageCatalogConnectOptions options) - { - co_return ConnectWithOptions(options); - } winrt::Microsoft::Management::Deployment::ConnectResult GetConnectCatalogErrorResult() { auto connectResult = winrt::make_self>(); @@ -50,10 +46,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation return *connectResult; } winrt::Microsoft::Management::Deployment::ConnectResult PackageCatalogReference::Connect() - { - return ConnectWithOptions(NULL); - } - winrt::Microsoft::Management::Deployment::ConnectResult PackageCatalogReference::ConnectWithOptions(winrt::Microsoft::Management::Deployment::PackageCatalogConnectOptions options) { try { @@ -63,7 +55,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation return GetConnectCatalogErrorResult(); } - if (options && !options.AcceptSourceAgreements()) + if (!m_acceptSourceAgreements) { return GetConnectCatalogErrorResult(); } @@ -174,4 +166,12 @@ namespace winrt::Microsoft::Management::Deployment::implementation m_sourceReference.SetCustomHeader(m_additionalPackageCatalogArguments); } } + void PackageCatalogReference::AcceptSourceAgreements(bool value) + { + m_acceptSourceAgreements = value; + } + bool PackageCatalogReference::AcceptSourceAgreements() + { + return m_acceptSourceAgreements; + } } diff --git a/src/Microsoft.Management.Deployment/PackageCatalogReference.h b/src/Microsoft.Management.Deployment/PackageCatalogReference.h index f2a5e82b6d..4aa80425aa 100644 --- a/src/Microsoft.Management.Deployment/PackageCatalogReference.h +++ b/src/Microsoft.Management.Deployment/PackageCatalogReference.h @@ -23,8 +23,8 @@ namespace winrt::Microsoft::Management::Deployment::implementation hstring AdditionalPackageCatalogArguments(); void AdditionalPackageCatalogArguments(hstring const& value); // Contract 6.0 - winrt::Windows::Foundation::IAsyncOperation ConnectWithOptionsAsync(PackageCatalogConnectOptions options); - winrt::Microsoft::Management::Deployment::ConnectResult ConnectWithOptions(PackageCatalogConnectOptions options); + bool AcceptSourceAgreements(); + void AcceptSourceAgreements(bool value); #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) private: @@ -33,6 +33,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation winrt::Windows::Foundation::Collections::IVector m_sourceAgreements{ winrt::single_threaded_vector() }; ::AppInstaller::Repository::Source m_sourceReference; std::optional m_additionalPackageCatalogArguments; + bool m_acceptSourceAgreements = true; #endif }; } diff --git a/src/Microsoft.Management.Deployment/PackageManager.idl b/src/Microsoft.Management.Deployment/PackageManager.idl index eef9185ed1..3d969c6c09 100644 --- a/src/Microsoft.Management.Deployment/PackageManager.idl +++ b/src/Microsoft.Management.Deployment/PackageManager.idl @@ -280,6 +280,16 @@ namespace Microsoft.Management.Deployment /// a lot of fields and no one requesting it. /// Gets the manifest of this package version. /// virtual Manifest::Manifest GetManifest() = 0; + + + [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] + { + /// Gets the default package catalog metadata of this package version. + CatalogPackageMetadata GetCatalogPackageMetadata(); + + /// Gets the package catalog metadata of this package version with the specified locale. + CatalogPackageMetadata GetCatalogPackageMetadata(String locale); + } } /// IMPLEMENTATION NOTE: PackageVersionKey from winget/RepositorySearch.h @@ -459,13 +469,6 @@ namespace Microsoft.Management.Deployment /// IsSame from IPackage in winget/RepositorySearch is not implemented in V1. /// Determines if the given IPackage refers to the same package as this one. /// virtual bool IsSame(const IPackage*) const = 0; - - [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] - { - CatalogPackageMetadata GetCatalogPackageMetadata(PackageVersionId versionKey, String locale); - - Windows.Foundation.Collections.IVectorView GetAllCatalogPackageMetadata(PackageVersionId versionKey); - } } /// IMPLEMENTATION NOTE: CompositeSearchBehavior from winget/RepositorySource.h @@ -654,10 +657,9 @@ namespace Microsoft.Management.Deployment [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] { /// Gets the required agreements for connecting to the package catalog (source). - Windows.Foundation.Collections.IVectorView SourceAgreements{ get; }; + Windows.Foundation.Collections.IVectorView SourceAgreements { get; }; - Windows.Foundation.IAsyncOperation ConnectWithOptionsAsync(PackageCatalogConnectOptions packageCatalogConnectOptions); - ConnectResult ConnectWithOptions(PackageCatalogConnectOptions packageCatalogConnectOptions); + Boolean AcceptSourceAgreements{ get; }; } } @@ -845,17 +847,6 @@ namespace Microsoft.Management.Deployment } } - /// Options when connecting to a package catalog. - /// Intended to allow source agreements to be accepted connecting to the package catalog. - [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] - runtimeclass PackageCatalogConnectOptions - { - PackageCatalogConnectOptions(); - - /// Accept the source agreements required when connecting to a package catalog. - Boolean AcceptSourceAgreements; - } - /// IMPLEMENTATION NOTE: SourceOrigin from AppInstaller::Repository::Documentation [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] runtimeclass Documentation diff --git a/src/Microsoft.Management.Deployment/PackageVersionInfo.cpp b/src/Microsoft.Management.Deployment/PackageVersionInfo.cpp index 0d8dcbfb59..12348710a5 100644 --- a/src/Microsoft.Management.Deployment/PackageVersionInfo.cpp +++ b/src/Microsoft.Management.Deployment/PackageVersionInfo.cpp @@ -20,6 +20,7 @@ #include "PackageManager.h" #pragma warning( pop ) #include +#include namespace winrt::Microsoft::Management::Deployment::implementation { @@ -138,4 +139,33 @@ namespace winrt::Microsoft::Management::Deployment::implementation { return m_packageVersion; } + Microsoft::Management::Deployment::CatalogPackageMetadata PackageVersionInfo::GetCatalogPackageMetadata() + { + auto catalogPackageMetadata = winrt::make_self>(); + if (m_packageVersion) + { + auto manifest = m_packageVersion->GetManifest(); + catalogPackageMetadata->Initialize(manifest.DefaultLocalization); + } + + return *catalogPackageMetadata; + } + Microsoft::Management::Deployment::CatalogPackageMetadata PackageVersionInfo::GetCatalogPackageMetadata(const hstring& locale) + { + std::string localeString = winrt::to_string(locale); + auto catalogPackageMetadata = winrt::make_self>(); + if (m_packageVersion) + { + auto manifest = m_packageVersion->GetManifest(); + if (!::AppInstaller::Locale::IsWellFormedBcp47Tag(localeString)) + { + throw hresult_invalid_argument(); + } + + manifest.ApplyLocale(localeString); + catalogPackageMetadata->Initialize(manifest.CurrentLocalization); + } + + return *catalogPackageMetadata; + } } diff --git a/src/Microsoft.Management.Deployment/PackageVersionInfo.h b/src/Microsoft.Management.Deployment/PackageVersionInfo.h index c0bb708ac6..c34390a05f 100644 --- a/src/Microsoft.Management.Deployment/PackageVersionInfo.h +++ b/src/Microsoft.Management.Deployment/PackageVersionInfo.h @@ -24,8 +24,12 @@ namespace winrt::Microsoft::Management::Deployment::implementation winrt::Windows::Foundation::Collections::IVectorView ProductCodes(); winrt::Microsoft::Management::Deployment::PackageCatalog PackageCatalog(); winrt::Microsoft::Management::Deployment::CompareResult CompareToVersion(hstring versionString); - // Contract version 4 + // Contract 4.0 bool HasApplicableInstaller(InstallOptions options); + // Contract 6.0 + winrt::Microsoft::Management::Deployment::CatalogPackageMetadata GetCatalogPackageMetadata(); + winrt::Microsoft::Management::Deployment::CatalogPackageMetadata GetCatalogPackageMetadata(const hstring& locale); + #if !defined(INCLUDE_ONLY_INTERFACE_METHODS) private: diff --git a/src/Microsoft.Management.Deployment/Public/ComClsids.h b/src/Microsoft.Management.Deployment/Public/ComClsids.h index 64e016712c..144ddb351e 100644 --- a/src/Microsoft.Management.Deployment/Public/ComClsids.h +++ b/src/Microsoft.Management.Deployment/Public/ComClsids.h @@ -11,7 +11,6 @@ #define WINGET_OUTOFPROC_COM_CLSID_InstallOptions "1095F097-EB96-453B-B4E6-1613637F3B14" #define WINGET_OUTOFPROC_COM_CLSID_UninstallOptions "E1D9A11E-9F85-4D87-9C17-2B93143ADB8D" #define WINGET_OUTOFPROC_COM_CLSID_PackageMatchFilter "D02C9DAF-99DC-429C-B503-4E504E4AB000" -#define WINGET_OUTOFPROC_COM_CLSID_PackageCatalogConnectOptions "B5033698-79D1-4B94-9C39-0EC4EF1C7853" #else #define WINGET_OUTOFPROC_COM_CLSID_PackageManager "74CB3139-B7C5-4B9E-9388-E6616DEA288C" #define WINGET_OUTOFPROC_COM_CLSID_FindPackagesOptions "1BD8FF3A-EC50-4F69-AEEE-DF4C9D3BAA96" @@ -19,7 +18,6 @@ #define WINGET_OUTOFPROC_COM_CLSID_InstallOptions "44FE0580-62F7-44D4-9E91-AA9614AB3E86" #define WINGET_OUTOFPROC_COM_CLSID_UninstallOptions "AA2A5C04-1AD9-46C4-B74F-6B334AD7EB8C" #define WINGET_OUTOFPROC_COM_CLSID_PackageMatchFilter "3F85B9F4-487A-4C48-9035-2903F8A6D9E8" -#define WINGET_OUTOFPROC_COM_CLSID_PackageCatalogConnectOptions "6C4F68AC-F601-42FC-8CAF-87D3B3321783" #endif // Clsids only used in in-proc invocation @@ -35,7 +33,6 @@ namespace winrt::Microsoft::Management::Deployment const CLSID WINGET_INPROC_COM_CLSID_UninstallOptions = { 0x869CB959, 0xEB54, 0x425C, 0xA1, 0xE4, 0x1A, 0x1C, 0x29, 0x1C, 0x64, 0xE9 }; // 869CB959-EB54-425C-A1E4-1A1C291C64E9 const CLSID WINGET_INPROC_COM_CLSID_PackageMatchFilter = { 0x57DC8962, 0x7343, 0x42CD, 0xB9, 0x1C, 0x04, 0xF6, 0xA2, 0x5D, 0xB1, 0xD0 }; // 57DC8962-7343-42CD-B91C-04F6A25DB1D0 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_PackageCatalogConnectOptions = { 0xD026FDDC, 0x44D3, 0x443A, 0x8D, 0xAB, 0xA4, 0xDD, 0x96, 0x99, 0x43, 0xB3 }; //D026FDDC-44D3-443A-8DAB-A4DD969943B3 CLSID GetRedirectedClsidFromInProcClsid(REFCLSID clsid); } \ No newline at end of file diff --git a/src/WindowsPackageManager/main.cpp b/src/WindowsPackageManager/main.cpp index dba52c0098..8ee8a3bc52 100644 --- a/src/WindowsPackageManager/main.cpp +++ b/src/WindowsPackageManager/main.cpp @@ -21,7 +21,6 @@ using namespace winrt::Microsoft::Management::Deployment; CoCreatableClassWrlCreatorMapInclude(PackageManager); CoCreatableClassWrlCreatorMapInclude(FindPackagesOptions); CoCreatableClassWrlCreatorMapInclude(CreateCompositePackageCatalogOptions); -CoCreatableClassWrlCreatorMapInclude(PackageCatalogConnectOptions); CoCreatableClassWrlCreatorMapInclude(InstallOptions); CoCreatableClassWrlCreatorMapInclude(UninstallOptions); CoCreatableClassWrlCreatorMapInclude(PackageMatchFilter); From 70915efce7c3f84b2a79b28a9a65d08f9f5de705 Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Wed, 1 Feb 2023 09:44:01 -0800 Subject: [PATCH 14/17] fix line spacing --- src/Microsoft.Management.Deployment/PackageManager.idl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.Management.Deployment/PackageManager.idl b/src/Microsoft.Management.Deployment/PackageManager.idl index 3d969c6c09..a26f14cf3c 100644 --- a/src/Microsoft.Management.Deployment/PackageManager.idl +++ b/src/Microsoft.Management.Deployment/PackageManager.idl @@ -281,7 +281,6 @@ namespace Microsoft.Management.Deployment /// Gets the manifest of this package version. /// virtual Manifest::Manifest GetManifest() = 0; - [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] { /// Gets the default package catalog metadata of this package version. From b990b2cf63928791ba7d0f14a9fa7fe508b5a451 Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Tue, 7 Feb 2023 12:16:09 -0800 Subject: [PATCH 15/17] address comments --- .../PackageManager.idl | 2 +- .../PackageVersionInfo.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.Management.Deployment/PackageManager.idl b/src/Microsoft.Management.Deployment/PackageManager.idl index a26f14cf3c..9c4ed98673 100644 --- a/src/Microsoft.Management.Deployment/PackageManager.idl +++ b/src/Microsoft.Management.Deployment/PackageManager.idl @@ -283,7 +283,7 @@ namespace Microsoft.Management.Deployment [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] { - /// Gets the default package catalog metadata of this package version. + /// Gets the package catalog metadata of this package version with the default localization based on user settings. CatalogPackageMetadata GetCatalogPackageMetadata(); /// Gets the package catalog metadata of this package version with the specified locale. diff --git a/src/Microsoft.Management.Deployment/PackageVersionInfo.cpp b/src/Microsoft.Management.Deployment/PackageVersionInfo.cpp index 12348710a5..c67bf9fd9f 100644 --- a/src/Microsoft.Management.Deployment/PackageVersionInfo.cpp +++ b/src/Microsoft.Management.Deployment/PackageVersionInfo.cpp @@ -145,7 +145,8 @@ namespace winrt::Microsoft::Management::Deployment::implementation if (m_packageVersion) { auto manifest = m_packageVersion->GetManifest(); - catalogPackageMetadata->Initialize(manifest.DefaultLocalization); + manifest.ApplyLocale(); + catalogPackageMetadata->Initialize(manifest.CurrentLocalization); } return *catalogPackageMetadata; @@ -153,15 +154,15 @@ namespace winrt::Microsoft::Management::Deployment::implementation Microsoft::Management::Deployment::CatalogPackageMetadata PackageVersionInfo::GetCatalogPackageMetadata(const hstring& locale) { std::string localeString = winrt::to_string(locale); + if (!::AppInstaller::Locale::IsWellFormedBcp47Tag(localeString)) + { + throw hresult_invalid_argument(); + } + auto catalogPackageMetadata = winrt::make_self>(); if (m_packageVersion) { auto manifest = m_packageVersion->GetManifest(); - if (!::AppInstaller::Locale::IsWellFormedBcp47Tag(localeString)) - { - throw hresult_invalid_argument(); - } - manifest.ApplyLocale(localeString); catalogPackageMetadata->Initialize(manifest.CurrentLocalization); } From 36f2b116f750d1b94fdd4585033dece2e8849728 Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Mon, 6 Mar 2023 10:35:53 -0800 Subject: [PATCH 16/17] add result status for agreements --- src/Microsoft.Management.Deployment/Converters.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Microsoft.Management.Deployment/Converters.h b/src/Microsoft.Management.Deployment/Converters.h index c086535b55..67a3153886 100644 --- a/src/Microsoft.Management.Deployment/Converters.h +++ b/src/Microsoft.Management.Deployment/Converters.h @@ -82,11 +82,8 @@ namespace winrt::Microsoft::Management::Deployment::implementation case APPINSTALLER_CLI_ERROR_INTERNAL_ERROR: resultStatus = TStatus::InternalError; break; - case APPINSTALLER_CLI_ERROR_SOURCE_AGREEMENTS_NOT_ACCEPTED: - resultStatus = TStatus::SourceAgreementsNotAccepted; - break; case APPINSTALLER_CLI_ERROR_PACKAGE_AGREEMENTS_NOT_ACCEPTED: - resultStatus = TStatus::PackageAgreementsNotAccepted; + WINGET_GET_OPERATION_RESULT_STATUS(PackageAgreementsNotAccepted, InternalError); break; default: switch (executionStage) From 414f959b4feacca437d9b9506175f9a85a8e847f Mon Sep 17 00:00:00 2001 From: Ryan Fu Date: Wed, 8 Mar 2023 11:52:50 -0800 Subject: [PATCH 17/17] fix nits --- src/Microsoft.Management.Deployment/CatalogPackage.cpp | 1 - src/Microsoft.Management.Deployment/Converters.h | 6 +++--- src/Microsoft.Management.Deployment/PackageManager.idl | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.Management.Deployment/CatalogPackage.cpp b/src/Microsoft.Management.Deployment/CatalogPackage.cpp index 78e70193ab..d4c2e6b96f 100644 --- a/src/Microsoft.Management.Deployment/CatalogPackage.cpp +++ b/src/Microsoft.Management.Deployment/CatalogPackage.cpp @@ -5,7 +5,6 @@ #include #include "CatalogPackage.h" #include "CatalogPackage.g.cpp" -#include "CatalogPackageMetadata.h" #include "PackageCatalog.h" #include "PackageVersionInfo.h" #include "PackageVersionId.h" diff --git a/src/Microsoft.Management.Deployment/Converters.h b/src/Microsoft.Management.Deployment/Converters.h index 67a3153886..b04cef9fd5 100644 --- a/src/Microsoft.Management.Deployment/Converters.h +++ b/src/Microsoft.Management.Deployment/Converters.h @@ -69,6 +69,9 @@ namespace winrt::Microsoft::Management::Deployment::implementation case APPINSTALLER_CLI_ERROR_EXEC_UNINSTALL_COMMAND_FAILED: WINGET_GET_OPERATION_RESULT_STATUS(InstallError, UninstallError); break; + case APPINSTALLER_CLI_ERROR_PACKAGE_AGREEMENTS_NOT_ACCEPTED: + WINGET_GET_OPERATION_RESULT_STATUS(PackageAgreementsNotAccepted, InternalError); + break; case APPINSTALLER_CLI_ERROR_CANNOT_WRITE_TO_UPLEVEL_INDEX: case APPINSTALLER_CLI_ERROR_INDEX_INTEGRITY_COMPROMISED: case APPINSTALLER_CLI_ERROR_YAML_INIT_FAILED: @@ -82,9 +85,6 @@ namespace winrt::Microsoft::Management::Deployment::implementation case APPINSTALLER_CLI_ERROR_INTERNAL_ERROR: resultStatus = TStatus::InternalError; break; - case APPINSTALLER_CLI_ERROR_PACKAGE_AGREEMENTS_NOT_ACCEPTED: - WINGET_GET_OPERATION_RESULT_STATUS(PackageAgreementsNotAccepted, InternalError); - break; default: switch (executionStage) { diff --git a/src/Microsoft.Management.Deployment/PackageManager.idl b/src/Microsoft.Management.Deployment/PackageManager.idl index 558e6d3cad..c363db4b2d 100644 --- a/src/Microsoft.Management.Deployment/PackageManager.idl +++ b/src/Microsoft.Management.Deployment/PackageManager.idl @@ -644,7 +644,7 @@ namespace Microsoft.Management.Deployment [contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 6)] { SourceAgreementsNotAccepted, - } + } }; /// Result of the Connect call @@ -684,7 +684,7 @@ namespace Microsoft.Management.Deployment /// Gets the required agreements for connecting to the package catalog (source). Windows.Foundation.Collections.IVectorView SourceAgreements { get; }; - Boolean AcceptSourceAgreements{ get; set; }; + Boolean AcceptSourceAgreements; } }