Skip to content

Commit

Permalink
Run signcheck in single threaded apartment (#7241)
Browse files Browse the repository at this point in the history
  • Loading branch information
chcosta authored Apr 15, 2021
1 parent d3f18dd commit 40ecdb3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static uint IsSigned(string path)
WinTrustData data = new WinTrustData()
{
cbStruct = (uint)Marshal.SizeOf(typeof(WinTrustData)),
dwProvFlags = Convert.ToUInt32(Provider.WTD_SAFER_FLAG),
dwProvFlags = 0,
dwStateAction = Convert.ToUInt32(StateAction.WTD_STATEACTION_IGNORE),
dwUIChoice = Convert.ToUInt32(UIChoice.WTD_UI_NONE),
dwUIContext = 0,
Expand Down
4 changes: 4 additions & 0 deletions src/SignCheck/SignCheck/Microsoft.DotNet.SignCheck.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<ProjectReference Include="..\Microsoft.SignCheck\Microsoft.DotNet.SignCheckLibrary.csproj" PrivateAssets="All" Publish="true" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\Common\Internal\AssemblyResolution.cs" Link="src\AssemblyResolution.cs" />
</ItemGroup>

<ItemGroup>
<Reference Include="System.Net" Pack="false" />
</ItemGroup>
Expand Down
9 changes: 8 additions & 1 deletion src/SignCheck/SignCheck/SignCheckTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.SignCheck.Logging;
using System;
using System.Collections.Generic;
Expand All @@ -10,8 +11,12 @@

namespace SignCheck
{
public class SignCheckTask : Microsoft.Build.Utilities.Task
[Microsoft.Build.Framework.LoadInSeparateAppDomain]
[RunInSTA]
public class SignCheckTask : AppDomainIsolatedTask
{
static SignCheckTask() => Microsoft.DotNet.AssemblyResolution.Initialize();

public bool EnableJarSignatureVerification
{
get;
Expand Down Expand Up @@ -85,6 +90,7 @@ public string ArtifactFolder

public override bool Execute()
{
Microsoft.DotNet.AssemblyResolution.Log = Log;
Options options = new Options();
options.EnableJarSignatureVerification = EnableJarSignatureVerification;
options.EnableXmlSignatureVerification = EnableXmlSignatureVerification;
Expand Down Expand Up @@ -143,6 +149,7 @@ public override bool Execute()

var sc = new SignCheck(options);
int result = sc.Run();
Microsoft.DotNet.AssemblyResolution.Log = null;
return (result == 0 && !Log.HasLoggedErrors);
}
}
Expand Down

0 comments on commit 40ecdb3

Please sign in to comment.