Skip to content

Commit

Permalink
Add Arm64 to list of architectures in Module Initialization. (#4251)
Browse files Browse the repository at this point in the history
<!-- To check a checkbox place an "x" between the brackets. e.g: [x] -->

- [X] I have signed the [Contributor License
Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs).
- [X] This pull request is related to an issue.
  - Resolves: #4169
-----

This PR addresses an issue that prevents the WinGet Cmdlets from loading
in an Arm64 PowerShell 7.x environment.
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/4251)
  • Loading branch information
snickler committed Apr 22, 2024
1 parent 1d99a66 commit ab35bba
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/PowerShell/scripts/Initialize-LocalWinGetModules.ps1
Expand Up @@ -74,6 +74,7 @@ class WinGetModule
{
$x64Path = "$($this.Output)\$location\x64\"
$x86Path = "$($this.Output)\$location\x86\"
$arm64Path = "$($this.Output)\$location\arm64\"
if (-not (Test-Path $x64Path))
{
New-Item $x64Path -ItemType directory
Expand All @@ -84,20 +85,28 @@ class WinGetModule
New-Item $x86Path -ItemType directory
}

if (-not (Test-Path $arm64Path))
{
New-Item $arm64Path -ItemType directory
}

foreach ($f in $files)
{
$copyErrors = $null
Copy-Item "$buildRoot\x64\$config\$f" "$($this.Output)\$location\x64\" -Force -ErrorVariable copyErrors -ErrorAction SilentlyContinue
$copyErrors | ForEach-Object { Write-Warning $_ }
Copy-Item "$buildRoot\x86\$config\$f" "$($this.Output)\$location\x86\" -Force -ErrorVariable copyErrors -ErrorAction SilentlyContinue
$copyErrors | ForEach-Object { Write-Warning $_ }
Copy-Item "$buildRoot\arm64\$config\$f" "$($this.Output)\$location\arm64\" -Force -ErrorVariable copyErrors -ErrorAction SilentlyContinue
$copyErrors | ForEach-Object { Write-Warning $_ }
}
}

[void]AddAnyCpuSpecificFilesToArch([string[]] $files, [string]$location, [string] $buildRoot, [string] $config)
{
$x64Path = "$($this.Output)\$location\x64\"
$x86Path = "$($this.Output)\$location\x86\"
$arm64Path = "$($this.Output)\$location\arm64\"
if (-not (Test-Path $x64Path))
{
New-Item $x64Path -ItemType directory
Expand All @@ -108,13 +117,20 @@ class WinGetModule
New-Item $x86Path -ItemType directory
}

if (-not (Test-Path $arm64Path))
{
New-Item $arm64Path -ItemType directory
}

foreach ($f in $files)
{
$copyErrors = $null
Copy-Item "$buildRoot\AnyCpu\$config\$f" "$($this.Output)\$location\x64\" -Force -ErrorVariable copyErrors -ErrorAction SilentlyContinue
$copyErrors | ForEach-Object { Write-Warning $_ }
Copy-Item "$buildRoot\AnyCpu\$config\$f" "$($this.Output)\$location\x86\" -Force -ErrorVariable copyErrors -ErrorAction SilentlyContinue
$copyErrors | ForEach-Object { Write-Warning $_ }
Copy-Item "$buildRoot\AnyCpu\$config\$f" "$($this.Output)\$location\arm64\" -Force -ErrorVariable copyErrors -ErrorAction SilentlyContinue
$copyErrors | ForEach-Object { Write-Warning $_ }
}
}
}
Expand Down

0 comments on commit ab35bba

Please sign in to comment.