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

Microsoft.WinGet.Client Any CPU #3622

Merged
merged 14 commits into from
Oct 24, 2023
Merged

Conversation

msftrubengu
Copy link
Contributor

@msftrubengu msftrubengu commented Sep 14, 2023

Move to Any CPU projects

Moves Microsoft.WinGet.Client.Cmdlet and Microsoft.WinGet.Client.Engine to be Any CPU platform binaries. This is in preparation of PSResourceGet (aka PowerShellGet v3) release and addresses #3501 as $env:PROCESSOR_ARCHITECTURE is not an allowed variable in a psd1.

Handle server disconnection

Before, we had a static PackageManager object for OOP calls. In the scenario where winget is upgraded, this object will be disconnected, and one would have to close its PowerShell 7 session and open a new one to keep using the cmdlets. This PR creates a wrapper that handles disconnections.

Windows PowerShell support

Correctly throw NotSupported exception for cmdlets that use winget's COM APIs. For this I had to track down all the types being loaded per command and make sure they get loaded after the constructor of each one. This resulted in some weird cases that I need to pass a string instead of an enum in the virtual methods of some base classes.
Fix issue where Microsoft.Win32.Registry.dll was missing.
Add Pester tests specifically for Windows PowerShell

Expected Layout

Microsoft.WinGet.Client\
	Format.ps1xml
	Microsoft.WinGet.Client.psd1
	net48\
		Microsoft.Win32.Registry.dll
		Microsoft.WinGet.Client.Cmdlets.dll
		Microsoft.WinGet.Client.Engine.dll
		Microsoft.WinGet.SharedLib.dll
		Newtonsoft.Json.dll
		Octokit.dll
	net6.0-windows10.0.22000.0\
		Microsoft.WinGet.Client.Cmdlets.dll
		DirectDependencies\
			Microsoft.WinGet.Client.Engine.dll
		SharedDependencies\
			Microsoft.Windows.SDK.NET.dll
			Microsoft.WinGet.SharedLib.dll
			Newtonsoft.Json.dll
			Octokit.dll
			WinRT.Runtime.dll
			x64\
				Microsoft.Management.Deployment.dll
				Microsoft.Management.Deployment.winmd
				WindowsPackageManager.dll
				winrtact.dll
			x86\
				Microsoft.Management.Deployment.dll
				Microsoft.Management.Deployment.winmd
				WindowsPackageManager.dll
				winrtact.dll

I didn't add the native binaries in the Windows PowerShell because they will never be loaded.

Additional changes:

  • Remove unnecessary AnyCpu build in AppInstallerCLI.sln
  • Fully remove Microsoft.WinGet.Client tests from AppInstallerCLIE2ETests in favor of Pester tests.
  • Improve Initialize-LocalWinGetModules.ps1 for local development. You can now specify which module to initialize.
Microsoft Reviewers: Open in CodeFlow

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@msftrubengu msftrubengu marked this pull request as ready for review September 20, 2023 01:30
@msftrubengu msftrubengu requested a review from a team as a code owner September 20, 2023 01:30
@msftrubengu
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ryfu-msft
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@msftrubengu msftrubengu merged commit a10f1ab into microsoft:master Oct 24, 2023
8 checks passed
JohnMcPMS pushed a commit to JohnMcPMS/winget-cli that referenced this pull request Nov 8, 2023
Move to Any CPU projects
Moves Microsoft.WinGet.Client.Cmdlet and Microsoft.WinGet.Client.Engine to be Any CPU platform binaries. This is in preparation of PSResourceGet (aka PowerShellGet v3) release and addresses microsoft#3501 as $env:PROCESSOR_ARCHITECTURE is not an allowed variable in a psd1.

Handle server disconnection
Before, we had a static PackageManager object for OOP calls. In the scenario where winget is upgraded, this object will be disconnected, and one would have to close its PowerShell 7 session and open a new one to keep using the cmdlets. This PR creates a wrapper that handles disconnections.

Windows PowerShell support
Correctly throw NotSupported exception for cmdlets that use winget's COM APIs. For this I had to track down all the types being loaded per command and make sure they get loaded after the constructor of each one. This resulted in some weird cases that I need to pass a string instead of an enum in the virtual methods of some base classes.
Fix issue where Microsoft.Win32.Registry.dll was missing.
Add Pester tests specifically for Windows PowerShell

Expected Layout
Microsoft.WinGet.Client\
	Format.ps1xml
	Microsoft.WinGet.Client.psd1
	net48\
		Microsoft.Win32.Registry.dll
		Microsoft.WinGet.Client.Cmdlets.dll
		Microsoft.WinGet.Client.Engine.dll
		Microsoft.WinGet.SharedLib.dll
		Newtonsoft.Json.dll
		Octokit.dll
	net6.0-windows10.0.22000.0\
		Microsoft.WinGet.Client.Cmdlets.dll
		DirectDependencies\
			Microsoft.WinGet.Client.Engine.dll
		SharedDependencies\
			Microsoft.Windows.SDK.NET.dll
			Microsoft.WinGet.SharedLib.dll
			Newtonsoft.Json.dll
			Octokit.dll
			WinRT.Runtime.dll
			x64\
				Microsoft.Management.Deployment.dll
				Microsoft.Management.Deployment.winmd
				WindowsPackageManager.dll
				winrtact.dll
			x86\
				Microsoft.Management.Deployment.dll
				Microsoft.Management.Deployment.winmd
				WindowsPackageManager.dll
				winrtact.dll
I didn't add the native binaries in the Windows PowerShell because they will never be loaded.

Additional changes:

Remove unnecessary AnyCpu build in AppInstallerCLI.sln
Fully remove Microsoft.WinGet.Client tests from AppInstallerCLIE2ETests in favor of Pester tests.
Improve Initialize-LocalWinGetModules.ps1 for local development. You can now specify which module to initialize.
@msftrubengu msftrubengu deleted the anycpu branch November 14, 2023 00:31
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.

3 participants