diff --git a/tools/SetupFlow/DevHome.SetupFlow.Common/Configuration/ConfigurationFileHelper.cs b/tools/SetupFlow/DevHome.SetupFlow.Common/Configuration/ConfigurationFileHelper.cs
index 268bf441c1..afdd410b2d 100644
--- a/tools/SetupFlow/DevHome.SetupFlow.Common/Configuration/ConfigurationFileHelper.cs
+++ b/tools/SetupFlow/DevHome.SetupFlow.Common/Configuration/ConfigurationFileHelper.cs
@@ -85,7 +85,7 @@ public async Task OpenConfigurationSetAsync(string filePath, string content)
_configSet = openResult.Set;
if (_configSet == null)
{
- throw new OpenConfigurationSetException(openResult.ResultCode, openResult.Field);
+ throw new OpenConfigurationSetException(openResult.ResultCode, openResult.Field, openResult.Value);
}
// Set input file path in the configuration set to inform the
diff --git a/tools/SetupFlow/DevHome.SetupFlow.Common/Exceptions/OpenConfigurationSetException.cs b/tools/SetupFlow/DevHome.SetupFlow.Common/Exceptions/OpenConfigurationSetException.cs
index 1e5b544b7f..5fed93f660 100644
--- a/tools/SetupFlow/DevHome.SetupFlow.Common/Exceptions/OpenConfigurationSetException.cs
+++ b/tools/SetupFlow/DevHome.SetupFlow.Common/Exceptions/OpenConfigurationSetException.cs
@@ -6,15 +6,8 @@
namespace DevHome.SetupFlow.Common.Exceptions;
-public class OpenConfigurationSetException : Exception
+public class OpenConfigurationSetException : WinGetConfigurationException
{
- // Open configuration error codes:
- // Reference: https://github.com/microsoft/winget-cli/blob/master/src/AppInstallerSharedLib/Public/AppInstallerErrors.h
- public const int WingetConfigErrorInvalidConfigurationFile = unchecked((int)0x8A15C001);
- public const int WingetConfigErrorInvalidYaml = unchecked((int)0x8A15C002);
- public const int WingetConfigErrorInvalidField = unchecked((int)0x8A15C003);
- public const int WingetConfigErrorUnknownConfigurationFileVersion = unchecked((int)0x8A15C004);
-
///
/// Gets the
///
@@ -24,16 +17,25 @@ public Exception ResultCode
}
///
- /// Gets the
+ /// Gets the field that is missing/invalid, if appropriate for the specific ResultCode.
///
public string Field
{
get;
}
- public OpenConfigurationSetException(Exception resultCode, string field)
+ ///
+ /// Gets the value of the field, if appropriate for the specific ResultCode.
+ ///
+ public string Value
+ {
+ get;
+ }
+
+ public OpenConfigurationSetException(Exception resultCode, string field, string value)
{
ResultCode = resultCode;
Field = field;
+ Value = value;
}
}
diff --git a/tools/SetupFlow/DevHome.SetupFlow.Common/Exceptions/WinGetConfigurationException.cs b/tools/SetupFlow/DevHome.SetupFlow.Common/Exceptions/WinGetConfigurationException.cs
new file mode 100644
index 0000000000..a12a495d6f
--- /dev/null
+++ b/tools/SetupFlow/DevHome.SetupFlow.Common/Exceptions/WinGetConfigurationException.cs
@@ -0,0 +1,39 @@
+// Copyright (c) Microsoft Corporation and Contributors
+// Licensed under the MIT license.
+
+using System;
+
+namespace DevHome.SetupFlow.Common.Exceptions;
+
+public class WinGetConfigurationException : Exception
+{
+ // WinGet Configuration error codes:
+ // https://github.com/microsoft/winget-cli/blob/master/src/PowerShell/Microsoft.WinGet.Configuration.Engine/Exceptions/ErrorCodes.cs
+ public const int WingetConfigErrorInvalidConfigurationFile = unchecked((int)0x8A15C001);
+ public const int WingetConfigErrorInvalidYaml = unchecked((int)0x8A15C002);
+ public const int WingetConfigErrorInvalidFieldType = unchecked((int)0x8A15C003);
+ public const int WingetConfigErrorUnknownConfigurationFileVersion = unchecked((int)0x8A15C004);
+ public const int WingetConfigErrorSetApplyFailed = unchecked((int)0x8A15C005);
+ public const int WingetConfigErrorDuplicateIdentifier = unchecked((int)0x8A15C006);
+ public const int WingetConfigErrorMissingDependency = unchecked((int)0x8A15C007);
+ public const int WingetConfigErrorDependencyUnsatisfied = unchecked((int)0x8A15C008);
+ public const int WingetConfigErrorAssertionFailed = unchecked((int)0x8A15C009);
+ public const int WingetConfigErrorManuallySkipped = unchecked((int)0x8A15C00A);
+ public const int WingetConfigErrorWarningNotAccepted = unchecked((int)0x8A15C00B);
+ public const int WingetConfigErrorSetDependencyCycle = unchecked((int)0x8A15C00C);
+ public const int WingetConfigErrorInvalidFieldValue = unchecked((int)0x8A15C00D);
+ public const int WingetConfigErrorMissingField = unchecked((int)0x8A15C00E);
+
+ // WinGet Configuration unit error codes:
+ public const int WinGetConfigUnitNotFound = unchecked((int)0x8A15C101);
+ public const int WinGetConfigUnitNotFoundRepository = unchecked((int)0x8A15C102);
+ public const int WinGetConfigUnitMultipleMatches = unchecked((int)0x8A15C103);
+ public const int WinGetConfigUnitInvokeGet = unchecked((int)0x8A15C104);
+ public const int WinGetConfigUnitInvokeTest = unchecked((int)0x8A15C105);
+ public const int WinGetConfigUnitInvokeSet = unchecked((int)0x8A15C106);
+ public const int WinGetConfigUnitModuleConflict = unchecked((int)0x8A15C107);
+ public const int WinGetConfigUnitImportModule = unchecked((int)0x8A15C108);
+ public const int WinGetConfigUnitInvokeInvalidResult = unchecked((int)0x8A15C109);
+ public const int WinGetConfigUnitSettingConfigRoot = unchecked((int)0x8A15C110);
+ public const int WinGetConfigUnitImportModuleAdmin = unchecked((int)0x8A15C111);
+}
diff --git a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Helpers/ElevatedConfigureUnitTaskResult.cs b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Helpers/ElevatedConfigureUnitTaskResult.cs
index 86e0916459..0e021d9daa 100644
--- a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Helpers/ElevatedConfigureUnitTaskResult.cs
+++ b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Helpers/ElevatedConfigureUnitTaskResult.cs
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
+using Microsoft.Management.Configuration;
+
namespace DevHome.SetupFlow.ElevatedComponent.Helpers;
///
@@ -19,4 +21,8 @@ public sealed class ElevatedConfigureUnitTaskResult
public bool IsSkipped { get; set; }
public int HResult { get; set; }
+
+ public int ResultSource { get; set; }
+
+ public string? Details { get; set; }
}
diff --git a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedConfigurationTask.cs b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedConfigurationTask.cs
index b1eded8de3..cd415ce71e 100644
--- a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedConfigurationTask.cs
+++ b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedConfigurationTask.cs
@@ -43,6 +43,7 @@ public IAsyncOperation ApplyConfiguration(string fi
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),
};
}).ToList();
diff --git a/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigurationUnitResult.cs b/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigurationUnitResult.cs
index a6d95c6654..7f6ec78a8b 100644
--- a/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigurationUnitResult.cs
+++ b/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigurationUnitResult.cs
@@ -1,45 +1,53 @@
-// Copyright (c) Microsoft Corporation and Contributors
-// Licensed under the MIT license.
-
-extern alias Projection;
-
-using Microsoft.Management.Configuration;
-using Projection::DevHome.SetupFlow.ElevatedComponent.Helpers;
-using Windows.Win32.Foundation;
-
-namespace DevHome.SetupFlow.Models;
-public class ConfigurationUnitResult
-{
- 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;
- Intent = result.Unit.Intent.ToString();
- IsSkipped = result.State == ConfigurationUnitState.Skipped;
- HResult = result.ResultInformation?.ResultCode?.HResult ?? HRESULT.S_OK;
- }
-
- public ConfigurationUnitResult(ElevatedConfigureUnitTaskResult result)
- {
- UnitName = result.UnitName;
- Id = result.Id;
- Description = result.Description;
- Intent = result.Intent;
- IsSkipped = result.IsSkipped;
- HResult = result.HResult;
- }
-
- public string UnitName { get; }
-
- public string Id { get; }
-
- public string Description { get; }
-
- public string Intent { get; }
-
- public bool IsSkipped { get; }
-
- public int HResult { get; }
-}
+// Copyright (c) Microsoft Corporation and Contributors
+// Licensed under the MIT license.
+
+extern alias Projection;
+
+using Microsoft.Management.Configuration;
+using Projection::DevHome.SetupFlow.ElevatedComponent.Helpers;
+using Windows.Win32.Foundation;
+
+namespace DevHome.SetupFlow.Models;
+public class ConfigurationUnitResult
+{
+ 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;
+ 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;
+ }
+
+ public ConfigurationUnitResult(ElevatedConfigureUnitTaskResult result)
+ {
+ UnitName = result.UnitName;
+ Id = result.Id;
+ Description = result.Description;
+ Intent = result.Intent;
+ IsSkipped = result.IsSkipped;
+ HResult = result.HResult;
+ ResultSource = (ConfigurationUnitResultSource)result.ResultSource;
+ Details = result.Details;
+ }
+
+ public string UnitName { get; }
+
+ public string Id { get; }
+
+ public string Description { get; }
+
+ public string Intent { get; }
+
+ public bool IsSkipped { get; }
+
+ public int HResult { get; }
+
+ public ConfigurationUnitResultSource ResultSource { get; }
+
+ public string Details { get; }
+}
diff --git a/tools/SetupFlow/DevHome.SetupFlow/Services/StringResourceKey.cs b/tools/SetupFlow/DevHome.SetupFlow/Services/StringResourceKey.cs
index c6d6614f66..dcf1ec1815 100644
--- a/tools/SetupFlow/DevHome.SetupFlow/Services/StringResourceKey.cs
+++ b/tools/SetupFlow/DevHome.SetupFlow/Services/StringResourceKey.cs
@@ -24,11 +24,6 @@ public static class StringResourceKey
public static readonly string ConfigurationFileApplySuccess = nameof(ConfigurationFileApplySuccess);
public static readonly string ConfigurationFileApplySuccessReboot = nameof(ConfigurationFileApplySuccessReboot);
public static readonly string ConfigurationFileApplying = nameof(ConfigurationFileApplying);
- public static readonly string ConfigurationFieldInvalid = nameof(ConfigurationFieldInvalid);
- public static readonly string ConfigurationFileInvalid = nameof(ConfigurationFileInvalid);
- public static readonly string ConfigurationFileOpenUnknownError = nameof(ConfigurationFileOpenUnknownError);
- public static readonly string ConfigurationFileVersionUnknown = nameof(ConfigurationFileVersionUnknown);
- public static readonly string ConfigurationFileTypeNotSupported = nameof(ConfigurationFileTypeNotSupported);
public static readonly string ConfigurationUnitFailed = nameof(ConfigurationUnitFailed);
public static readonly string ConfigurationUnitSkipped = nameof(ConfigurationUnitSkipped);
public static readonly string ConfigurationUnitSuccess = nameof(ConfigurationUnitSuccess);
@@ -176,4 +171,34 @@ public static class StringResourceKey
public static readonly string InstallPackageErrorNoApplicableInstallers = nameof(InstallPackageErrorNoApplicableInstallers);
public static readonly string InstallPackageErrorUnknownErrorWithErrorCode = nameof(InstallPackageErrorUnknownErrorWithErrorCode);
public static readonly string InstallPackageErrorUnknownErrorWithErrorCodeAndExitCode = nameof(InstallPackageErrorUnknownErrorWithErrorCodeAndExitCode);
+
+ // WinGet Configuration
+ public static readonly string ConfigurationFieldInvalidType = nameof(ConfigurationFieldInvalidType);
+ public static readonly string ConfigurationFieldInvalidValue = nameof(ConfigurationFieldInvalidValue);
+ public static readonly string ConfigurationFieldMissing = nameof(ConfigurationFieldMissing);
+ public static readonly string ConfigurationFileInvalid = nameof(ConfigurationFileInvalid);
+ public static readonly string ConfigurationFileOpenUnknownError = nameof(ConfigurationFileOpenUnknownError);
+ public static readonly string ConfigurationFileVersionUnknown = nameof(ConfigurationFileVersionUnknown);
+ public static readonly string ConfigurationUnitHasDuplicateIdentifier = nameof(ConfigurationUnitHasDuplicateIdentifier);
+ public static readonly string ConfigurationUnitHasMissingDependency = nameof(ConfigurationUnitHasMissingDependency);
+ public static readonly string ConfigurationUnitAssertHadNegativeResult = nameof(ConfigurationUnitAssertHadNegativeResult);
+ public static readonly string ConfigurationUnitNotFoundInModule = nameof(ConfigurationUnitNotFoundInModule);
+ public static readonly string ConfigurationUnitNotFound = nameof(ConfigurationUnitNotFound);
+ public static readonly string ConfigurationUnitMultipleMatches = nameof(ConfigurationUnitMultipleMatches);
+ public static readonly string ConfigurationUnitFailedDuringGet = nameof(ConfigurationUnitFailedDuringGet);
+ public static readonly string ConfigurationUnitFailedDuringTest = nameof(ConfigurationUnitFailedDuringTest);
+ public static readonly string ConfigurationUnitFailedDuringSet = nameof(ConfigurationUnitFailedDuringSet);
+ public static readonly string ConfigurationUnitModuleConflict = nameof(ConfigurationUnitModuleConflict);
+ public static readonly string ConfigurationUnitModuleImportFailed = nameof(ConfigurationUnitModuleImportFailed);
+ public static readonly string ConfigurationUnitReturnedInvalidResult = nameof(ConfigurationUnitReturnedInvalidResult);
+ public static readonly string ConfigurationUnitManuallySkipped = nameof(ConfigurationUnitManuallySkipped);
+ public static readonly string ConfigurationUnitNotRunDueToDependency = nameof(ConfigurationUnitNotRunDueToDependency);
+ public static readonly string WinGetConfigUnitSettingConfigRoot = nameof(WinGetConfigUnitSettingConfigRoot);
+ public static readonly string WinGetConfigUnitImportModuleAdmin = nameof(WinGetConfigUnitImportModuleAdmin);
+ public static readonly string ConfigurationUnitFailedConfigSet = nameof(ConfigurationUnitFailedConfigSet);
+ public static readonly string ConfigurationUnitFailedInternal = nameof(ConfigurationUnitFailedInternal);
+ public static readonly string ConfigurationUnitFailedPrecondition = nameof(ConfigurationUnitFailedPrecondition);
+ public static readonly string ConfigurationUnitFailedSystemState = nameof(ConfigurationUnitFailedSystemState);
+ public static readonly string ConfigurationUnitFailedUnitProcessing = nameof(ConfigurationUnitFailedUnitProcessing);
+ public static readonly string ConfigurationUnitNotRunDueToFailedAssert = nameof(ConfigurationUnitNotRunDueToFailedAssert);
}
diff --git a/tools/SetupFlow/DevHome.SetupFlow/Strings/en-us/Resources.resw b/tools/SetupFlow/DevHome.SetupFlow/Strings/en-us/Resources.resw
index 77c10d0d5b..0215395b2c 100644
--- a/tools/SetupFlow/DevHome.SetupFlow/Strings/en-us/Resources.resw
+++ b/tools/SetupFlow/DevHome.SetupFlow/Strings/en-us/Resources.resw
@@ -221,14 +221,6 @@
View {0}
{Locked="{0}"}Title for the page showing the contents of a configuration file. {0} is replaced by the configuration file name.
-
- Failed: {0}
- {Locked="{0}"}Error message displayed when applying a configuration unit fails. {0} is replaced by an error code.
-
-
- Skipped: {0}
- {Locked="{0}"}Warning message displayed when applying a configuration unit is skipped. {0} is replaced by an error code.
-
Configuration successfully applied
Message displayed when applying a configuration unit succeeds.
@@ -1263,4 +1255,97 @@
Add another account
Menu flyout item content to add another account
+
+ The field '{0}' in the configuration file is the wrong type.
+ {Locked="{0}"} An error in reading a configuration file. {0} is a placeholder replaced by the field name from the file.
+
+
+ The system is not in the desired state asserted by the configuration.
+
+
+ This configuration unit failed for an unknown reason: {0}
+ {Locked="{0}"} {0} is a placeholder for the unrecognized error code.
+
+
+ The configuration unit failed due to the configuration: {0}
+ {Locked="{0}"} {0} is a placeholder for the unrecognized error code.
+
+
+ The configuration unit failed while attempting to get the current system state.
+
+
+ The configuration unit failed while attempting to apply the desired state.
+
+
+ The configuration unit failed while attempting to test the current system state.
+
+
+ The configuration unit failed due to an internal error: {0}
+ {Locked="{0}"} {0} is a placeholder for the unrecognized error code.
+
+
+ The configuration unit failed due to a precondition not being valid: {0}
+ {Locked="{0}"} {0} is a placeholder for the unrecognized error code.
+
+
+ The configuration unit failed due to the system state: {0}
+ {Locked="{0}"} {0} is a placeholder for the unrecognized error code.
+
+
+ The configuration unit failed while attempting to run: {0}
+ {Locked="{0}"} {0} is a placeholder for the unrecognized error code.
+
+
+ The configuration contains the identifier `{0}` multiple times.
+ {Locked="{0}"} {0} is a placeholder that is replaced by the identifier string from the user input file.
+
+
+ The dependency `{0}` was not found within the configuration.
+ {Locked="{0}"} {0} is a placeholder that is replaced by the identifier string from the user input file.
+
+
+ This configuration unit was manually skipped.
+
+
+ The module for the configuration unit is available in multiple locations with the same version.
+
+
+ Loading the module for the configuration unit failed.
+
+
+ Multiple matches were found for the configuration unit; specify the module to select the correct one.
+
+
+ The configuration unit could not be found.
+
+
+ The configuration unit was not in the module as expected.
+
+
+ This configuration unit was not run because a dependency failed or was not run.
+
+
+ The configuration unit returned an unexpected result during execution.
+
+
+ This configuration unit was not run for an unknown reason: {0}
+ {Locked="{0}"} {0} is a placeholder for the unrecognized error code.
+
+
+ The field '{0}' has an invalid value: {1}
+ {Locked="{0}","{1}"} An error in reading a configuration file. {0} is a placeholder replaced by the field name from the file. {1} is a placeholder for the invalid value.
+
+
+ The field '{0}' is missing or empty.
+ {Locked="{0}"} An error in reading a configuration file. {0} is a placeholder replaced by the expected field name from the file.
+
+
+ Loading the module for the configuration unit failed because it requires administrator privileges to run.
+
+
+ A unit contains a setting that requires the config root.
+
+
+ This configuration unit was not run because an assert failed or was false.
+
\ No newline at end of file
diff --git a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ConfigurationFileViewModel.cs b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ConfigurationFileViewModel.cs
index aab509b93d..5004717478 100644
--- a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ConfigurationFileViewModel.cs
+++ b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ConfigurationFileViewModel.cs
@@ -141,13 +141,20 @@ await mainWindow.ShowErrorMessageDialogAsync(
private string GetErrorMessage(OpenConfigurationSetException exception)
{
- return exception.ResultCode?.HResult switch
+ switch (exception.ResultCode.HResult)
{
- OpenConfigurationSetException.WingetConfigErrorInvalidField =>
- StringResource.GetLocalized(StringResourceKey.ConfigurationFieldInvalid, exception.Field),
- OpenConfigurationSetException.WingetConfigErrorUnknownConfigurationFileVersion =>
- StringResource.GetLocalized(StringResourceKey.ConfigurationFileVersionUnknown, exception.Field),
- _ => StringResource.GetLocalized(StringResourceKey.ConfigurationFileInvalid),
- };
+ case WinGetConfigurationException.WingetConfigErrorInvalidFieldType:
+ return StringResource.GetLocalized(StringResourceKey.ConfigurationFieldInvalidType, exception.Field);
+ case WinGetConfigurationException.WingetConfigErrorInvalidFieldValue:
+ return StringResource.GetLocalized(StringResourceKey.ConfigurationFieldInvalidValue, exception.Field, exception.Value);
+ case WinGetConfigurationException.WingetConfigErrorMissingField:
+ return StringResource.GetLocalized(StringResourceKey.ConfigurationFieldMissing, exception.Field);
+ case WinGetConfigurationException.WingetConfigErrorUnknownConfigurationFileVersion:
+ return StringResource.GetLocalized(StringResourceKey.ConfigurationFileVersionUnknown, exception.Value);
+ case WinGetConfigurationException.WingetConfigErrorInvalidConfigurationFile:
+ case WinGetConfigurationException.WingetConfigErrorInvalidYaml:
+ default:
+ return StringResource.GetLocalized(StringResourceKey.ConfigurationFileInvalid);
+ }
}
}
diff --git a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ConfigurationUnitResultViewModel.cs b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ConfigurationUnitResultViewModel.cs
index db8bfaeeca..4cf141010f 100644
--- a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ConfigurationUnitResultViewModel.cs
+++ b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ConfigurationUnitResultViewModel.cs
@@ -1,9 +1,10 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
-using System.Globalization;
+using DevHome.SetupFlow.Common.Exceptions;
using DevHome.SetupFlow.Models;
using DevHome.SetupFlow.Services;
+using Microsoft.Management.Configuration;
using Windows.Win32.Foundation;
namespace DevHome.SetupFlow.ViewModels;
@@ -41,19 +42,18 @@ public ConfigurationUnitResultViewModel(ISetupFlowStringResource stringResource,
private string GetApplyResult()
{
- var hresult = $"0x{_unitResult.HResult:X}";
if (IsSkipped)
{
- return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSkipped, hresult);
- }
-
- if (IsError)
- {
- return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitFailed, hresult);
+ return GetUnitSkipMessage();
+ }
+
+ if (IsError)
+ {
+ return GetUnitErrorMessage();
}
return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSuccess);
- }
+ }
private string BuildTitle()
{
@@ -73,5 +73,79 @@ private string BuildTitle()
}
return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryFull, _unitResult.Intent, _unitResult.UnitName, _unitResult.Id, _unitResult.Description);
+ }
+
+ private string GetUnitSkipMessage()
+ {
+ var resultCode = _unitResult.HResult;
+ switch (resultCode)
+ {
+ case WinGetConfigurationException.WingetConfigErrorManuallySkipped:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitManuallySkipped);
+ case WinGetConfigurationException.WingetConfigErrorDependencyUnsatisfied:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitNotRunDueToDependency);
+ case WinGetConfigurationException.WingetConfigErrorAssertionFailed:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitNotRunDueToFailedAssert);
+ }
+
+ var resultCodeHex = $"0x{resultCode:X}";
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSkipped, resultCodeHex);
+ }
+
+ private string GetUnitErrorMessage()
+ {
+ var resultCode = _unitResult.HResult;
+ switch (resultCode)
+ {
+ case WinGetConfigurationException.WingetConfigErrorDuplicateIdentifier:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitHasDuplicateIdentifier, _unitResult.Id);
+ case WinGetConfigurationException.WingetConfigErrorMissingDependency:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitHasMissingDependency, _unitResult.Details);
+ case WinGetConfigurationException.WingetConfigErrorAssertionFailed:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitAssertHadNegativeResult);
+ case WinGetConfigurationException.WinGetConfigUnitNotFound:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitNotFoundInModule);
+ case WinGetConfigurationException.WinGetConfigUnitNotFoundRepository:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitNotFound);
+ case WinGetConfigurationException.WinGetConfigUnitMultipleMatches:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitMultipleMatches);
+ case WinGetConfigurationException.WinGetConfigUnitInvokeGet:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitFailedDuringGet);
+ case WinGetConfigurationException.WinGetConfigUnitInvokeTest:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitFailedDuringTest);
+ case WinGetConfigurationException.WinGetConfigUnitInvokeSet:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitFailedDuringSet);
+ case WinGetConfigurationException.WinGetConfigUnitModuleConflict:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitModuleConflict);
+ case WinGetConfigurationException.WinGetConfigUnitImportModule:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitModuleImportFailed);
+ case WinGetConfigurationException.WinGetConfigUnitInvokeInvalidResult:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitReturnedInvalidResult);
+ case WinGetConfigurationException.WingetConfigErrorManuallySkipped:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitManuallySkipped);
+ case WinGetConfigurationException.WingetConfigErrorDependencyUnsatisfied:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitNotRunDueToDependency);
+ case WinGetConfigurationException.WinGetConfigUnitSettingConfigRoot:
+ return _stringResource.GetLocalized(StringResourceKey.WinGetConfigUnitSettingConfigRoot);
+ case WinGetConfigurationException.WinGetConfigUnitImportModuleAdmin:
+ return _stringResource.GetLocalized(StringResourceKey.WinGetConfigUnitImportModuleAdmin);
+ }
+
+ var resultCodeHex = $"0x{resultCode:X}";
+ switch (_unitResult.ResultSource)
+ {
+ case ConfigurationUnitResultSource.ConfigurationSet:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitFailedConfigSet, resultCodeHex);
+ case ConfigurationUnitResultSource.Internal:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitFailedInternal, resultCodeHex);
+ case ConfigurationUnitResultSource.Precondition:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitFailedPrecondition, resultCodeHex);
+ case ConfigurationUnitResultSource.SystemState:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitFailedSystemState, resultCodeHex);
+ case ConfigurationUnitResultSource.UnitProcessing:
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitFailedUnitProcessing, resultCodeHex);
+ }
+
+ return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitFailed, resultCodeHex);
}
}