Skip to content

Ensure required modules for configuration export and import#5521

Merged
yao-msft merged 8 commits into
microsoft:masterfrom
yao-msft:requiredmodule2
Jun 13, 2025
Merged

Ensure required modules for configuration export and import#5521
yao-msft merged 8 commits into
microsoft:masterfrom
yao-msft:requiredmodule2

Conversation

@yao-msft
Copy link
Copy Markdown
Contributor

@yao-msft yao-msft commented Jun 12, 2025

  • Added Microsoft.PowerShell as dependent unit of other Predefined modules.
  • Use RunCommandOnSet as awork around for ensuring v2 modules before v3 resource is available
  • Also added always apply logic for certain units i.e. Microsoft.DSC.Transitional/RunCommandOnSet
  • Added and updated tests
Microsoft Reviewers: Open in CodeFlow

@github-actions

This comment was marked as resolved.


ValueSet settings;
settings.Insert(s_Setting_PowerShellGet_ModuleName, PropertyValue::CreateString(moduleName));
settings.Insert(s_Setting_WinGetPackage_Id, PropertyValue::CreateString(L"Microsoft.PowerShell"));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constants?

Also, we should consider extracting this from / filtering out of the package results.


// Apply the unit to make sure it's on the system.
context.Reporter.Info() << Resource::String::ConfigurationExportInstallRequiredModule(Utility::LocIndView{ "Microsoft PowerShell Package" }) << std::endl;
auto applyPowerShellResult = ApplyUnit(context, powerShellPackageUnit);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always apply it without testing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the wingetpackage dsc resource, it tests it (in the resource implementation) before applying. So I'm just applying it to save 2 calls.

@yao-msft yao-msft merged commit 847b449 into microsoft:master Jun 13, 2025
9 checks passed
@yao-msft yao-msft deleted the requiredmodule2 branch June 13, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants