[2020-02] Bump msbuild to track mono-2019-12 (#19661)
[mono-project.git] / eng / common / SigningValidation.proj
blob3d0ac80af3ff514b963468220c39230eb7836df2
1 <!-- 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. -->
2 <Project Sdk="Microsoft.NET.Sdk">
3   <!--
4     This MSBuild file is intended to be used as the body of the default 
5     publishing release pipeline. The release pipeline will use this file
6     to invoke the SignCheck tool to validate that packages about to
7     be published are correctly signed.
8   
9     Parameters:
10   
11       - PackageBasePath   : Directory containing all files that need to be validated.
12       - SignCheckVersion  : Version of SignCheck package to be used.
13       - SignValidationExclusionList   : ItemGroup containing exclusion list to be forwarded to SignCheck.
14       - EnableJarSigningCheck    : Whether .jar files should be validated.
15       - EnableStrongNameCheck    : Whether strong name check should be performed.
16   -->
18   <PropertyGroup>
19     <TargetFramework>netcoreapp2.1</TargetFramework>
20   </PropertyGroup>
22   <!--
23     From 'Signing.props' we import $(SignValidationExclusionList)
24   -->
25   <Import Project="$(MSBuildThisFileDirectory)Signing.props" Condition="Exists('$(MSBuildThisFileDirectory)Signing.props')" />
27   <Target Name="ValidateSigning">
28     <PropertyGroup>
29       <SignCheckToolPath>$(NuGetPackageRoot)Microsoft.DotNet.SignCheck\$(SignCheckVersion)\tools\Microsoft.DotNet.SignCheck.exe</SignCheckToolPath>
31       <SignCheckInputDir>$(PackageBasePath)</SignCheckInputDir>
32       <SignCheckLog>signcheck.log</SignCheckLog>
33       <SignCheckErrorLog>signcheck.errors.log</SignCheckErrorLog>
34       <SignCheckExclusionsFile>signcheck.exclusions.txt</SignCheckExclusionsFile>
35     </PropertyGroup>
36     
37     <ItemGroup>
38       <!--
39         Documentation for these arguments is available here:
40         https://github.com/dotnet/arcade/tree/master/src/SignCheck
41       -->
42       <SignCheckArgs Include="--recursive" />
43       <SignCheckArgs Include="--traverse-subfolders" />
44       <SignCheckArgs Include="--file-status AllFiles" />
45       <SignCheckArgs Include="--log-file $(SignCheckLog)" />
46       <SignCheckArgs Include="--error-log-file $(SignCheckErrorLog)" />
47       <SignCheckArgs Include="--input-files $(SignCheckInputDir)" />
48       
49       <SignCheckArgs Include="--exclusions-file $(SignCheckExclusionsFile)" Condition="'@(SignValidationExclusionList)' != ''" />
50       <SignCheckArgs Include="--verify-jar" Condition="'$(EnableJarSigningCheck)' == 'true'" />
51       <SignCheckArgs Include="--verify-strongname" Condition="'$(EnableStrongNameCheck)' == 'true'" />
52     </ItemGroup>
53    
54     <WriteLinesToFile 
55       File="$(SignCheckExclusionsFile)"
56       Lines="@(SignValidationExclusionList)"
57       Condition="'@(SignValidationExclusionList)' != ''"
58       Overwrite="true"
59       Encoding="Unicode"/>
60     
61     <!--
62       IgnoreExitCode='true' because the tool doesn't return '0' on success.
63     -->
64     <Exec 
65       Command="&quot;$(SignCheckToolPath)&quot; @(SignCheckArgs, ' ')"
66       IgnoreExitCode='true' 
67       ConsoleToMsBuild="false" 
68       StandardErrorImportance="high" />
70     <Error 
71       Text="Signing validation failed. Check $(SignCheckErrorLog) for more information." 
72       Condition="Exists($(SignCheckErrorLog)) and '$([System.IO.File]::ReadAllText($(SignCheckErrorLog)))' != ''" />
74     <Message
75       Text="##vso[artifact.upload containerfolder=LogFiles;artifactname=LogFiles]{SignCheckErrorLog}"
76       Condition="Exists($(SignCheckErrorLog)) and '$([System.IO.File]::ReadAllText($(SignCheckErrorLog)))' != ''" />
77     
78   </Target>
80   <ItemGroup>
81     <PackageReference Include="Microsoft.DotNet.SignCheck" Version="$(SignCheckVersion)" />
82   </ItemGroup>
83 </Project>