diff --git a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Helpers/ElevatedConfigureUnitTaskResult.cs b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Helpers/ElevatedConfigureUnitTaskResult.cs index 0e021d9daa..a28c535770 100644 --- a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Helpers/ElevatedConfigureUnitTaskResult.cs +++ b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Helpers/ElevatedConfigureUnitTaskResult.cs @@ -14,7 +14,7 @@ public sealed class ElevatedConfigureUnitTaskResult public string? Id { get; set; } - public string? Description { get; set; } + public string? UnitDescription { get; set; } public string? Intent { get; set; } @@ -25,4 +25,6 @@ public sealed class ElevatedConfigureUnitTaskResult public int ResultSource { get; set; } public string? Details { get; set; } + + public string? ErrorDescription { get; set; } } diff --git a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedConfigurationTask.cs b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedConfigurationTask.cs index cd415ce71e..9f2ee9333c 100644 --- a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedConfigurationTask.cs +++ b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedConfigurationTask.cs @@ -39,11 +39,12 @@ public IAsyncOperation ApplyConfiguration(string fi { UnitName = unitResult.Unit.UnitName, Id = unitResult.Unit.Identifier, - Description = descriptionObj?.ToString() ?? string.Empty, + UnitDescription = descriptionObj?.ToString() ?? string.Empty, Intent = unitResult.Unit.Intent.ToString(), IsSkipped = unitResult.State == ConfigurationUnitState.Skipped, HResult = unitResult.ResultInformation?.ResultCode?.HResult ?? HRESULT.S_OK, ResultSource = (int)(unitResult.ResultInformation?.ResultSource ?? ConfigurationUnitResultSource.None), + ErrorDescription = unitResult.ResultInformation?.Description, }; }).ToList(); diff --git a/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigurationUnitResult.cs b/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigurationUnitResult.cs index 7f6ec78a8b..8f5a21d402 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigurationUnitResult.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigurationUnitResult.cs @@ -15,31 +15,35 @@ public ConfigurationUnitResult(ApplyConfigurationUnitResult result) UnitName = result.Unit.UnitName; Id = result.Unit.Identifier; result.Unit.Directives.TryGetValue("description", out var descriptionObj); - Description = descriptionObj?.ToString() ?? string.Empty; + UnitDescription = descriptionObj?.ToString() ?? string.Empty; Intent = result.Unit.Intent.ToString(); IsSkipped = result.State == ConfigurationUnitState.Skipped; HResult = result.ResultInformation?.ResultCode?.HResult ?? HRESULT.S_OK; ResultSource = result.ResultInformation?.ResultSource ?? ConfigurationUnitResultSource.None; Details = result.ResultInformation?.Details; + ErrorDescription = result.ResultInformation?.Description; } public ConfigurationUnitResult(ElevatedConfigureUnitTaskResult result) { UnitName = result.UnitName; Id = result.Id; - Description = result.Description; + UnitDescription = result.UnitDescription; Intent = result.Intent; IsSkipped = result.IsSkipped; HResult = result.HResult; ResultSource = (ConfigurationUnitResultSource)result.ResultSource; Details = result.Details; + ErrorDescription = result.ErrorDescription; } public string UnitName { get; } public string Id { get; } - public string Description { get; } + public string UnitDescription { get; } + + public string ErrorDescription { get; } public string Intent { get; } diff --git a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ConfigurationUnitResultViewModel.cs b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ConfigurationUnitResultViewModel.cs index 4cf141010f..321cd7ae9b 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ConfigurationUnitResultViewModel.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ConfigurationUnitResultViewModel.cs @@ -22,7 +22,7 @@ namespace DevHome.SetupFlow.ViewModels; public class ConfigurationUnitResultViewModel { private readonly ConfigurationUnitResult _unitResult; - private readonly ISetupFlowStringResource _stringResource; + private readonly ISetupFlowStringResource _stringResource; public ConfigurationUnitResultViewModel(ISetupFlowStringResource stringResource, ConfigurationUnitResult unitResult) { @@ -33,13 +33,15 @@ public ConfigurationUnitResultViewModel(ISetupFlowStringResource stringResource, public string Title => BuildTitle(); public string ApplyResult => GetApplyResult(); + + public string ErrorDescription => GetErrorDescription(); public bool IsSkipped => _unitResult.IsSkipped; public bool IsError => !IsSkipped && _unitResult.HResult != HRESULT.S_OK; public bool IsSuccess => _unitResult.HResult == HRESULT.S_OK; - + private string GetApplyResult() { if (IsSkipped) @@ -57,22 +59,22 @@ private string GetApplyResult() private string BuildTitle() { - if (string.IsNullOrEmpty(_unitResult.Id) && string.IsNullOrEmpty(_unitResult.Description)) + if (string.IsNullOrEmpty(_unitResult.Id) && string.IsNullOrEmpty(_unitResult.UnitDescription)) { return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryMinimal, _unitResult.Intent, _unitResult.UnitName); } if (string.IsNullOrEmpty(_unitResult.Id)) { - return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryNoId, _unitResult.Intent, _unitResult.UnitName, _unitResult.Description); + return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryNoId, _unitResult.Intent, _unitResult.UnitName, _unitResult.UnitDescription); } - if (string.IsNullOrEmpty(_unitResult.Description)) + if (string.IsNullOrEmpty(_unitResult.UnitDescription)) { return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryNoDescription, _unitResult.Intent, _unitResult.UnitName, _unitResult.Id); } - return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryFull, _unitResult.Intent, _unitResult.UnitName, _unitResult.Id, _unitResult.Description); + return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryFull, _unitResult.Intent, _unitResult.UnitName, _unitResult.Id, _unitResult.UnitDescription); } private string GetUnitSkipMessage() @@ -147,5 +149,34 @@ private string GetUnitErrorMessage() } return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitFailed, resultCodeHex); - } + } + + private string GetErrorDescription() + { + if (string.IsNullOrEmpty(_unitResult.ErrorDescription)) + { + return string.Empty; + } + + // If the localized configuration error message requires additional + // context, display the error description from the resource module directly. + // Code reference: https://github.com/microsoft/winget-cli/blob/master/src/AppInstallerCLICore/Workflows/ConfigurationFlow.cpp + switch (_unitResult.HResult) + { + case WinGetConfigurationException.WingetConfigErrorDuplicateIdentifier: + case WinGetConfigurationException.WingetConfigErrorMissingDependency: + case WinGetConfigurationException.WingetConfigErrorAssertionFailed: + case WinGetConfigurationException.WinGetConfigUnitNotFound: + case WinGetConfigurationException.WinGetConfigUnitNotFoundRepository: + case WinGetConfigurationException.WinGetConfigUnitMultipleMatches: + case WinGetConfigurationException.WinGetConfigUnitModuleConflict: + case WinGetConfigurationException.WinGetConfigUnitImportModule: + case WinGetConfigurationException.WinGetConfigUnitInvokeInvalidResult: + case WinGetConfigurationException.WinGetConfigUnitSettingConfigRoot: + case WinGetConfigurationException.WinGetConfigUnitImportModuleAdmin: + return string.Empty; + default: + return _unitResult.ErrorDescription; + } + } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/Views/SummaryView.xaml b/tools/SetupFlow/DevHome.SetupFlow/Views/SummaryView.xaml index bde815d538..9af80d4539 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Views/SummaryView.xaml +++ b/tools/SetupFlow/DevHome.SetupFlow/Views/SummaryView.xaml @@ -20,6 +20,7 @@ + @@ -144,22 +145,29 @@ + + - - - - - - - - - - + + + + + + + + + + + + +