mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
This commit is contained in:
@@ -16,6 +16,7 @@ using System.Management.Automation.Language;
|
||||
using System.Management.Automation.Runspaces;
|
||||
using System.Management.Automation.Security;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Diagnostics;
|
||||
@@ -1920,11 +1921,12 @@ namespace Microsoft.PowerShell.Commands
|
||||
else if ((requiredProcessorArchitecture != ProcessorArchitecture.None) &&
|
||||
(requiredProcessorArchitecture != ProcessorArchitecture.MSIL))
|
||||
{
|
||||
#pragma warning disable SYSLIB0037
|
||||
ProcessorArchitecture currentArchitecture = typeof(object).Assembly.GetName().ProcessorArchitecture;
|
||||
#pragma warning restore SYSLIB0037
|
||||
Architecture currentArchitecture = RuntimeInformation.ProcessArchitecture;
|
||||
|
||||
if (currentArchitecture != requiredProcessorArchitecture)
|
||||
if ((requiredProcessorArchitecture == ProcessorArchitecture.X86 && currentArchitecture != Architecture.X86) ||
|
||||
(requiredProcessorArchitecture == ProcessorArchitecture.Amd64 && currentArchitecture != Architecture.X64) ||
|
||||
(requiredProcessorArchitecture == ProcessorArchitecture.Arm && (currentArchitecture != Architecture.Arm && currentArchitecture != Architecture.Arm64)) ||
|
||||
requiredProcessorArchitecture == ProcessorArchitecture.IA64)
|
||||
{
|
||||
containedErrors = true;
|
||||
if (writingErrors)
|
||||
|
||||
@@ -56,6 +56,18 @@ Describe "Import-Module" -Tags "CI" {
|
||||
Import-Module TestModule -RequiredVersion 1.1
|
||||
(Get-Module TestModule).Version | Should -BeIn "1.1"
|
||||
}
|
||||
|
||||
It 'ProcessorArchitecture should work' {
|
||||
$currentProcessorArchitecture = switch ([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture) {
|
||||
'X86' { 'x86' }
|
||||
'X64' { 'amd64' }
|
||||
'Arm64' { 'arm' }
|
||||
default { throw "Unknown processor architecture" }
|
||||
}
|
||||
New-ModuleManifest -Path "$TestDrive\TestModule.psd1" -ProcessorArchitecture $currentProcessorArchitecture
|
||||
$module = Import-Module -Name "$TestDrive\TestModule.psd1" -PassThru
|
||||
$module.ProcessorArchitecture | Should -Be $currentProcessorArchitecture
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Import-Module with ScriptsToProcess" -Tags "CI" {
|
||||
|
||||
Reference in New Issue
Block a user