@@ -1255,7 +1255,7 @@ namespace AppInstaller::CLI::Workflow
12551255 return unit;
12561256 }
12571257
1258- ValueSet CreateValueSetFromStringArray (const std::vector<std::wstring>& values)
1258+ ValueSet CreateValueSetFromStringVector (const std::vector<std::wstring>& values)
12591259 {
12601260 ValueSet result;
12611261 size_t index = 0 ;
@@ -1287,7 +1287,7 @@ namespace AppInstaller::CLI::Workflow
12871287 L" -Command" ,
12881288 L" if (-not (Get-Module -ListAvailable -Name " + moduleNameString + L" )) { Install-Module -Name " + moduleNameString + L" -Confirm:$False -Force -AllowPrerelease -AllowClobber }"
12891289 };
1290- settings.Insert (L" arguments" , CreateValueSetFromStringArray (arguments));
1290+ settings.Insert (L" arguments" , CreateValueSetFromStringVector (arguments));
12911291 unit.Settings (settings);
12921292
12931293 unit.Dependencies ().Append (dependentUnit.Identifier ());
@@ -1574,22 +1574,18 @@ namespace AppInstaller::CLI::Workflow
15741574 {
15751575 ConfigurationContext& configContext = context.Get <Data::ConfigurationContext>();
15761576
1577- // PowerShell package needs to be present for later certain predefined modules to work.
1578- std::optional<ConfigurationUnit> powerShellPackageUnit = CreatePowerShellPackageUnit ();
1577+ // PowerShell package needs to be present for certain predefined modules to work.
1578+ ConfigurationUnit powerShellPackageUnit = CreatePowerShellPackageUnit ();
1579+ configContext.Set ().Units ().Append (powerShellPackageUnit);
15791580
15801581 // Apply the unit to make sure it's on the system.
1581- context.Reporter .Info () << Resource::String::ConfigurationExportInstallRequiredModule (Utility::LocIndView{ " Microsoft PowerShell" }) << std::endl;
1582- auto applyPowerShellResult = ApplyUnit (context, powerShellPackageUnit. value () );
1583- if (SUCCEEDED (applyPowerShellResult.ResultInformation ().ResultCode ()))
1582+ context.Reporter .Info () << Resource::String::ConfigurationExportInstallRequiredModule (Utility::LocIndView{ " Microsoft PowerShell Package " }) << std::endl;
1583+ auto applyPowerShellResult = ApplyUnit (context, powerShellPackageUnit);
1584+ if (FAILED (applyPowerShellResult.ResultInformation ().ResultCode ()))
15841585 {
1585- configContext.Set ().Units ().Append (powerShellPackageUnit.value ());
1586- }
1587- else
1588- {
1589- AICLI_LOG (Config, Warning, << " Failed to ensure module. [Microsoft PowerShell] Related settings will not be exported." );
1590- LogFailedGetConfigurationUnitDetails (powerShellPackageUnit.value (), applyPowerShellResult.ResultInformation ());
1586+ AICLI_LOG (Config, Warning, << " Failed to ensure module. [Microsoft PowerShell Package] Related settings may not be exported." );
1587+ LogFailedGetConfigurationUnitDetails (powerShellPackageUnit, applyPowerShellResult.ResultInformation ());
15911588 context.Reporter .Warn () << Resource::String::ConfigurationExportInstallRequiredModuleFailed << std::endl;
1592- powerShellPackageUnit = std::nullopt ;
15931589 }
15941590
15951591 for (const auto & resources : PredefinedResourcesForExport ())
@@ -1598,13 +1594,7 @@ namespace AppInstaller::CLI::Workflow
15981594
15991595 if (!resources.RequiredModule .empty ())
16001596 {
1601- if (!powerShellPackageUnit)
1602- {
1603- // PowerShell package not present, skip.
1604- continue ;
1605- }
1606-
1607- requiredModuleUnit = CreateRequiredModuleUnit (resources.RequiredModule , powerShellPackageUnit.value ());
1597+ requiredModuleUnit = CreateRequiredModuleUnit (resources.RequiredModule , powerShellPackageUnit);
16081598
16091599 // Apply the unit to make sure it's on the system.
16101600 context.Reporter .Info () << Resource::String::ConfigurationExportInstallRequiredModule (Utility::LocIndView{ Utility::ConvertToUTF8 (resources.RequiredModule ) }) << std::endl;
0 commit comments