Skip to content

Commit 1504231

Browse files
authored
Add option to disable all strong name signing during build of NuGet.Client repository (#5744)
1 parent d3804ab commit 1504231

59 files changed

Lines changed: 205 additions & 223 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.ps1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Indicates the build script is invoked from CI
2121
Indicates whether to create the end to end package.
2222
2323
.PARAMETER SkipDelaySigning
24-
Indicates whether to skip delay signing. By default assemblies will be delay signed.
24+
Indicates whether to skip strong name signing. By default assemblies will be delay signed and require strong name validation exclusions.
2525
2626
.EXAMPLE
2727
.\build.ps1
@@ -135,8 +135,7 @@ Invoke-BuildStep $VSMessage {
135135

136136
If ($SkipDelaySigning)
137137
{
138-
$buildArgs += "/p:MS_PFX_PATH="
139-
$buildArgs += "/p:NUGET_PFX_PATH="
138+
$buildArgs += "/p:SkipSigning=true"
140139
}
141140

142141
if ($Binlog)

build/common.targets

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
</ItemGroup>
2525
</Target>
2626

27-
<ImportGroup Condition=" '$(SkipSigning)' != 'true' ">
28-
<Import Project="sign.targets" />
29-
</ImportGroup>
27+
<Import Project="sign.targets" Condition=" '$(SkipSigning)' != 'true' "/>
3028

3129
<PropertyGroup Condition="'$(Shipping)' == 'true'">
3230
<GetSigningInputsDependsOn Condition="'$(GetSigningInputsDependsOn)' == ''">GetSigningInputsDefault</GetSigningInputsDependsOn>

build/config.props

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@
9090
<PackageIcon>icon.png</PackageIcon>
9191
</PropertyGroup>
9292

93-
<PropertyGroup>
94-
<NUGET_PFX_PATH>$(MSBuildThisFileDirectory)..\keys\NuGetKey.snk</NUGET_PFX_PATH>
95-
<MS_PFX_PATH>$(MSBuildThisFileDirectory)..\keys\35MSSharedLib1024.snk</MS_PFX_PATH>
96-
</PropertyGroup>
97-
9893
<Target Name="GetSemanticVersion">
9994
<Message Text="$(SemanticVersion)" Importance="High"/>
10095
</Target>

build/sign.targets

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,44 @@
1-
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2-
3-
<!-- Use NuGet SNK by default for all projects except API.Test. -->
1+
<Project>
42
<PropertyGroup>
5-
<StrongNameKey>$(NUGET_PFX_PATH)</StrongNameKey>
6-
<DefaultStrongNameCert>67</DefaultStrongNameCert>
3+
<SignAssembly>true</SignAssembly>
4+
<SignWithTestKey Condition="'$(TestProject)' == 'true'">true</SignWithTestKey>
75
</PropertyGroup>
86

9-
<!-- Use MSFT SNK for all NuGet.Core test and source projects and since we do not own MSFT SNK we can only delay sign the assemblies. -->
10-
<PropertyGroup Condition = " $(MSBuildProjectFullPath.Contains('src\NuGet.Core')) == 'true' or $(MSBuildProjectFullPath.Contains('test/NuGet.Core')) == 'true' or
11-
$(MSBuildProjectFullPath.Contains('src/NuGet.Core')) == 'true' or $(MSBuildProjectFullPath.Contains('test\NuGet.Core')) == 'true' or
12-
$(MSBuildProjectFullPath.Contains('NuGet.CommandLine.csproj')) == 'true' or
13-
$(MSBuildProjectFullPath.Contains('NuGet.Indexing.csproj')) == 'true' ">
7+
<PropertyGroup Condition="'$(TestProject)' != 'true' And '$(SignWithTestKey)' != 'true'">
8+
<SignWithNuGetKey Condition="'$(SignWithMicrosoftKey)' != 'true' And '$(SignWithNuGetKey)' == ''">true</SignWithNuGetKey>
9+
<SignWithMicrosoftKey Condition="'$(SignWithNuGetKey)' != 'true' And '$(SignWithMicrosoftKey)' == ''">true</SignWithMicrosoftKey>
10+
</PropertyGroup>
11+
12+
<!-- Use Test SNK by default for all test projects -->
13+
<PropertyGroup Condition="'$(SignWithTestKey)' == 'true'">
14+
<AssemblyOriginatorKeyFile>$([System.IO.Path]::Combine($(MSBuildThisFileDirectory), '..', 'keys', 'Test.snk'))</AssemblyOriginatorKeyFile>
15+
</PropertyGroup>
1416

15-
<StrongNameKey>$(MS_PFX_PATH)</StrongNameKey>
16-
<DefaultStrongNameCert>MsSharedLib72</DefaultStrongNameCert>
17+
<!-- Use NuGet SNK by default for all projects -->
18+
<PropertyGroup Condition="'$(SignWithNuGetKey)' == 'true'">
19+
<AssemblyOriginatorKeyFile>$([System.IO.Path]::Combine($(MSBuildThisFileDirectory), '..', 'keys', 'NuGetKey.snk'))</AssemblyOriginatorKeyFile>
20+
<StrongNameCert>67</StrongNameCert>
1721
</PropertyGroup>
1822

19-
<PropertyGroup Condition = " Exists($(StrongNameKey)) ">
20-
<SignAssembly>true</SignAssembly>
23+
<!-- Use MSFT SNK for all NuGet.Core projects and since we do not own MSFT SNK we can only delay sign the assemblies. -->
24+
<PropertyGroup Condition="'$(SignWithMicrosoftKey)' == 'true'">
25+
<AssemblyOriginatorKeyFile>$([System.IO.Path]::Combine($(MSBuildThisFileDirectory), '..', 'keys', '35MSSharedLib1024.snk'))</AssemblyOriginatorKeyFile>
26+
<StrongNameCert>MsSharedLib72</StrongNameCert>
27+
</PropertyGroup>
28+
29+
<PropertyGroup Condition="'$(SignWithNuGetKey)' == 'true' Or '$(SignWithMicrosoftKey)' == 'true'">
2130
<DelaySign Condition="'$(IsXplat)' != 'true'">true</DelaySign>
2231
<PublicSign Condition="'$(IsXplat)' == 'true'">true</PublicSign>
23-
<AssemblyOriginatorKeyFile Condition = " '$(AssemblyOriginatorKeyFile)' == '' ">$(StrongNameKey)</AssemblyOriginatorKeyFile>
24-
<StrongNameCert Condition="'$(StrongNameCert)' == ''">$(DefaultStrongNameCert)</StrongNameCert>
2532
</PropertyGroup>
2633

34+
<ItemGroup>
35+
<!-- All InternalsVisibleTo are supposed to be tests so update them with the public key from Test.snk -->
36+
<InternalsVisibleTo Update="@(InternalsVisibleTo)" PublicKey="0024000004800000940000000602000000240000525341310004000001000100A5276DF8650A58CB43396DC7B3D395F30A82D0D1FA98FBCFE3ABEAD5DE0B1DB6764347A0F6BF0B060A27C202CCD122DB5DED8F596CEBE2ECC3A6629015EEB96C94F6B9E8185D4ACC84C376FF6B1C3147431A4D55CB5736DB97A9E88FCC47D9193F4DB5896DC5817E5D0CBD2641726E7431990BCD2DD7FA1D28493D0CFD9DCFA4" />
37+
38+
<!-- DynamicProxyGenAssembly2 is the assembly generated by mocks and are signed with a known key -->
39+
<InternalsVisibleTo Update="DynamicProxyGenAssembly2" PublicKey="0024000004800000940000000602000000240000525341310004000001000100C547CAC37ABD99C8DB225EF2F6C8A3602F3B3606CC9891605D02BAA56104F4CFC0734AA39B93BF7852F7D9266654753CC297E7D2EDFE0BAC1CDCF9F717241550E0A7B191195B7667BB4F64BCB8E2121380FD1D9D46AD2D92D2D15605093924CCEAF74C4861EFF62ABF69B9291ED0A340E113BE11E6A7D3113E92484CF7045CC7" />
40+
41+
<!-- Test.Utility is shipped so is singed with the NuGet key -->
42+
<InternalsVisibleTo Update="Test.Utility" PublicKey="002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293" />
43+
</ItemGroup>
2744
</Project>

keys/Test.snk

596 Bytes
Binary file not shown.

src/NuGet.Clients/NuGet.CommandLine/NuGet.CommandLine.csproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ApplicationManifest>app.manifest</ApplicationManifest>
1313
<Shipping>true</Shipping>
1414
<OutputType>Exe</OutputType>
15+
<SignWithMicrosoftKey>true</SignWithMicrosoftKey>
1516
<ComVisible>false</ComVisible>
1617
<!-- Pack properties-->
1718
<PackProject>true</PackProject>
@@ -23,7 +24,7 @@
2324
<UsePublicApiAnalyzer>false</UsePublicApiAnalyzer>
2425
<GetSigningInputsDependsOn>GetSigningInputsCustom</GetSigningInputsDependsOn>
2526
<GetSymbolsToIndexDependsOn>GetSymbolsToIndexCustom</GetSymbolsToIndexDependsOn>
26-
</PropertyGroup>
27+
</PropertyGroup>
2728

2829
<Target Name="CreateCommandlineNupkg">
2930
<ItemGroup>
@@ -101,6 +102,11 @@
101102
</EmbeddedResource>
102103
</ItemGroup>
103104

105+
<ItemGroup>
106+
<InternalsVisibleTo Include="NuGet.CommandLine.FuncTest" />
107+
<InternalsVisibleTo Include="NuGet.CommandLine.Test" />
108+
</ItemGroup>
109+
104110
<Target Name="DetermineILMergeNuGetExeInputsOutputs">
105111
<PropertyGroup>
106112
<PathToBuiltNuGetExe>$(OutputPath)NuGet.exe</PathToBuiltNuGetExe>
@@ -124,7 +130,7 @@
124130
Condition="'$(BuildingInsideVisualStudio)' != 'true' and '$(SkipILMergeOfNuGetExe)' != 'true'" >
125131
<PropertyGroup>
126132
<IlmergeCommand>$(ILMergeConsolePath) /lib:$(OutputPath) /out:$(PathToMergedNuGetExe) @(MergeAllowDup -> '/allowdup:%(Identity)', ' ') /log:$(OutputPath)IlMergeLog.txt</IlmergeCommand>
127-
<IlmergeCommand Condition="Exists($(MS_PFX_PATH))">$(IlmergeCommand) /delaysign /keyfile:$(MS_PFX_PATH)</IlmergeCommand>
133+
<IlmergeCommand Condition="'$(SkipSigning)' != 'true' And Exists($(AssemblyOriginatorKeyFile))">$(IlmergeCommand) /delaysign /keyfile:$(AssemblyOriginatorKeyFile)</IlmergeCommand>
128134
<IlmergeCommand>$(IlmergeCommand) $(PathToBuiltNuGetExe) @(BuildArtifacts->'%(fullpath)', ' ')</IlmergeCommand>
129135
<IlmergeCommand>$(IlmergeCommand) @(LocResource->'%(fullpath)', ' ')</IlmergeCommand>
130136
</PropertyGroup>

src/NuGet.Clients/NuGet.CommandLine/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/NuGet.Clients/NuGet.Console/NuGet.Console.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,10 @@
4343
</EmbeddedResource>
4444
</ItemGroup>
4545

46+
<ItemGroup>
47+
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
48+
<InternalsVisibleTo Include="NuGet.Console.TestContract" />
49+
<InternalsVisibleTo Include="NuGet.PowerShellHost.Test" />
50+
</ItemGroup>
51+
4652
</Project>

src/NuGet.Clients/NuGet.Console/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,8 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System.Reflection;
5-
using System.Runtime.CompilerServices;
65
using System.Runtime.InteropServices;
76

8-
// General Information about an assembly is controlled through the following
9-
// set of attributes. Change these attribute values to modify the information
10-
// associated with an assembly.
11-
12-
[assembly: InternalsVisibleTo("NuGet.Console.TestContract, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
13-
[assembly: InternalsVisibleTo("NuGet.PowerShellHost.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
14-
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
15-
167
// The following GUID is for the ID of the typelib if this project is exposed to COM
178

189
[assembly: Guid("3f7df594-3ac4-4ed6-93c3-1dcfee7600c6")]

src/NuGet.Clients/NuGet.Indexing/NuGet.Indexing.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<PackProject>true</PackProject>
77
<Shipping>true</Shipping>
88
<IncludeInVsix>true</IncludeInVsix>
9+
<SignWithMicrosoftKey>true</SignWithMicrosoftKey>
910
</PropertyGroup>
1011

1112
<ItemGroup>

0 commit comments

Comments
 (0)