winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 73555181e4ae025f61d97d0e2147cdb47545d1a6
parent 2937bdfcb3681c45a53eabc6cc45fafc327fa956
Author: Zach Willson <zachcwillson@users.noreply.github.com>
Date:   Tue, 26 Apr 2022 16:16:11 -0700

Allow winget to install MS Store packages without account (#2095)


Diffstat:
Msrc/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp | 30+++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp @@ -70,37 +70,37 @@ namespace AppInstaller::CLI::Workflow return errorCode; } - bool GetFreeUserEntitlement(Execution::Context& context, const std::wstring& productId) + bool GetFreeEntitlement(Execution::Context& context, const std::wstring& productId) { AppInstallManager installManager; // Verifying/Acquiring product ownership context.Reporter.Info() << Resource::String::MSStoreInstallTryGetEntitlement << std::endl; - GetEntitlementResult enr = installManager.GetFreeUserEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); - if (enr.Status() == GetEntitlementStatus::Succeeded) + AICLI_LOG(CLI, Info, << "Get user entitlement."); + GetEntitlementResult result = installManager.GetFreeUserEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); + if (result.Status() == GetEntitlementStatus::NoStoreAccount) { - context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementSuccess << std::endl; - AICLI_LOG(CLI, Error, << "Get entitlement succeeded."); - + AICLI_LOG(CLI, Info, << "Get device entitlement."); + result = installManager.GetFreeDeviceEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); } - else if (enr.Status() == GetEntitlementStatus::NoStoreAccount) + + if (result.Status() == GetEntitlementStatus::Succeeded) { - context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNoStoreAccount << std::endl; - AICLI_LOG(CLI, Error, << "Get entitlement failed. No Store account."); + context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementSuccess << std::endl; } - else if (enr.Status() == GetEntitlementStatus::NetworkError) + else if (result.Status() == GetEntitlementStatus::NetworkError) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNetworkError << std::endl; AICLI_LOG(CLI, Error, << "Get entitlement failed. Network error."); } - else if (enr.Status() == GetEntitlementStatus::ServerError) + else if (result.Status() == GetEntitlementStatus::ServerError) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementServerError << std::endl; AICLI_LOG(CLI, Error, << "Get entitlement succeeded. Server error. ProductId: " << Utility::ConvertToUTF8(productId)); } - return enr.Status() == GetEntitlementStatus::Succeeded; + return result.Status() == GetEntitlementStatus::Succeeded; } } @@ -111,7 +111,7 @@ namespace AppInstaller::CLI::Workflow AppInstallManager installManager; // Verifying/Acquiring product ownership - if (!GetFreeUserEntitlement(context, productId)) + if (!GetFreeEntitlement(context, productId)) { AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_MSSTORE_INSTALL_FAILED); } @@ -149,7 +149,7 @@ namespace AppInstaller::CLI::Workflow AppInstallManager installManager; // Verifying/Acquiring product ownership - if (!GetFreeUserEntitlement(context, productId)) + if (!GetFreeEntitlement(context, productId)) { AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_MSSTORE_INSTALL_FAILED); } @@ -160,7 +160,7 @@ namespace AppInstaller::CLI::Workflow AppInstallItem installItem = installManager.SearchForUpdatesAsync( productId, // ProductId winrt::hstring() // SkuId - ).get(); + ).get(); if (!installItem) {