-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add workaround for appx on server 2025/psrp
- Loading branch information
Showing
3 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
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
37 changes: 37 additions & 0 deletions
37
tests/integration/targets/win_package/library/prereq_setup.ps1
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,37 @@ | ||
#!powershell | ||
|
||
# Copyright: (c) 2024, Ansible Project | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
#AnsibleRequires -CSharpUtil Ansible.Basic | ||
|
||
|
||
$module = [Ansible.Basic.AnsibleModule]::Create($args, @{}) | ||
|
||
# Server 2025 fails to run Get-AppxPackage and other DISM module commands in | ||
# a PSRemoting (psrp) session as it has a dependency on some dll's not present | ||
# in the GAC and only in the powershell.exe directory. As PSRP runs through | ||
# wsmprovhost.exe, it fails to find those dlls. This hack will manually load | ||
# the 4 requires dlls into the GAC so our tests can work. This is a hack and | ||
# should be removed in the future if MS fix their bug on 2025. | ||
try { | ||
$null = Get-AppxPackage | ||
} | ||
catch { | ||
Add-Type -AssemblyName "System.EnterpriseServices" | ||
$publish = [System.EnterpriseServices.Internal.Publish]::new() | ||
|
||
@( | ||
'System.Numerics.Vectors.dll', | ||
'System.Runtime.CompilerServices.Unsafe.dll', | ||
'System.Security.Principal.Windows.dll', | ||
'System.Memory.dll' | ||
) | ForEach-Object { | ||
$dllPath = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\$_" | ||
$publish.GacInstall($dllPath) | ||
} | ||
|
||
$module.Result.changed = $true | ||
} | ||
|
||
$module.ExitJson() |
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