From b074e2c29a2ae11733de2348d94a8e52c2b198e7 Mon Sep 17 00:00:00 2001
From: Medeni Baykal <433724+Haplois@users.noreply.github.com>
Date: Thu, 19 Nov 2020 17:05:52 +0100
Subject: [PATCH] Assembly load fixes (#2644)
* Cherry-picked signing and assembly load fixes from `master`
---
scripts/build.ps1 | 7 +++--
scripts/verify-nupkgs.ps1 | 2 +-
scripts/verify-sign.ps1 | 26 ++++++++++++++-----
...rosoft.TestPlatform.TestHost.NetCore.props | 17 ++++++++++++
.../nuspec/TestPlatform.TestHost.nuspec | 21 +++++++--------
src/package/sign/sign.proj | 2 ++
6 files changed, 54 insertions(+), 21 deletions(-)
diff --git a/scripts/build.ps1 b/scripts/build.ps1
index 5379bc0284..ed67487c38 100644
--- a/scripts/build.ps1
+++ b/scripts/build.ps1
@@ -354,14 +354,17 @@ function Publish-Package
# Copy the .NET core x86 and x64 testhost exes from tempPublish to required folder
New-Item -ItemType directory -Path $testhostCorePackageX64Dir -Force | Out-Null
Copy-Item $testhostCorePackageTempX64Dir\testhost* $testhostCorePackageX64Dir -Force -recurse
+ Copy-Item $testhostCorePackageTempX64Dir\Microsoft.TestPlatform.PlatformAbstractions.dll $testhostCorePackageX64Dir -Force
+
New-Item -ItemType directory -Path $testhostCorePackageX86Dir -Force | Out-Null
Copy-Item $testhostCorePackageTempX86Dir\testhost.x86* $testhostCorePackageX86Dir -Force -recurse
+ Copy-Item $testhostCorePackageTempX86Dir\Microsoft.TestPlatform.PlatformAbstractions.dll $testhostCorePackageX86Dir -Force
# Copy over the Full CLR built testhost package assemblies to the Core CLR and Full CLR package folder.
$coreCLRFull_Dir = "TestHost"
$fullDestDir = Join-Path $coreCLR20PackageDir $coreCLRFull_Dir
New-Item -ItemType directory -Path $fullDestDir -Force | Out-Null
- Copy-Item $testhostFullPackageDir\* $fullDestDir -Force -recurse
+ Copy-Item $testhostFullPackageDir\* $fullDestDir -Force -Recurse
Set-ScriptFailedOnError
@@ -369,7 +372,7 @@ function Publish-Package
Publish-PackageInternal $dataCollectorProject $TPB_TargetFramework472 $fullDestDir
New-Item -ItemType directory -Path $fullCLRPackageDir -Force | Out-Null
- Copy-Item $testhostFullPackageDir\* $fullCLRPackageDir -Force -recurse
+ Copy-Item $testhostFullPackageDir\* $fullCLRPackageDir -Force -Recurse
Set-ScriptFailedOnError
diff --git a/scripts/verify-nupkgs.ps1 b/scripts/verify-nupkgs.ps1
index ca4fe4fbf0..9735d4e3f8 100644
--- a/scripts/verify-nupkgs.ps1
+++ b/scripts/verify-nupkgs.ps1
@@ -21,7 +21,7 @@ function Verify-Nuget-Packages($packageDirectory)
"Microsoft.TestPlatform.Extensions.TrxLogger" = 33;
"Microsoft.TestPlatform.ObjectModel" = 62;
"Microsoft.TestPlatform.Portable" = 566;
- "Microsoft.TestPlatform.TestHost" = 145;
+ "Microsoft.TestPlatform.TestHost" = 154;
"Microsoft.TestPlatform.TranslationLayer" = 121}
$nugetPackages = Get-ChildItem -Filter "*.nupkg" $packageDirectory | % { $_.FullName}
diff --git a/scripts/verify-sign.ps1 b/scripts/verify-sign.ps1
index f3c36833ef..e435cd06f5 100644
--- a/scripts/verify-sign.ps1
+++ b/scripts/verify-sign.ps1
@@ -45,6 +45,9 @@ function Verify-Assemblies
if ($signature.SignerCertificate.Subject -eq "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US") {
Write-Log "Valid: $($_.FullName)"
}
+ elseif ($signature.SignerCertificate.Subject -eq "CN=Microsoft 3rd Party Application Component, O=Microsoft Corporation, L=Redmond, S=Washington, C=US") {
+ Write-Log "Valid (3rd Party): $($_.FullName)"
+ }
else {
# For legacy components, sign certificate is always "prod" signature. Skip such binaries.
if ($signature.SignerCertificate.Thumbprint -eq "98ED99A67886D020C564923B7DF25E9AC019DF26") {
@@ -54,15 +57,15 @@ function Verify-Assemblies
elseif ($signature.SignerCertificate.Thumbprint -eq "5EAD300DC7E4D637948ECB0ED829A072BD152E17") {
Write-Log "Valid (Prod Signed): $($_.FullName)."
}
- # For some dlls e.g. "Interop.UIAutomationClient.dll", sign certificate is different signature. Skip such binaries.
+ # For some dlls e.g. "Interop.UIAutomationClient.dll", sign certificate is different signature. Skip such binaries.
elseif ($signature.SignerCertificate.Thumbprint -eq "67B1757863E3EFF760EA9EBB02849AF07D3A8080") {
Write-Log "Valid (Prod Signed): $($_.FullName)."
}
- # For some dlls e.g. "Microsoft.VisualStudio.ArchitectureTools.PEReader.dll", sign certificate is different signature. Skip such binaries.
+ # For some dlls e.g. "Microsoft.VisualStudio.ArchitectureTools.PEReader.dll", sign certificate is different signature. Skip such binaries.
elseif ($signature.SignerCertificate.Thumbprint -eq "9DC17888B5CFAD98B3CB35C1994E96227F061675") {
Write-Log "Valid (Prod Signed): $($_.FullName)."
}
- # For some dlls sign certificate is different signature. Skip such binaries.
+ # For some dlls sign certificate is different signature. Skip such binaries.
elseif ($signature.SignerCertificate.Thumbprint -eq "62009AAABDAE749FD47D19150958329BF6FF4B34") {
Write-Log "Valid (Prod Signed): $($_.FullName)."
}
@@ -70,6 +73,14 @@ function Verify-Assemblies
elseif ($signature.SignerCertificate.Thumbprint -eq "899FA016DEE8E665FF2A315A1151C43FB96C430B") {
Write-Log "Valid (Prod Signed): $($_.FullName)."
}
+ # Microsoft 3rd Party Application Component
+ elseif ($signature.SignerCertificate.Thumbprint -eq "709133ECC53CBF386F4A5ECB782AEEF499F0F8CA") {
+ Write-Log "Valid (Prod Signed): $($_.FullName)."
+ }
+ # Microsoft 3rd Party Application Component
+ elseif ($signature.SignerCertificate.Thumbprint -eq "912357a68d29b8fe17168ef8c44d6830d1d42801") {
+ Write-Log "Valid (Prod Signed): $($_.FullName)."
+ }
else {
Write-FailLog "Incorrect certificate. File: $($_.FullName). Certificate: $($signature.SignerCertificate.Thumbprint)."
}
@@ -99,12 +110,13 @@ function Verify-NugetPackages
Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/v4.6.1/nuget.exe -OutFile $nugetInstallPath
}
- Write-Log "Using nuget.exe installed at $nugetInstallPath"
+ Write-Log "Using nuget.exe installed at $nugetInstallPath"
- $artifactsDirectory = Join-Path $env:TP_OUT_DIR $TPB_Configuration
+ $artifactsDirectory = Join-Path $env:TP_OUT_DIR $TPB_Configuration
$packagesDirectory = Join-Path $artifactsDirectory "packages"
+
Get-ChildItem -Filter *.nupkg $packagesDirectory | % {
- & $nugetInstallPath verify -signature -CertificateFingerprint 3F9001EA83C560D712C24CF213C3D312CB3BFF51EE89435D3430BD06B5D0EECE $_.FullName
+ & $nugetInstallPath verify -signature -CertificateFingerprint "3F9001EA83C560D712C24CF213C3D312CB3BFF51EE89435D3430BD06B5D0EECE;AA12DA22A49BCE7D5C1AE64CC1F3D892F150DA76140F210ABD2CBFFCA2C18A27;" $_.FullName
}
Write-Log "Verify-NugetPackages: Complete"
@@ -130,4 +142,4 @@ function Write-FailLog ([string] $message)
}
Verify-Assemblies
-Verify-NugetPackages
+Verify-NugetPackages
\ No newline at end of file
diff --git a/src/package/nuspec/Microsoft.TestPlatform.TestHost.NetCore.props b/src/package/nuspec/Microsoft.TestPlatform.TestHost.NetCore.props
index b57ffe1287..7dd28d882f 100644
--- a/src/package/nuspec/Microsoft.TestPlatform.TestHost.NetCore.props
+++ b/src/package/nuspec/Microsoft.TestPlatform.TestHost.NetCore.props
@@ -11,6 +11,11 @@
PreserveNewest
False
+
+ Microsoft.TestPlatform.PlatformAbstractions.dll
+ PreserveNewest
+ False
+
@@ -23,5 +28,17 @@
PreserveNewest
False
+
+ Microsoft.TestPlatform.PlatformAbstractions.dll
+ PreserveNewest
+ False
+
+
+
+
+ Microsoft.TestPlatform.PlatformAbstractions.dll
+ PreserveNewest
+ False
+
\ No newline at end of file
diff --git a/src/package/nuspec/TestPlatform.TestHost.nuspec b/src/package/nuspec/TestPlatform.TestHost.nuspec
index d2f1343ff5..89947ccf1e 100644
--- a/src/package/nuspec/TestPlatform.TestHost.nuspec
+++ b/src/package/nuspec/TestPlatform.TestHost.nuspec
@@ -32,29 +32,28 @@
-
-
-
-
-
+
+
+
-
-
+
+
+
+
+
-
-
-
-
+
+
diff --git a/src/package/sign/sign.proj b/src/package/sign/sign.proj
index 8452eb0d48..43c91cf0f3 100644
--- a/src/package/sign/sign.proj
+++ b/src/package/sign/sign.proj
@@ -345,8 +345,10 @@
+
+