CodeSign.targets 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <Project>
  2. <PropertyGroup>
  3. <!-- _ProjectsOnly is for local builds and shouldn't be used on CI. -->
  4. <DisableCodeSigning Condition=" '$(_ProjectsOnly)' == 'true' ">true</DisableCodeSigning>
  5. <CodeSignDependsOn>$(CodeSignDependsOn);CollectFileSignInfo</CodeSignDependsOn>
  6. </PropertyGroup>
  7. <Target Name="CollectFileSignInfo" DependsOnTargets="_PrepareRepositories;GetProjectArtifactInfo;GetFxProjectArtifactInfo">
  8. <ItemGroup>
  9. <_RepositoryProject Remove="@(_RepositoryProject)" />
  10. <_RepositoryProject Include="$(MSBuildProjectFullPath)" Condition="'%(Repository.Identity)' != ''">
  11. <AdditionalProperties>RepositoryRoot=%(Repository.RootPath)</AdditionalProperties>
  12. <Build>%(Repository.Build)</Build>
  13. </_RepositoryProject>
  14. <_ShippedRepositoryProject Include="$(MSBuildProjectFullPath)" Condition="'%(ShippedRepository.Identity)' != ''">
  15. <AdditionalProperties>RepositoryRoot=%(ShippedRepository.RootPath)</AdditionalProperties>
  16. <Build>false</Build>
  17. </_ShippedRepositoryProject>
  18. </ItemGroup>
  19. <PropertyGroup>
  20. <GetFileSignInfoProps>
  21. AssemblySigningCertName=$(AssemblySigningCertName);
  22. AssemblySigning3rdPartyCertName=$(AssemblySigning3rdPartyCertName);
  23. PowerShellSigningCertName=$(PowerShellSigningCertName);
  24. PackageSigningCertName=$(PackageSigningCertName);
  25. VsixSigningCertName=$(VsixSigningCertName);
  26. JarSigningCertName=$(JarSigningCertName);
  27. ArtifactsDir=$(ArtifactsDir);
  28. BuildDir=$(BuildDir)
  29. </GetFileSignInfoProps>
  30. </PropertyGroup>
  31. <MSBuild Projects="@(_RepositoryProject)"
  32. Condition="@(_RepositoryProject->Count()) != 0"
  33. Targets="_GetFileSignInfo"
  34. Properties="$(GetFileSignInfoProps);$(DesignTimeBuildProps);DesignTimeBuild=true;Configuration=$(Configuration);BuildNumber=$(BuildNumber);CustomAfterKoreBuildTargets=$(MSBuildThisFileFullPath)"
  35. BuildInParallel="true">
  36. <Output TaskParameter="TargetOutputs" ItemName="_RepoFileSignInfo" />
  37. </MSBuild>
  38. <MSBuild Projects="@(_ShippedRepositoryProject)"
  39. Condition="@(_ShippedRepositoryProject->Count()) != 0"
  40. Targets="_GetFileSignInfo"
  41. Properties="$(GetFileSignInfoProps);$(DesignTimeBuildProps);IsFinalBuild=true;DesignTimeBuild=true;Configuration=$(Configuration);BuildNumber=$(BuildNumber);CustomAfterKoreBuildTargets=$(MSBuildThisFileFullPath)"
  42. BuildInParallel="true">
  43. <Output TaskParameter="TargetOutputs" ItemName="_ShippedRepoFileSignInfo" />
  44. </MSBuild>
  45. <ItemGroup>
  46. <!-- If repos were not built, only use this info to collect the mapping of FileName -> Certificate. Otherwise, include .nupkg and .zips in signing. -->
  47. <_FilesToSign Include="@(_RepoFileSignInfo)" Condition="'%(_RepoFileSignInfo.IsFileToSign)' == 'true' AND ('$(_ReposWereBuilt)' == 'true' OR '%(_RepoFileSignInfo.Container)' != '' ) " />
  48. <_FilesToSign Include="@(_ShippedRepoFileSignInfo)" Condition="'%(_ShippedRepoFileSignInfo.IsFileToSign)' == 'true' AND '%(_ShippedRepoFileSignInfo.Container)' != '' " />
  49. <FilesToSign Include="@(_FilesToSign)" />
  50. <!-- Normalize FilesToExcludeFromSigning to filename + extension. -->
  51. <_Temp Remove="@(_Temp)" />
  52. <_Temp Include="@(FilesToExcludeFromSigning)" />
  53. <FilesToExcludeFromSigning Remove="@(FilesToExcludeFromSigning)" />
  54. <FilesToExcludeFromSigning Include="@(_Temp->'%(FileName)%(Extension)')" />
  55. <_Temp Remove="@(_Temp)" />
  56. <FilesToExcludeFromSigning Include="@(_ShippedRepoFileSignInfo->'%(FileName)%(Extension)')" Condition="'%(_ShippedRepoFileSignInfo.IsFileToExcludeFromSign)' == 'true'" />
  57. <FilesToExcludeFromSigning Include="@(_RepoFileSignInfo->'%(FileName)%(Extension)')" Condition="'%(_RepoFileSignInfo.IsFileToExcludeFromSign)' == 'true'" />
  58. <!-- Workaround for the way we have both repo and Universe builds, crossgen AND uncrossgened outputs. This prevents duplicate configuration between 'exclude' and 'sign' options. -->
  59. <FilesToExcludeFromSigning Remove="@(FilesToSign->'%(FileName)%(Extension)')" />
  60. </ItemGroup>
  61. </Target>
  62. <Target Name="_GetFileSignInfo" DependsOnTargets="GetArtifactInfo" Returns="@(_FileSignInfo)">
  63. <ItemGroup>
  64. <_FileSignInfo Include="@(FilesToSign)" IsFileToSign="true" />
  65. <_FileSignInfo Include="@(FilesToExcludeFromSigning)" IsFileToExcludeFromSign="true" />
  66. </ItemGroup>
  67. </Target>
  68. </Project>