X Tutup
The Wayback Machine - https://web.archive.org/web/20250428225207/https://github.com/PowerShell/PowerShell/pull/24265
Skip to content

Fix how processor arch is validated in Import-Module #24265

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

Merged
merged 2 commits into from
Sep 10, 2024

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Sep 9, 2024

PR Summary

In .NET 9, the deprecated call to AssemblyName.ProcessorArchitecture returns MSIL so this causes the module manifest ProcessorArchitecture keyword to fail (unless it specifies MSIL. Change is to use the current process architecture, however, this is a different enum, so we have to do direct comparisons. The module manifest limits what ProcessorArchitecture values are allowed, so we only need to check those.

This is a regression from 7.4

PR Context

Fix #24225

PR Checklist

@daxian-dbw daxian-dbw added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Sep 9, 2024
@iSazonov
Copy link
Collaborator

Can you please explain the purpose of this parameter in the manifest?
In my understanding of how this code works, this parameter is intended only to tell the user that the module will not work on his system.
The fact is that the parameter is formal and subjective. In other words, the author must specify the value, although the actual value is in the assembly metadata. Then the question arises why should we check a dummy value from the manifest (which may even contradict the actual one) when we could check the actual value from metadata? There is a universal rule "check the features at run time". I think we should rely on this rule. Over time, the number of supported architectures may increase (in addition, there may be dependencies on the type and version of the OS).
So my suggestion is:

  1. ignore this parameter in the manifest
  2. GetManifest should show the value from assembly metadata
  3. Test-Manifest should compare the current architecture and the value from assembly metadata

@SteveL-MSFT
Copy link
Member Author

SteveL-MSFT commented Sep 10, 2024

@iSazonov those are good questions, but outside the scope of this fix. This PR is simply fixing a regression that prevents existing modules from importing because the declared required processor architecture doesn't match what PowerShell thinks it's currently running as the existing code always returns MSIL from the .NET deprecated API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BackPort-7.5.x-Done CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ProcessorArchitecture module requirement regression or intended change in 7.5.0-preview.4?
4 participants
X Tutup