Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start Microsoft.WinGet.Configuration module #3187

Merged
merged 2 commits into from
Apr 27, 2023

Conversation

msftrubengu
Copy link
Contributor

@msftrubengu msftrubengu commented Apr 25, 2023

This PR sets the foundation for the new PowerShell module Microsoft.WinGet.Configuration which is going to be an equivalent of winget configure

The module is going to be built as a binary module and it supports using its own ACL to load dependencies. The Microsoft.WinGet.Configuration.Cmdlets project will contain all the cmdlet entry points and Microsoft.WinGet.Configuration.Engine the actual logic.

This module consumes Microsoft.Management.Configuration which uses cswinrt and requires being run on an MTA. This is achieved via MtaCommand.cs. This class contains functions that will verify if the current thread is already running on an MTA (via pwsh.exe -MTA) and if not start a new MTA thread. Every command that consumes winrt objects must implement it.

MtaCommand.cs also implements methods to handle waiting for asynchronous calls and allows sending messages to the PowerShell host that are required to be executed in the main thread (only WriteDebug is implemented for now, but any other method follows the same approach). This is based on the async mechanism that azure-powershell uses.

This PR includes Invoke-WinGetConfiguration but is just a proof-of-concept cmdlet and should not be taken seriously.

The next PR will be all the changes in the configuration processor to enable ConfigurationProcessorType.Default

Microsoft Reviewers: Open in CodeFlow

@github-actions

This comment has been minimized.

@msftrubengu msftrubengu marked this pull request as ready for review April 26, 2023 16:57
@msftrubengu msftrubengu requested a review from a team as a code owner April 26, 2023 16:57
/// Invoke-WinGetConfiguration.
/// Start configuration and waits for completion.
/// </summary>
[Cmdlet(VerbsLifecycle.Invoke, "WinGetConfiguration")]
Copy link
Member

Choose a reason for hiding this comment

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

I would really suggest starting with Start and Complete so that you don't do things you have to untangle by only implementing Invoke.

[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true)]
public string File { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

There should be a Get-WinGetConfiguration command that is the primary method to open a file and other commands should be taking in a file path only as a convenience. Given that there might be an arbitrary number of mechanisms to load a configuration set, maybe we even force it to be loaded with the Get.

@msftrubengu msftrubengu merged commit 84d3e87 into microsoft:master Apr 27, 2023
@g0t4
Copy link

g0t4 commented Jun 4, 2023

About a week ago I stumbled on the Microsoft.WinGet.Client & Microsoft.WinGet.Dsc modules. I immediately incorporated them into my own machine init scripts. Work like a charm. I'm looking forward to what you're doing here with winget configure and DevHome... keep up the great work!

Are you looking for feedback on this Configuration module?

@denelon
Copy link
Contributor

denelon commented Jun 5, 2023

@g0t4 yes, we're always looking for feedback. Package Management is complex to begin with, and adding configuration management is probably an order of magnitude more complex. Feel free to create issues or discussions. We're always looking for user scenarios that either aren't covered, or where the behavior isn't quite right.

@msftrubengu msftrubengu deleted the config_module_skeleton branch August 14, 2023 22:27
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.

None yet

4 participants