Skip to content

Commit

Permalink
Assembly load fixes (#2644)
Browse files Browse the repository at this point in the history
* Cherry-picked signing and assembly load fixes from `master`
  • Loading branch information
Haplois authored Nov 19, 2020
1 parent d6875ce commit b074e2c
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 21 deletions.
7 changes: 5 additions & 2 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -354,22 +354,25 @@ 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

# Copy over the Full CLR built datacollector package assemblies to the Core CLR package folder along with testhost
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

Expand Down
2 changes: 1 addition & 1 deletion scripts/verify-nupkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
26 changes: 19 additions & 7 deletions scripts/verify-sign.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -54,22 +57,30 @@ 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)."
}
# Microsoft 3rd Party Authenticode Signature
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)."
}
Expand Down Expand Up @@ -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"
Expand All @@ -130,4 +142,4 @@ function Write-FailLog ([string] $message)
}

Verify-Assemblies
Verify-NugetPackages
Verify-NugetPackages
17 changes: 17 additions & 0 deletions src/package/nuspec/Microsoft.TestPlatform.TestHost.NetCore.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
<Content Include="$(MSBuildThisFileDirectory)x86\Microsoft.TestPlatform.PlatformAbstractions.dll">
<Link>Microsoft.TestPlatform.PlatformAbstractions.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
<ItemGroup Condition=" ('$(Platform)'!= 'x86' AND '$(PlatformTarget)' != 'x86') AND '$(OS)' == 'Windows_NT'" >
<Content Include="$(MSBuildThisFileDirectory)x64\testhost.exe">
Expand All @@ -23,5 +28,17 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
<Content Include="$(MSBuildThisFileDirectory)x64\Microsoft.TestPlatform.PlatformAbstractions.dll">
<Link>Microsoft.TestPlatform.PlatformAbstractions.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
<ItemGroup Condition=" '$(OS)' != 'Windows_NT'" >
<Content Include="$(MSBuildThisFileDirectory)Microsoft.TestPlatform.PlatformAbstractions.dll">
<Link>Microsoft.TestPlatform.PlatformAbstractions.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
</Project>
21 changes: 10 additions & 11 deletions src/package/nuspec/TestPlatform.TestHost.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,28 @@
<file src="ThirdPartyNotices.txt" target="" />
<file src="_._" target="lib\net45\" />

<!-- NetCore -->
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\Microsoft.TestPlatform.CommunicationUtilities.dll" target="lib\netcoreapp2.1\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\Microsoft.TestPlatform.CrossPlatEngine.dll" target="lib\netcoreapp2.1\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\Microsoft.VisualStudio.TestPlatform.Common.dll" target="lib\netcoreapp2.1\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\Microsoft.TestPlatform.Utilities.dll" target="lib\netcoreapp2.1\" />
<!-- netcoreapp2.1 -->
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\Microsoft.VisualStudio.TestPlatform.*.dll" target="lib\netcoreapp2.1\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\Microsoft.TestPlatform.*.dll" target="lib\netcoreapp2.1\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\testhost.dll" target="lib\netcoreapp2.1\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\testhost.deps.json" target="lib\netcoreapp2.1\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\x86\msdia140.dll" target="lib\netcoreapp2.1\x86\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\x64\msdia140.dll" target="lib\netcoreapp2.1\x64\" />

<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x64\testhost.dll" target="build\netcoreapp2.1\x64" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x64\testhost.exe" target="build\netcoreapp2.1\x64" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\Microsoft.TestPlatform.PlatformAbstractions.dll" target="build\netcoreapp2.1\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x64\testhost.dll" target="build\netcoreapp2.1\x64\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x64\testhost.exe" target="build\netcoreapp2.1\x64\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x64\Microsoft.TestPlatform.PlatformAbstractions.dll" target="build\netcoreapp2.1\x64\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x86\testhost.x86.dll" target="build\netcoreapp2.1\x86\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x86\testhost.x86.exe" target="build\netcoreapp2.1\x86\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x86\Microsoft.TestPlatform.PlatformAbstractions.dll" target="build\netcoreapp2.1\x86\" />

<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\Microsoft.TestPlatform.TestHost.props" target="build\netcoreapp2.1\" />

<!-- UWP -->
<file src="Microsoft.TestPlatform.TestHost\uap10.0\testhost.dll" target="lib\uap10.0\" />
<file src="Microsoft.TestPlatform.TestHost\uap10.0\Microsoft.TestPlatform.CommunicationUtilities.dll" target="lib\uap10.0\" />
<file src="Microsoft.TestPlatform.TestHost\uap10.0\Microsoft.TestPlatform.CrossPlatEngine.dll" target="lib\uap10.0\" />
<file src="Microsoft.TestPlatform.TestHost\uap10.0\Microsoft.TestPlatform.Utilities.dll" target="lib\uap10.0\" />
<file src="Microsoft.TestPlatform.TestHost\uap10.0\Microsoft.VisualStudio.TestPlatform.Common.dll" target="lib\uap10.0\" />
<file src="Microsoft.TestPlatform.TestHost\uap10.0\Microsoft.TestPlatform.*.dll" target="lib\uap10.0\" />
<file src="Microsoft.TestPlatform.TestHost\uap10.0\Microsoft.VisualStudio.TestPlatform.*.dll" target="lib\uap10.0\" />

<file src="Microsoft.TestPlatform.TestHost\uap10.0\x86\msdia140.dll" target="build\uap10.0\x86\" />
<file src="Microsoft.TestPlatform.TestHost\uap10.0\x64\msdia140.dll" target="build\uap10.0\x64\" />
Expand Down
2 changes: 2 additions & 0 deletions src/package/sign/sign.proj
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,10 @@
<TestHostCoreAssembliesToSign Include="$(ArtifactsBaseDirectory)Microsoft.TestPlatform.TestHost\netcoreapp2.1\testhost.dll" />
<TestHostCoreAssembliesToSign Include="$(ArtifactsBaseDirectory)Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x64\testhost.exe" />
<TestHostCoreAssembliesToSign Include="$(ArtifactsBaseDirectory)Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x64\testhost.dll" />
<TestHostCoreAssembliesToSign Include="$(ArtifactsBaseDirectory)Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x64\Microsoft.TestPlatform.PlatformAbstractions.dll" />
<TestHostCoreAssembliesToSign Include="$(ArtifactsBaseDirectory)Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x86\testhost.x86.exe" />
<TestHostCoreAssembliesToSign Include="$(ArtifactsBaseDirectory)Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x86\testhost.x86.dll" />
<TestHostCoreAssembliesToSign Include="$(ArtifactsBaseDirectory)Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x86\Microsoft.TestPlatform.PlatformAbstractions.dll" />
<TestHostCoreAssembliesToSign Include="$(ArtifactsBaseDirectory)Microsoft.TestPlatform.TestHost\netcoreapp2.1\Microsoft.TestPlatform.CommunicationUtilities.dll" />
<TestHostCoreAssembliesToSign Include="$(ArtifactsBaseDirectory)Microsoft.TestPlatform.TestHost\netcoreapp2.1\Microsoft.TestPlatform.CrossPlatEngine.dll" />
<TestHostCoreAssembliesToSign Include="$(ArtifactsBaseDirectory)Microsoft.TestPlatform.TestHost\netcoreapp2.1\Microsoft.TestPlatform.PlatformAbstractions.dll" />
Expand Down

0 comments on commit b074e2c

Please sign in to comment.