Skip to content

Commit 4d0a127

Browse files
committed
Task 42666: Verify Azure DLL via public key token
- Consolidated strong name signing into Directory.Build.props. - Added a conditional compilation constant for strong name signing. - Added public key token check when SqlClient loads the Azure assembly. - Added logging related to Azure assembly loading. - Added explicit check for .NET runtime. - Added a way to define whatever conditional compilation constants we want on the command-line.
1 parent ee71014 commit 4d0a127

14 files changed

Lines changed: 95 additions & 107 deletions

File tree

eng/pipelines/steps/compound-build-csproj-step.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
# See the LICENSE file in the project root for more information. #
55
#################################################################################
66

7-
# Generic build step for csproj-based Extension packages (Logging, Abstractions, Azure). Each
8-
# project uses a build.proj target that runs Build only and produces assemblies within
9-
# $(BUILD_OUTPUT). Downstream ESRP DLL signing must locate the assemblies within $(BUILD_OUTPUT)
10-
# for all target frameworks that the csproj targets. NuGet packaging is done separately via
11-
# compound-pack-csproj-step.yml after DLL signing.
7+
# Generic build step for csproj-based packages. Each project uses a build.proj target that runs
8+
# Build only and produces assemblies within $(BUILD_OUTPUT). Downstream ESRP DLL signing must
9+
# locate the assemblies within $(BUILD_OUTPUT) for all target frameworks that the csproj targets.
10+
# NuGet packaging is done separately via compound-pack-csproj-step.yml after DLL signing.
1211

1312
parameters:
1413
# The MSBuild build target in build.proj (e.g. BuildLogging, BuildAbstractions,

src/Directory.Build.props

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@
6161
<!-- Respect environment variable for the .NET install directory if set; otherwise, use the current default location -->
6262
<BuildSimulator Condition="'$(BuildSimulator)' != 'true'">false</BuildSimulator>
6363
</PropertyGroup>
64+
65+
<!-- Add user-supplied define constants. -->
66+
<PropertyGroup Condition="'$(UserDefinedConstants)' != ''">
67+
<DefineConstants>$(DefineConstants);$(UserDefinedConstants)</DefineConstants>
68+
</PropertyGroup>
69+
6470
<PropertyGroup Condition="'$(BuildSimulator)' == 'true'">
6571
<DefineConstants>$(DefineConstants);ENCLAVE_SIMULATOR</DefineConstants>
6672
</PropertyGroup>
@@ -109,6 +115,17 @@
109115
<!-- <WarningsNotAsErrors>NU1901;NU1902;NU1903;NU1904</WarningsNotAsErrors> -->
110116
</PropertyGroup>
111117

118+
<!-- Strong name signing ============================================= -->
119+
120+
<!-- When a signing key is specified, we will perform strong name assembly signing. -->
121+
<PropertyGroup Condition="'$(SigningKeyPath)' != ''">
122+
<SignAssembly>true</SignAssembly>
123+
<AssemblyOriginatorKeyFile>$(SigningKeyPath)</AssemblyOriginatorKeyFile>
124+
125+
<!-- We also define a constant used for conditional compilation. -->
126+
<DefineConstants>$(DefineConstants);STRONG_NAME_SIGNING</DefineConstants>
127+
</PropertyGroup>
128+
112129
<!-- Packaging for source link-->
113130
<PropertyGroup>
114131
<DebugType>portable</DebugType>

src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/Abstractions.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,7 @@
1414
<TargetFrameworks>netstandard2.0</TargetFrameworks>
1515
</PropertyGroup>
1616

17-
<!-- Strong name signing ============================================= -->
18-
19-
<!-- When a signing key is specified, we will perform strong name assembly signing. -->
20-
<PropertyGroup Condition="'$(SigningKeyPath)' != ''">
21-
<SignAssembly>true</SignAssembly>
22-
<AssemblyOriginatorKeyFile>$(SigningKeyPath)</AssemblyOriginatorKeyFile>
23-
</PropertyGroup>
24-
<!-- Otherwise, we're not signing, so we are permitted to expose our internals to tests. -->
17+
<!-- When we're not signing, we are permitted to expose our internals to tests. -->
2518
<ItemGroup Condition="'$(SigningKeyPath)' == ''">
2619
<InternalsVisibleTo Include="$(AssemblyName).Test" />
2720
</ItemGroup>

src/Microsoft.Data.SqlClient.Extensions/Azure/src/Azure.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,7 @@
1414
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
1515
</PropertyGroup>
1616

17-
<!-- Strong name signing ============================================= -->
18-
19-
<!-- When a signing key is specified, we will perform strong name assembly signing. -->
20-
<PropertyGroup Condition="'$(SigningKeyPath)' != ''">
21-
<SignAssembly>true</SignAssembly>
22-
<AssemblyOriginatorKeyFile>$(SigningKeyPath)</AssemblyOriginatorKeyFile>
23-
</PropertyGroup>
24-
<!-- Otherwise, we're not signing, so we are permitted to expose our internals to tests. -->
17+
<!-- When we're not signing, we are permitted to expose our internals to tests. -->
2518
<ItemGroup Condition="'$(SigningKeyPath)' == ''">
2619
<InternalsVisibleTo Include="$(AssemblyName).Test" />
2720
</ItemGroup>

