summaryrefslogtreecommitdiff
path: root/.packages/microsoft.dotnet.arcade.sdk/1.0.0-beta.19577.5/tools/SdkTasks/SigningValidation.proj
blob: c7a8acf64868c75de2f5f07eb2aa68f0867c4c33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Execute">
  <!--
    This MSBuild file is intended to be used as the body of the default 
    publishing release pipeline. The release pipeline will use this file
    to invoke the SignCheck tool to validate that packages about to
    be published are correctly signed.
  
    Parameters:
  
      - PackageBasePath         : Directory containing all files that need to be validated.
      - SignCheckExclusionsFile : Path to file containing exclusion list to be used by SignCheck.
      - EnableJarSigningCheck   : Whether .jar files should be validated.
      - EnableStrongNameCheck   : Whether strong name check should be performed.
  -->

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <Target Name="Execute">
    <PropertyGroup>
      <SignCheckToolPath>$(NuGetPackageRoot)Microsoft.DotNet.SignCheck\$(MicrosoftDotNetSignCheckVersion)\tools\Microsoft.DotNet.SignCheck.exe</SignCheckToolPath>

      <SignCheckInputDir>$(PackageBasePath)</SignCheckInputDir>
      <SignCheckLog>signcheck.log</SignCheckLog>
      <SignCheckErrorLog>signcheck.errors.log</SignCheckErrorLog>
    </PropertyGroup>
    
    <ItemGroup>
      <!--
        Documentation for these arguments is available here:
        https://github.com/dotnet/arcade/tree/master/src/SignCheck
      -->
      <SignCheckArgs Include="--recursive" />
      <SignCheckArgs Include="--traverse-subfolders" />
      <SignCheckArgs Include="--file-status AllFiles" />
      <SignCheckArgs Include="--log-file $(SignCheckLog)" />
      <SignCheckArgs Include="--error-log-file $(SignCheckErrorLog)" />
      <SignCheckArgs Include="--input-files &quot;$(SignCheckInputDir)&quot;" />
      
      <SignCheckArgs Include="--exclusions-file &quot;$(SignCheckExclusionsFile)&quot;" Condition="'$(SignCheckExclusionsFile)' != '' and Exists($(SignCheckExclusionsFile))" />
      <SignCheckArgs Include="--verify-jar" Condition="'$(EnableJarSigningCheck)' == 'true'" />
      <SignCheckArgs Include="--verify-strongname" Condition="'$(EnableStrongNameCheck)' == 'true'" />
    </ItemGroup>
    
    <!--
      IgnoreExitCode='true' because the tool doesn't return '0' on success.
    -->
    <Exec 
      Command="&quot;$(SignCheckToolPath)&quot; @(SignCheckArgs, ' ')"
      IgnoreExitCode='true' 
      ConsoleToMsBuild="false" 
      StandardErrorImportance="high" />

    <Error 
      Text="Signing validation failed. Check $(SignCheckErrorLog) for more information." 
      Condition="Exists($(SignCheckErrorLog)) and '$([System.IO.File]::ReadAllText($(SignCheckErrorLog)))' != ''" />

    <Message
      Text="##vso[artifact.upload containerfolder=LogFiles;artifactname=LogFiles]{SignCheckErrorLog}"
      Condition="Exists($(SignCheckErrorLog)) and '$([System.IO.File]::ReadAllText($(SignCheckErrorLog)))' != ''" />
    
  </Target>

  <ItemGroup>
    <PackageReference Include="Microsoft.DotNet.SignCheck" Version="$(MicrosoftDotNetSignCheckVersion)" />
  </ItemGroup>
</Project>