build/sign.targets (30 lines of code) (raw):
<Project>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<SignWithTestKey Condition="'$(TestProject)' == 'true'">true</SignWithTestKey>
</PropertyGroup>
<PropertyGroup Condition="'$(TestProject)' != 'true' And '$(SignWithTestKey)' != 'true'">
<SignWithNuGetKey Condition="'$(SignWithMicrosoftKey)' != 'true' And '$(SignWithNuGetKey)' == ''">true</SignWithNuGetKey>
<SignWithMicrosoftKey Condition="'$(SignWithNuGetKey)' != 'true' And '$(SignWithMicrosoftKey)' == ''">true</SignWithMicrosoftKey>
</PropertyGroup>
<!-- Use Test SNK by default for all test projects -->
<PropertyGroup Condition="'$(SignWithTestKey)' == 'true'">
<AssemblyOriginatorKeyFile>$([System.IO.Path]::Combine($(MSBuildThisFileDirectory), '..', 'keys', 'Test.snk'))</AssemblyOriginatorKeyFile>
</PropertyGroup>
<!-- Use NuGet SNK by default for all projects -->
<PropertyGroup Condition="'$(SignWithNuGetKey)' == 'true'">
<AssemblyOriginatorKeyFile>$([System.IO.Path]::Combine($(MSBuildThisFileDirectory), '..', 'keys', 'NuGetKey.snk'))</AssemblyOriginatorKeyFile>
<StrongNameCert>67</StrongNameCert>
</PropertyGroup>
<!-- Use MSFT SNK for all NuGet.Core projects and since we do not own MSFT SNK we can only delay sign the assemblies. -->
<PropertyGroup Condition="'$(SignWithMicrosoftKey)' == 'true'">
<AssemblyOriginatorKeyFile>$([System.IO.Path]::Combine($(MSBuildThisFileDirectory), '..', 'keys', '35MSSharedLib1024.snk'))</AssemblyOriginatorKeyFile>
<StrongNameCert>MsSharedLib72</StrongNameCert>
</PropertyGroup>
<PropertyGroup Condition="'$(SignWithNuGetKey)' == 'true' Or '$(SignWithMicrosoftKey)' == 'true'">
<PublicSign Condition="'$(DotNetBuildFromVMR)' == 'true' Or '$(IsXplat)' == 'true' ">true</PublicSign>
<DelaySign Condition="'$(DotNetBuildFromVMR)' != 'true' And '$(IsXplat)' != 'true' ">true</DelaySign>
</PropertyGroup>
<ItemGroup>
<!-- All InternalsVisibleTo are supposed to be tests so update them with the public key from Test.snk -->
<InternalsVisibleTo Update="@(InternalsVisibleTo)" PublicKey="0024000004800000940000000602000000240000525341310004000001000100A5276DF8650A58CB43396DC7B3D395F30A82D0D1FA98FBCFE3ABEAD5DE0B1DB6764347A0F6BF0B060A27C202CCD122DB5DED8F596CEBE2ECC3A6629015EEB96C94F6B9E8185D4ACC84C376FF6B1C3147431A4D55CB5736DB97A9E88FCC47D9193F4DB5896DC5817E5D0CBD2641726E7431990BCD2DD7FA1D28493D0CFD9DCFA4" />
<!-- DynamicProxyGenAssembly2 is the assembly generated by mocks and are signed with a known key -->
<InternalsVisibleTo Update="DynamicProxyGenAssembly2" PublicKey="0024000004800000940000000602000000240000525341310004000001000100C547CAC37ABD99C8DB225EF2F6C8A3602F3B3606CC9891605D02BAA56104F4CFC0734AA39B93BF7852F7D9266654753CC297E7D2EDFE0BAC1CDCF9F717241550E0A7B191195B7667BB4F64BCB8E2121380FD1D9D46AD2D92D2D15605093924CCEAF74C4861EFF62ABF69B9291ED0A340E113BE11E6A7D3113E92484CF7045CC7" />
<!-- Microsoft.Internal.NuGet.Testing.SignedPackages is shipped (to a dotnet feed, not to nuget.org) so is singed with the NuGet key -->
<InternalsVisibleTo Update="Microsoft.Internal.NuGet.Testing.SignedPackages" PublicKey="002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293" />
</ItemGroup>
</Project>