From d8813eeb7bad63149996c275396b016d7fd2561c Mon Sep 17 00:00:00 2001 From: Zach Willson Date: Wed, 13 Apr 2022 20:54:06 -0700 Subject: [PATCH 01/10] Update MSStoreInstallerHandler.cpp update log message for NoStoreAccount and add or check for return statement to return true for GetFreeUserEntitlement if status was no store account --- .../Workflows/MSStoreInstallerHandler.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp index affe8a35ff..6dcfd638bd 100644 --- a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp +++ b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp @@ -87,7 +87,7 @@ namespace AppInstaller::CLI::Workflow else if (enr.Status() == GetEntitlementStatus::NoStoreAccount) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNoStoreAccount << std::endl; - AICLI_LOG(CLI, Error, << "Get entitlement failed. No Store account."); + AICLI_LOG(CLI, Error, << "Get entitlement failed, no Store account. However, that is okay as the app is free."); } else if (enr.Status() == GetEntitlementStatus::NetworkError) { @@ -99,8 +99,7 @@ namespace AppInstaller::CLI::Workflow 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 entitlementStatus == GetEntitlementStatus::Succeeded || entitlementStatus == GetEntitlementStatus::NoStoreAccount; } } From 07e0e0abdcc07b0d8028991cab35abfd4e09979a Mon Sep 17 00:00:00 2001 From: "zwillson@microsoft.com" Date: Thu, 14 Apr 2022 08:52:41 -0700 Subject: [PATCH 02/10] Update MSStoreInstallerHandler.cpp Fix formatting and return statement --- src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp index 6dcfd638bd..a0990d9202 100644 --- a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp +++ b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp @@ -99,7 +99,7 @@ namespace AppInstaller::CLI::Workflow context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementServerError << std::endl; AICLI_LOG(CLI, Error, << "Get entitlement succeeded. Server error. ProductId: " << Utility::ConvertToUTF8(productId)); } - return entitlementStatus == GetEntitlementStatus::Succeeded || entitlementStatus == GetEntitlementStatus::NoStoreAccount; + return enr.Status() == GetEntitlementStatus::Succeeded || enr.Status() == GetEntitlementStatus::NoStoreAccount; } } @@ -159,7 +159,7 @@ namespace AppInstaller::CLI::Workflow AppInstallItem installItem = installManager.SearchForUpdatesAsync( productId, // ProductId winrt::hstring() // SkuId - ).get(); + ).get(); if (!installItem) { From 28e9dbf569c47b1a8699d8b05a970d5593e6a060 Mon Sep 17 00:00:00 2001 From: "zwillson@microsoft.com" Date: Thu, 14 Apr 2022 12:56:44 -0700 Subject: [PATCH 03/10] Update MSStoreInstallerHandler.cpp Address feedback around usage of GetFreeDeviceEntitlementAsync, moved state checking logic to its own method --- .../Workflows/MSStoreInstallerHandler.cpp | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp index a0990d9202..fd1a932a48 100644 --- a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp +++ b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp @@ -78,16 +78,31 @@ namespace AppInstaller::CLI::Workflow context.Reporter.Info() << Resource::String::MSStoreInstallTryGetEntitlement << std::endl; GetEntitlementResult enr = installManager.GetFreeUserEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); + return GetSuccessOfEntitlementRequest(context, productId, enr); + } + + bool GetFreeDeviceEntitlement(Execution::Context& context, const std::wstring& productId) + { + AppInstallManager installManager; + + // Verifying/Acquiring product ownership + context.Reporter.Info() << Resource::String::MSStoreInstallTryGetEntitlement << std::endl; + GetEntitlementResult enr = installManager.GetFreeDeviceEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); + + return GetSuccessOfEntitlementRequest(context, productId, enr); + } + + bool GetSuccessOfEntitlementRequest(Execution::Context& context, const std::wstring& productId, GetEntitlementResult enr) + { if (enr.Status() == GetEntitlementStatus::Succeeded) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementSuccess << std::endl; AICLI_LOG(CLI, Error, << "Get entitlement succeeded."); - } else if (enr.Status() == GetEntitlementStatus::NoStoreAccount) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNoStoreAccount << std::endl; - AICLI_LOG(CLI, Error, << "Get entitlement failed, no Store account. However, that is okay as the app is free."); + AICLI_LOG(CLI, Error, << "Get entitlement failed. No Store account."); } else if (enr.Status() == GetEntitlementStatus::NetworkError) { @@ -99,7 +114,7 @@ namespace AppInstaller::CLI::Workflow 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 || enr.Status() == GetEntitlementStatus::NoStoreAccount; + return enr.Status() == GetEntitlementStatus::Succeeded; } } @@ -110,7 +125,7 @@ namespace AppInstaller::CLI::Workflow AppInstallManager installManager; // Verifying/Acquiring product ownership - if (!GetFreeUserEntitlement(context, productId)) + if (!GetFreeUserEntitlement(context, productId) || !GetFreeDeviceEntitlement(context, productId)) { AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_MSSTORE_INSTALL_FAILED); } @@ -148,7 +163,7 @@ namespace AppInstaller::CLI::Workflow AppInstallManager installManager; // Verifying/Acquiring product ownership - if (!GetFreeUserEntitlement(context, productId)) + if (!GetFreeUserEntitlement(context, productId) || !GetFreeDeviceEntitlement(context, productId)) { AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_MSSTORE_INSTALL_FAILED); } From a5c81f0ef8af00e07d2f170122d1f79efd9c62c2 Mon Sep 17 00:00:00 2001 From: "zwillson@microsoft.com" Date: Thu, 14 Apr 2022 13:24:24 -0700 Subject: [PATCH 04/10] Update MSStoreInstallerHandler.cpp Update to make logging clear over which entitlement type failed or succeeded --- .../Workflows/MSStoreInstallerHandler.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp index fd1a932a48..31236a2bfc 100644 --- a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp +++ b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp @@ -78,7 +78,7 @@ namespace AppInstaller::CLI::Workflow context.Reporter.Info() << Resource::String::MSStoreInstallTryGetEntitlement << std::endl; GetEntitlementResult enr = installManager.GetFreeUserEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); - return GetSuccessOfEntitlementRequest(context, productId, enr); + return GetSuccessOfEntitlementRequest(context, productId, enr, "User"); } bool GetFreeDeviceEntitlement(Execution::Context& context, const std::wstring& productId) @@ -89,30 +89,30 @@ namespace AppInstaller::CLI::Workflow context.Reporter.Info() << Resource::String::MSStoreInstallTryGetEntitlement << std::endl; GetEntitlementResult enr = installManager.GetFreeDeviceEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); - return GetSuccessOfEntitlementRequest(context, productId, enr); + return GetSuccessOfEntitlementRequest(context, productId, enr, "Device"); } - bool GetSuccessOfEntitlementRequest(Execution::Context& context, const std::wstring& productId, GetEntitlementResult enr) + bool GetSuccessOfEntitlementRequest(Execution::Context& context, const std::wstring& productId, GetEntitlementResult enr, std::string entitlementType) { if (enr.Status() == GetEntitlementStatus::Succeeded) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementSuccess << std::endl; - AICLI_LOG(CLI, Error, << "Get entitlement succeeded."); + AICLI_LOG(CLI, Error, << "Get " + entitlementType + " entitlement succeeded."); } else if (enr.Status() == GetEntitlementStatus::NoStoreAccount) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNoStoreAccount << std::endl; - AICLI_LOG(CLI, Error, << "Get entitlement failed. No Store account."); + AICLI_LOG(CLI, Error, << "Get " + entitlementType + " entitlement failed. No Store account."); } else if (enr.Status() == GetEntitlementStatus::NetworkError) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNetworkError << std::endl; - AICLI_LOG(CLI, Error, << "Get entitlement failed. Network error."); + AICLI_LOG(CLI, Error, << "Get " + entitlementType + " entitlement failed. Network error."); } else if (enr.Status() == GetEntitlementStatus::ServerError) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementServerError << std::endl; - AICLI_LOG(CLI, Error, << "Get entitlement succeeded. Server error. ProductId: " << Utility::ConvertToUTF8(productId)); + AICLI_LOG(CLI, Error, << "Get " + entitlementType + " entitlement succeeded. Server error. ProductId: " << Utility::ConvertToUTF8(productId)); } return enr.Status() == GetEntitlementStatus::Succeeded; } From 199fd6a1ee169a86dc43f8a7a060ed6320c8bfbd Mon Sep 17 00:00:00 2001 From: Zach Willson Date: Thu, 14 Apr 2022 17:30:15 -0700 Subject: [PATCH 05/10] Update src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp Co-authored-by: JohnMcPMS --- src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp index 31236a2bfc..e23c1b8faf 100644 --- a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp +++ b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp @@ -97,7 +97,7 @@ namespace AppInstaller::CLI::Workflow if (enr.Status() == GetEntitlementStatus::Succeeded) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementSuccess << std::endl; - AICLI_LOG(CLI, Error, << "Get " + entitlementType + " entitlement succeeded."); + AICLI_LOG(CLI, Error, << "Get " << entitlementType << " entitlement succeeded."); } else if (enr.Status() == GetEntitlementStatus::NoStoreAccount) { From b14ae912919499370546717723e0487489994613 Mon Sep 17 00:00:00 2001 From: Zach Willson Date: Thu, 14 Apr 2022 17:30:24 -0700 Subject: [PATCH 06/10] Update src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp Co-authored-by: JohnMcPMS --- src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp index e23c1b8faf..4d050423a8 100644 --- a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp +++ b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp @@ -92,7 +92,7 @@ namespace AppInstaller::CLI::Workflow return GetSuccessOfEntitlementRequest(context, productId, enr, "Device"); } - bool GetSuccessOfEntitlementRequest(Execution::Context& context, const std::wstring& productId, GetEntitlementResult enr, std::string entitlementType) + bool GetSuccessOfEntitlementRequest(Execution::Context& context, const std::wstring& productId, GetEntitlementResult enr, std::string_view entitlementType) { if (enr.Status() == GetEntitlementStatus::Succeeded) { From 06e51b5d74667d2f81ae7177d41bc4b6a0a629f1 Mon Sep 17 00:00:00 2001 From: "zwillson@microsoft.com" Date: Thu, 14 Apr 2022 17:59:23 -0700 Subject: [PATCH 07/10] Update MSStoreInstallerHandler.cpp addressed feedback --- .../Workflows/MSStoreInstallerHandler.cpp | 65 ++++++++++--------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp index 4d050423a8..1108ed6145 100644 --- a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp +++ b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp @@ -70,51 +70,56 @@ 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(); - - return GetSuccessOfEntitlementRequest(context, productId, enr, "User"); - } - - bool GetFreeDeviceEntitlement(Execution::Context& context, const std::wstring& productId) - { - AppInstallManager installManager; - - // Verifying/Acquiring product ownership - context.Reporter.Info() << Resource::String::MSStoreInstallTryGetEntitlement << std::endl; - GetEntitlementResult enr = installManager.GetFreeDeviceEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); - - return GetSuccessOfEntitlementRequest(context, productId, enr, "Device"); - } - - bool GetSuccessOfEntitlementRequest(Execution::Context& context, const std::wstring& productId, GetEntitlementResult enr, std::string_view entitlementType) - { - if (enr.Status() == GetEntitlementStatus::Succeeded) + GetEntitlementResult userEntitlementResult = installManager.GetFreeUserEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); + if (userEntitlementResult.Status() == GetEntitlementStatus::Succeeded) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementSuccess << std::endl; - AICLI_LOG(CLI, Error, << "Get " << entitlementType << " entitlement succeeded."); + AICLI_LOG(CLI, Error, << "Get user entitlement succeeded."); } - else if (enr.Status() == GetEntitlementStatus::NoStoreAccount) + else if (userEntitlementResult.Status() == GetEntitlementStatus::NoStoreAccount) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNoStoreAccount << std::endl; - AICLI_LOG(CLI, Error, << "Get " + entitlementType + " entitlement failed. No Store account."); + // Fallback to Device Entitlement + GetEntitlementResult deviceEntitlementResult = installManager.GetFreeDeviceEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); + if (deviceEntitlementResult.Status() == GetEntitlementStatus::Succeeded) + { + context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementSuccess << std::endl; + AICLI_LOG(CLI, Error, << "Get device entitlement succeeded."); + } + else if (deviceEntitlementResult.Status() == GetEntitlementStatus::NoStoreAccount) + { + context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNoStoreAccount << std::endl; + AICLI_LOG(CLI, Error, << "Get user and device entitlement failed. No Store account."); + } + else if (deviceEntitlementResult.Status() == GetEntitlementStatus::NetworkError) + { + context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNetworkError << std::endl; + AICLI_LOG(CLI, Error, << "Get device entitlement failed. Network error."); + } + else if (deviceEntitlementResult.Status() == GetEntitlementStatus::ServerError) + { + context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementServerError << std::endl; + AICLI_LOG(CLI, Error, << "Get device entitlement succeeded. Server error. ProductId: " << Utility::ConvertToUTF8(productId)); + } + return deviceEntitlementResult.Status() == GetEntitlementStatus::Succeeded; } - else if (enr.Status() == GetEntitlementStatus::NetworkError) + else if (userEntitlementResult.Status() == GetEntitlementStatus::NetworkError) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNetworkError << std::endl; - AICLI_LOG(CLI, Error, << "Get " + entitlementType + " entitlement failed. Network error."); + AICLI_LOG(CLI, Error, << "Get user entitlement failed. Network error."); } - else if (enr.Status() == GetEntitlementStatus::ServerError) + else if (userEntitlementResult.Status() == GetEntitlementStatus::ServerError) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementServerError << std::endl; - AICLI_LOG(CLI, Error, << "Get " + entitlementType + " entitlement succeeded. Server error. ProductId: " << Utility::ConvertToUTF8(productId)); + AICLI_LOG(CLI, Error, << "Get user entitlement succeeded. Server error. ProductId: " << Utility::ConvertToUTF8(productId)); } - return enr.Status() == GetEntitlementStatus::Succeeded; + return userEntitlementResult.Status() == GetEntitlementStatus::Succeeded; } } @@ -125,7 +130,7 @@ namespace AppInstaller::CLI::Workflow AppInstallManager installManager; // Verifying/Acquiring product ownership - if (!GetFreeUserEntitlement(context, productId) || !GetFreeDeviceEntitlement(context, productId)) + if (!GetFreeEntitlement(context, productId)) { AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_MSSTORE_INSTALL_FAILED); } @@ -163,7 +168,7 @@ namespace AppInstaller::CLI::Workflow AppInstallManager installManager; // Verifying/Acquiring product ownership - if (!GetFreeUserEntitlement(context, productId) || !GetFreeDeviceEntitlement(context, productId)) + if (!GetFreeEntitlement(context, productId)) { AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_MSSTORE_INSTALL_FAILED); } From 4d265e93938e7bd10b1f9ff940ad6513f7f5dbf5 Mon Sep 17 00:00:00 2001 From: "zwillson@microsoft.com" Date: Tue, 26 Apr 2022 11:12:33 -0700 Subject: [PATCH 08/10] Update MSStoreInstallerHandler.cpp address feedback --- .../Workflows/MSStoreInstallerHandler.cpp | 48 ++++++------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp index 1108ed6145..02288ef955 100644 --- a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp +++ b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp @@ -76,50 +76,32 @@ namespace AppInstaller::CLI::Workflow // Verifying/Acquiring product ownership context.Reporter.Info() << Resource::String::MSStoreInstallTryGetEntitlement << std::endl; - GetEntitlementResult userEntitlementResult = installManager.GetFreeUserEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); - if (userEntitlementResult.Status() == GetEntitlementStatus::Succeeded) + + AICLI_LOG(CLI, Error, << "Get user entitlement."); + GetEntitlementResult result = installManager.GetFreeUserEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); + if (result.Status() == GetEntitlementStatus::Succeeded) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementSuccess << std::endl; - AICLI_LOG(CLI, Error, << "Get user entitlement succeeded."); } - else if (userEntitlementResult.Status() == GetEntitlementStatus::NoStoreAccount) + + if (result.Status() == GetEntitlementStatus::NoStoreAccount) { - context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNoStoreAccount << std::endl; - // Fallback to Device Entitlement - GetEntitlementResult deviceEntitlementResult = installManager.GetFreeDeviceEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); - if (deviceEntitlementResult.Status() == GetEntitlementStatus::Succeeded) - { - context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementSuccess << std::endl; - AICLI_LOG(CLI, Error, << "Get device entitlement succeeded."); - } - else if (deviceEntitlementResult.Status() == GetEntitlementStatus::NoStoreAccount) - { - context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNoStoreAccount << std::endl; - AICLI_LOG(CLI, Error, << "Get user and device entitlement failed. No Store account."); - } - else if (deviceEntitlementResult.Status() == GetEntitlementStatus::NetworkError) - { - context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNetworkError << std::endl; - AICLI_LOG(CLI, Error, << "Get device entitlement failed. Network error."); - } - else if (deviceEntitlementResult.Status() == GetEntitlementStatus::ServerError) - { - context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementServerError << std::endl; - AICLI_LOG(CLI, Error, << "Get device entitlement succeeded. Server error. ProductId: " << Utility::ConvertToUTF8(productId)); - } - return deviceEntitlementResult.Status() == GetEntitlementStatus::Succeeded; + AICLI_LOG(CLI, Error, << "Get device entitlement."); + result = installManager.GetFreeUserEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); } - else if (userEntitlementResult.Status() == GetEntitlementStatus::NetworkError) + + if (result.Status() == GetEntitlementStatus::NetworkError) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNetworkError << std::endl; - AICLI_LOG(CLI, Error, << "Get user entitlement failed. Network error."); + AICLI_LOG(CLI, Error, << "Get entitlement failed. Network error."); } - else if (userEntitlementResult.Status() == GetEntitlementStatus::ServerError) + else if (result.Status() == GetEntitlementStatus::ServerError) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementServerError << std::endl; - AICLI_LOG(CLI, Error, << "Get user entitlement succeeded. Server error. ProductId: " << Utility::ConvertToUTF8(productId)); + AICLI_LOG(CLI, Error, << "Get entitlement succeeded. Server error. ProductId: " << Utility::ConvertToUTF8(productId)); } - return userEntitlementResult.Status() == GetEntitlementStatus::Succeeded; + + return result.Status() == GetEntitlementStatus::Succeeded; } } From 83e04f6f9e2773614d8820091f00b448c071e482 Mon Sep 17 00:00:00 2001 From: Yao Sun Date: Tue, 26 Apr 2022 14:58:03 -0700 Subject: [PATCH 09/10] Use device --- .../Workflows/MSStoreInstallerHandler.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp index 02288ef955..5e9643d144 100644 --- a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp +++ b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp @@ -79,18 +79,17 @@ namespace AppInstaller::CLI::Workflow AICLI_LOG(CLI, Error, << "Get user entitlement."); GetEntitlementResult result = installManager.GetFreeUserEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); - if (result.Status() == GetEntitlementStatus::Succeeded) - { - context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementSuccess << std::endl; - } - if (result.Status() == GetEntitlementStatus::NoStoreAccount) { AICLI_LOG(CLI, Error, << "Get device entitlement."); - result = installManager.GetFreeUserEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); + result = installManager.GetFreeDeviceEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); } - if (result.Status() == GetEntitlementStatus::NetworkError) + if (result.Status() == GetEntitlementStatus::Succeeded) + { + context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementSuccess << std::endl; + } + else if (result.Status() == GetEntitlementStatus::NetworkError) { context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNetworkError << std::endl; AICLI_LOG(CLI, Error, << "Get entitlement failed. Network error."); From eb1375ea3002ef02747c4175a08a67e914ae92e2 Mon Sep 17 00:00:00 2001 From: Yao Sun Date: Tue, 26 Apr 2022 15:08:53 -0700 Subject: [PATCH 10/10] Correct logging type --- src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp index 5e9643d144..99d11224eb 100644 --- a/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp +++ b/src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp @@ -77,11 +77,11 @@ namespace AppInstaller::CLI::Workflow // Verifying/Acquiring product ownership context.Reporter.Info() << Resource::String::MSStoreInstallTryGetEntitlement << std::endl; - AICLI_LOG(CLI, Error, << "Get user entitlement."); + AICLI_LOG(CLI, Info, << "Get user entitlement."); GetEntitlementResult result = installManager.GetFreeUserEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); if (result.Status() == GetEntitlementStatus::NoStoreAccount) { - AICLI_LOG(CLI, Error, << "Get device entitlement."); + AICLI_LOG(CLI, Info, << "Get device entitlement."); result = installManager.GetFreeDeviceEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get(); }