-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Microsoft.WinGet.Client to run in any PowerShell session runnin…
…g as system (#3816) This PR adds support for running the Microsoft.WinGet.Client module in system context without the need to start pwsh.exe -MTA. Running as MTA is required using inproc Microsoft.Management.Deployment. If the module is running inproc and the current thread is not an MTA, it will create a new MTA thread and execute there. Otherwise, non inproc or already an MTA will use the current thread. This was done by sharing AsyncCommand (renamed to PowerShellCmdlet) from Microsoft.WinGet.Configuration. Originally, I wanted to create a new shared lib, but decided to just share the files between the projects. All cmdlets must inherit from PowerShellCmdlet. All cmdlets that use Microsoft.Management.Deployment must inherit ManagementDeploymentCommand and use Execute at the command engine entry point. As a safe mechanism, if any call to PackageManagerWrapper will verify the thread is not an STA if running inproc and fail. I verified the cmdlets work in system context locally. A future PR will add running our pester tests using psexe.exe
- Loading branch information
1 parent
28a3073
commit 09c8771
Showing
59 changed files
with
618 additions
and
439 deletions.
There are no files selected for viewing
337 changes: 198 additions & 139 deletions
337
...iguration.Engine/Commands/AsyncCommand.cs → ...owerShell/CommonFiles/PowerShellCmdlet.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// ----------------------------------------------------------------------------- | ||
// <copyright file="StreamType.cs" company="Microsoft Corporation"> | ||
// Copyright (c) Microsoft Corporation. Licensed under the MIT License. | ||
// </copyright> | ||
// ----------------------------------------------------------------------------- | ||
|
||
namespace Microsoft.WinGet.Common.Command | ||
{ | ||
/// <summary> | ||
/// The write stream type of the cmdlet. | ||
/// </summary> | ||
public enum StreamType | ||
{ | ||
/// <summary> | ||
/// Debug. | ||
/// </summary> | ||
Debug, | ||
|
||
/// <summary> | ||
/// Verbose. | ||
/// </summary> | ||
Verbose, | ||
|
||
/// <summary> | ||
/// Warning. | ||
/// </summary> | ||
Warning, | ||
|
||
/// <summary> | ||
/// Error. | ||
/// </summary> | ||
Error, | ||
|
||
/// <summary> | ||
/// Progress. | ||
/// </summary> | ||
Progress, | ||
|
||
/// <summary> | ||
/// Object. | ||
/// </summary> | ||
Object, | ||
|
||
/// <summary> | ||
/// Information. | ||
/// </summary> | ||
Information, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.