Make sure the assembly/library resolvers are registered at early stage (#21361)

This commit is contained in:
Dongbo Wang
2024-03-21 16:25:12 -07:00
committed by GitHub
parent a332481d7e
commit ad7278bbff
4 changed files with 56 additions and 7 deletions
@@ -0,0 +1,13 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Describe "Assembly resolvers should be registered early at startup" -Tags "CI" {
## The PKI module requires loading an assembly from GAC, and thus depends on the PowerShell assembly resolver to work.
It "Can load the PKI module with 'pwsh -ExecutionPolicy bypass -NoProfile -c `"Import-Module PKI`"'" -Skip:(!$IsWindows) {
## Use 'Bypass' execution policy so that it doesn't trigger 'AuthorizationManager' which would trigger 'ClrFacade' initialization.
## We want to make sure even if 'ClrFacade' is not hit during startup, the resolvers are still registered early enough.
$out = pwsh -ExecutionPolicy bypass -NoProfile -c "Import-Module PKI; Get-Module | % name"
$out | Should -BeExactly "PKI"
}
}