src/Microsoft.Data.SqlClient.Extensions/Logging/src/Logging.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,7 @@
1414
<TargetFrameworks>netstandard2.0</TargetFrameworks>
1515
</PropertyGroup>
1616

17-
<!-- Strong name signing ============================================= -->
18-
19-
<!-- When a signing key is specified, we will perform strong name assembly signing. -->
20-
<PropertyGroup Condition="'$(SigningKeyPath)' != ''">
21-
<SignAssembly>true</SignAssembly>
22-
<AssemblyOriginatorKeyFile>$(SigningKeyPath)</AssemblyOriginatorKeyFile>
23-
</PropertyGroup>
24-
<!-- Otherwise, we're not signing, so we are permitted to expose our internals to tests. -->
17+
<!-- When we're not signing, we are permitted to expose our internals to tests. -->
2518
<ItemGroup Condition="'$(SigningKeyPath)' == ''">
2619
<InternalsVisibleTo Include="$(AssemblyName).Test" />
2720
</ItemGroup>

src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,9 @@
1515
</PropertyGroup>
1616

1717
<!-- Trim/AOT Support ================================================ -->
18-
<PropertyGroup>
19-
<IsTrimmable Condition="'$(TargetFramework)' != 'net462'">true</IsTrimmable>
20-
<IsAotCompatible Condition="'$(TargetFramework)' != 'net462'">true</IsAotCompatible>
21-
</PropertyGroup>
22-
23-
<!-- Strong name signing ============================================= -->
24-
25-
<!-- When a signing key is specified, we will perform strong name assembly signing. -->
26-
<PropertyGroup Condition="'$(SigningKeyPath)' != ''">
27-
<SignAssembly>true</SignAssembly>
28-
<AssemblyOriginatorKeyFile>$(SigningKeyPath)</AssemblyOriginatorKeyFile>
18+
<PropertyGroup Condition="'$(TargetFramework)' != 'net462'">
19+
<IsTrimmable>true</IsTrimmable>
20+
<IsAotCompatible>true</IsAotCompatible>
2921
</PropertyGroup>
3022

3123
<!-- References ====================================================== -->

src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@
1515
<Platforms>AnyCPU;x64;x86</Platforms>
1616
</PropertyGroup>
1717

18-
<!-- Strong name signing ============================================= -->
19-
20-
<!-- When a signing key is specified, we will perform strong name assembly signing. -->
21-
<PropertyGroup Condition="'$(SigningKeyPath)' != ''">
22-
<SignAssembly>true</SignAssembly>
23-
<AssemblyOriginatorKeyFile>$(SigningKeyPath)</AssemblyOriginatorKeyFile>
24-
</PropertyGroup>
25-
2618
<!-- CLS Compliance attribute -->
2719
<ItemGroup>
2820
<AssemblyAttribute Include="System.CLSCompliantAttribute">

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,7 @@
2020
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
2121
</PropertyGroup>
2222

23-
<!-- Strong name signing ============================================= -->
24-
25-
<!-- When a signing key is specified, we will perform strong name assembly signing. -->
26-
<PropertyGroup Condition="'$(SigningKeyPath)' != ''">
27-
<SignAssembly>true</SignAssembly>
28-
<AssemblyOriginatorKeyFile>$(SigningKeyPath)</AssemblyOriginatorKeyFile>
29-
</PropertyGroup>
30-
<!-- Otherwise, we're not signing, so we are permitted to expose our internals to tests. -->
23+
<!-- When we're not signing, we are permitted to expose our internals to tests. -->
3124
<ItemGroup Condition="'$(SigningKeyPath)' == ''">
3225
<InternalsVisibleTo Include="UnitTests" />
3326
</ItemGroup>

src/Microsoft.Data.SqlClient/netfx/ref/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010
<Configurations>Debug;Release</Configurations>
1111
</PropertyGroup>
1212

13-
<!-- Strong name signing ============================================= -->
14-
15-
<!-- When a signing key is specified, we will perform strong name assembly signing. -->
16-
<PropertyGroup Condition="'$(SigningKeyPath)' != ''">
17-
<SignAssembly>true</SignAssembly>
18-
<AssemblyOriginatorKeyFile>$(SigningKeyPath)</AssemblyOriginatorKeyFile>
19-
</PropertyGroup>
20-
2113
<!-- CLS Compliance -->
2214
<ItemGroup>
2315
<AssemblyAttribute Include="System.CLSCompliantAttribute">

src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,7 @@
1717
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
1818
</PropertyGroup>
1919

20-
<!-- Strong name signing ============================================= -->
21-
22-
<!-- When a signing key is specified, we will perform strong name assembly signing. -->
23-
<PropertyGroup Condition="'$(SigningKeyPath)' != ''">
24-
<SignAssembly>true</SignAssembly>
25-
<AssemblyOriginatorKeyFile>$(SigningKeyPath)</AssemblyOriginatorKeyFile>
26-
</PropertyGroup>
27-
<!-- Otherwise, we're not signing, so we are permitted to expose our internals to tests. -->
20+
<!-- When we're not signing, we are permitted to expose our internals to tests. -->
2821
<ItemGroup Condition="'$(SigningKeyPath)' == ''">
2922
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
3023
<_Parameter1>UnitTests</_Parameter1>

0 commit comments

Comments
 (0)