Skip to content

Commit 7ce30d0

Browse files
committed
test msdocs
1 parent 1c2431c commit 7ce30d0

File tree

1 file changed

+33
-66
lines changed

1 file changed

+33
-66
lines changed

.github/workflows/test-windows.yml

Lines changed: 33 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -24,91 +24,58 @@ jobs:
2424
- name: Add local NuGet repository
2525
run: dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Yubico/index.json"
2626

27-
- name: Build Yubico.Core
28-
run: dotnet build Yubico.NET.SDK.sln --configuration Debug
29-
30-
- name: Disable Strong Name Verification
27+
- name: Configure Strong Name Bypass (According to Microsoft Docs)
3128
run: |
32-
# Find all Yubico assemblies and disable SN verification for all of them
33-
# First, find the sn.exe tool
34-
$snExe = $null
35-
$possiblePaths = @(
36-
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\x64\sn.exe",
37-
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\sn.exe"
38-
)
39-
40-
foreach ($path in $possiblePaths) {
41-
if (Test-Path $path) {
42-
$snExe = $path
43-
Write-Host "Found sn.exe at $snExe"
44-
break
45-
}
46-
}
47-
48-
if ($null -eq $snExe) {
49-
Write-Host "sn.exe not found in common locations, will try using the PATH"
50-
$snExe = "sn.exe"
51-
}
52-
53-
# Disable verification for all Yubico assemblies by their PublicKeyToken
54-
Write-Host "Disabling strong name verification for all assemblies"
55-
& $snExe -Vr *,fdb9ca4403bc032c
56-
& $snExe -Vr *
57-
58-
# Also disable specific assemblies explicitly
59-
$assembliesToDisable = @(
60-
"Yubico.Core",
61-
"Yubico.YubiKey"
62-
)
29+
# According to the docs, we need to ensure the bypass feature is ENABLED
30+
# Create or update the registry key to enable strong name bypass (value 1)
31+
Write-Host "Enabling strong name bypass feature according to official Microsoft documentation..."
6332
64-
foreach ($assembly in $assembliesToDisable) {
65-
Write-Host "Disabling strong name verification for $assembly"
66-
& $snExe -Vr "$assembly,fdb9ca4403bc032c"
67-
}
33+
# For 64-bit systems (GitHub runners are 64-bit)
34+
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\.NETFramework" -Name "AllowStrongNameBypass" -Value 1 -PropertyType DWORD -Force
35+
New-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework" -Name "AllowStrongNameBypass" -Value 1 -PropertyType DWORD -Force
6836
69-
# Use the registry approach as well (belt and suspenders)
70-
$registryPaths = @(
71-
"HKLM:\SOFTWARE\Microsoft\StrongName\Verification",
72-
"HKLM:\SOFTWARE\Wow6432Node\Microsoft\StrongName\Verification"
73-
)
37+
Write-Host "Registry keys set to ENABLE strong name bypass"
7438
75-
foreach ($regPath in $registryPaths) {
76-
foreach ($assembly in $assembliesToDisable) {
77-
$keyPath = "$regPath\$assembly,fdb9ca4403bc032c"
78-
if (-not (Test-Path $keyPath)) {
79-
Write-Host "Creating registry key $keyPath"
80-
New-Item -Path $keyPath -Force | Out-Null
81-
}
82-
}
83-
}
84-
85-
# Check if verification is disabled
86-
Write-Host "Checking verification settings:"
87-
& $snExe -Vl
39+
# Also create application config file for the test assembly
40+
$configPath = "Yubico.Core/tests/integration/app.config"
41+
$configContent = @"
42+
<?xml version="1.0" encoding="utf-8" ?>
43+
<configuration>
44+
<runtime>
45+
<bypassTrustedAppStrongNames enabled="true" />
46+
</runtime>
47+
</configuration>
48+
"@
49+
Set-Content -Path $configPath -Value $configContent
50+
Write-Host "Created app.config file to enable strong name bypass for the test project"
8851
shell: pwsh
52+
53+
- name: Build Yubico.Core
54+
run: dotnet build Yubico.NET.SDK.sln --configuration Debug
8955

9056
- name: Test Yubico.Core Integration Tests (NET47)
9157
run: |
92-
# Set environment variables for this specific run
93-
$env:COMPLUS_DISABLESTRICTVERIFICATION=1
94-
$env:COMPLUS_DISABLESTRONGNAMEVERIFICATION=1
58+
# Set the environment variable for the current process
59+
$env:COMPLUS_EnableBypassTrustedAppStrongNames=1
9560
96-
# Run the test with elevated permissions if possible
97-
dotnet test Yubico.Core/tests/integration/Yubico.Core.IntegrationTests.csproj -f net47 --logger trx --settings coverlet.runsettings.xml --collect:"XPlat Code Coverage"
61+
# Run with explicit Debug configuration
62+
dotnet test Yubico.Core/tests/integration/Yubico.Core.IntegrationTests.csproj -f net47 --configuration Debug --logger trx --settings coverlet.runsettings.xml --collect:"XPlat Code Coverage"
9863
shell: pwsh
99-
64+
10065
- name: Test Yubico.YubiKey
10166
run: dotnet test Yubico.YubiKey/tests/unit/Yubico.YubiKey.UnitTests.csproj --logger trx --settings coverlet.runsettings.xml --collect:"XPlat Code Coverage"
102-
67+
10368
- name: Test Yubico.Core
10469
run: dotnet test Yubico.Core/tests/unit/Yubico.Core.UnitTests.csproj --logger trx --settings coverlet.runsettings.xml --collect:"XPlat Code Coverage"
105-
70+
10671
- name: Test Yubico.Core Integration tests (NET6)
10772
run: dotnet test Yubico.Core/tests/integration/Yubico.Core.IntegrationTests.csproj -f net6.0 --logger trx --settings coverlet.runsettings.xml --collect:"XPlat Code Coverage"
108-
73+
10974
- name: Test Yubico.Core Integration tests (NET8)
11075
run: dotnet test Yubico.Core/tests/integration/Yubico.Core.IntegrationTests.csproj -f net8.0 --logger trx --settings coverlet.runsettings.xml --collect:"XPlat Code Coverage"
76+
11177

78+
11279
- name: Upload Test Result Files
11380
uses: actions/upload-artifact@v4
11481
with:

0 commit comments

Comments
 (0)