1 <?xml version="1.0" encoding="utf-8"?>
2 <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
4 <Import Project="..\dir.props"/>
5 <Import Project="..\dir.targets" />
8 <!-- The SignFiles target needs OutDir to be defined -->
9 <OutDir>$(BinDir)</OutDir>
12 <UsingTask AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll" TaskName="ReadSigningRequired" />
15 <WindowsNativeLocation Include="$(BinDir)*.dll" />
16 <WindowsNativeLocation Include="$(BinDir)*.exe" />
17 <!-- Ensure cross targeting components are signed properly -->
18 <WindowsNativeLocation Include="$(BinDir)$(CrossTargetComponentFolder)\*.exe" />
19 <WindowsNativeLocation Include="$(BinDir)$(CrossTargetComponentFolder)\*.dll" />
21 <!-- sign the cross targeted files as well -->
22 <ItemGroup Condition="'$(CrossTargetComponentFolder)' != ''">
23 <WindowsNativeLocation Include="$(BinDir)$(CrossTargetComponentFolder)/*.dll" />
24 <WindowsNativeLocation Include="$(BinDir)$(CrossTargetComponentFolder)/*.exe" />
27 <Target Name="GenerateSignForWindowsNative">
29 Managed assemblies should already have a requires_signing file dropped so only generate
30 a requires_signing file for ones that don't exist which should leave just native assembies
32 <WriteSigningRequired AuthenticodeSig="$(AuthenticodeSig)"
33 MarkerFile="%(WindowsNativeLocation.Identity).requires_signing"
34 Condition="!Exists('%(WindowsNativeLocation.Identity).requires_signing')" />
37 <!-- populates item group FilesToSign with the list of files to sign -->
38 <Target Name="GetFilesToSignItems"
39 DependsOnTargets="GenerateSignForWindowsNative">
40 <!-- read all of the marker files and populate the FilesToSign item group -->
42 <SignMarkerFile Include="$(OutDir)**\*.requires_signing" />
44 <ReadSigningRequired MarkerFiles="@(SignMarkerFile)">
45 <Output TaskParameter="SigningMetadata" ItemName="FilesToSign" />
46 </ReadSigningRequired>
48 <Message Importance="High" Text="Attempting to sign %(FilesToSign.Identity) with authenticode='%(FilesToSign.Authenticode)' and strongname='%(FilesToSign.StrongName)'" />
53 Condition="'$(SkipSigning)' != 'true'"
54 DependsOnTargets="GetFilesToSignItems;SignFiles">
56 <!-- now that the files have been signed delete the marker files -->
57 <Delete Files="@(SignMarkerFile)" />