Skip to content

Commit

Permalink
add workaround for appx on server 2025/psrp
Browse files Browse the repository at this point in the history
  • Loading branch information
jborean93 committed Nov 10, 2024
1 parent e2574be commit a987488
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ stages:
test: 2022/psrp/https
- name: 2022 SSH Key
test: 2022/ssh/key
- name: 2025 PSRP HTTPS
test: 2025/psrp/https
- name: 2025 PSRP HTTP
test: 2025/psrp/http
- name: 2025 SSH Key
test: 2025/ssh/key
- stage: Windows_2
Expand All @@ -150,8 +150,8 @@ stages:
test: 2022/psrp/https
- name: 2022 SSH Key
test: 2022/ssh/key
- name: 2025 PSRP HTTPS
test: 2025/psrp/https
- name: 2025 PSRP HTTP
test: 2025/psrp/http
- name: 2025 SSH Key
test: 2025/ssh/key
- stage: Windows_3
Expand All @@ -173,8 +173,8 @@ stages:
test: 2022/psrp/https
- name: 2022 SSH Key
test: 2022/ssh/key
- name: 2025 PSRP HTTPS
test: 2025/psrp/https
- name: 2025 PSRP HTTP
test: 2025/psrp/http
- name: 2025 SSH Key
test: 2025/ssh/key
- stage: Summary
Expand Down
37 changes: 37 additions & 0 deletions tests/integration/targets/win_package/library/prereq_setup.ps1
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()
3 changes: 3 additions & 0 deletions tests/integration/targets/win_package/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
path: '{{ test_path }}'
state: directory

- name: setup 2025 pre-reqs for testing over PSRP
prereq_setup:

# Some of the registry_tests.yml create a badly formed unisntall string so remove the reg entry in case the test
# didn't get to cleaning itself up
- name: remove registry package path
Expand Down

0 comments on commit a987488

Please sign in to comment.