summaryrefslogtreecommitdiff
path: root/.packages/microsoft.dotnet.arcade.sdk/1.0.0-beta.19577.5/tools/StrongName.targets
blob: 12ed647fdf33fcfb1e6a5553c490d507fadc4545 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?xml version="1.0" encoding="utf-8"?>
<!-- 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>

  <!--
    Reads variables:
      SignAssembly    "true" to sign the output assembly of the current project
      StrongNameKeyId The id of the key used for strong name generation

    Writes variables:
      DelaySign
      PublicSign
      PublicKey
      PublicKeyToken
      AssemblyOriginatorKeyFile
  -->

  <PropertyGroup Condition="'$(SignAssembly)' != 'false'">
    <DelaySign>false</DelaySign>
    <PublicSign>true</PublicSign>
  </PropertyGroup>

  <!-- Binaries are delay or public-signed with one of these keys; later, the signing system will finish the strong-name signing. -->
  <Choose>
    <When Condition="'$(SignAssembly)' == 'false'" />
    <When Condition="'$(StrongNameKeyId)' == 'Microsoft'">
      <PropertyGroup>
        <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)snk/MSFT.snk</AssemblyOriginatorKeyFile>
        <PublicKey>$(MicrosoftPublicKey)</PublicKey>
        <PublicKeyToken>b03f5f7f11d50a3a</PublicKeyToken>
      </PropertyGroup>
    </When>
    <When Condition="'$(StrongNameKeyId)' == 'MicrosoftShared'">
      <PropertyGroup>
        <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)snk/35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
        <PublicKey>$(MicrosoftSharedPublicKey)</PublicKey>
        <PublicKeyToken>31BF3856AD364E35</PublicKeyToken>
      </PropertyGroup>
    </When>
    <When Condition="'$(StrongNameKeyId)' == 'MicrosoftAspNetCore'">
      <PropertyGroup>
        <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)snk/AspNetCore.snk</AssemblyOriginatorKeyFile>
        <PublicKey>$(MicrosoftAspNetCorePublicKey)</PublicKey>
        <PublicKeyToken>adb9793829ddae60</PublicKeyToken>
        <PublicSign>false</PublicSign> <!-- The MicrosoftAspNetCore strong name key is a full key -->
      </PropertyGroup>
    </When>
    <When Condition="'$(StrongNameKeyId)' == 'ECMA'">
      <PropertyGroup>
        <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)snk/ECMA.snk</AssemblyOriginatorKeyFile>
        <PublicKey>$(ECMAPublicKey)</PublicKey>
        <PublicKeyToken>b77a5c561934e089</PublicKeyToken>
      </PropertyGroup>
    </When>
    <!--
      The Open key can be used by any library that needs strong name signing that doesn't
      have to be protected by the closed MS based keys. The idea is to have a key for identity but
      not for any security purposes.
    -->
    <When Condition="'$(StrongNameKeyId)' == 'Open'">
      <PropertyGroup>
        <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)snk/Open.snk</AssemblyOriginatorKeyFile>
        <PublicKey>$(OpenPublicKey)</PublicKey>
        <PublicKeyToken>cc7b13ffcd2ddd51</PublicKeyToken>
        <DelaySign>false</DelaySign>
        <PublicSign>false</PublicSign> <!-- The Open strong name key is a full key -->
      </PropertyGroup>
    </When>
    <When Condition="'$(StrongNameKeyId)' == 'SilverlightPlatform'">
      <PropertyGroup>
        <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)snk/SilverlightPlatformPublicKey.snk</AssemblyOriginatorKeyFile>
        <PublicKey>$(SilverlightPlatformPublicKey)</PublicKey>
        <PublicKeyToken>7cec85d7bea7798e</PublicKeyToken>
      </PropertyGroup>
    </When>
  </Choose>

  <!-- Build Flag Verification -->
  <PropertyGroup>
    <PrepareForBuildDependsOn>$(PrepareForBuildDependsOn);VerifyBuildFlags</PrepareForBuildDependsOn>
  </PropertyGroup>

  <Target Name="VerifyBuildFlags">
    <Error Condition="'$(SignAssembly)' != 'false' and
                      ('$(PublicKey)' == '' or '$(PublicKeyToken)' == '' or '$(AssemblyOriginatorKeyFile)' == '')"
           Text="PublicKey, PublicKeyToken and AssemblyOriginatorKeyFile must be specified" />
  </Target>

</Project>