Skip to content

Use StrongNameKeyId rather than directly using AssemblyOriginatorKeyFile: fix PublicKeyToken #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 28, 2020

Conversation

dagood
Copy link
Member

@dagood dagood commented Jul 27, 2020

The projects currently use lines like <AssemblyOriginatorKeyFile>$(KeyFileDir)MSFT.snk</AssemblyOriginatorKeyFile> to set the key to use for strong-name signing. This seems to conflict with the Arcade configuration method, which looks like this:

    <When Condition="'$(StrongNameKeyId)' == 'Microsoft'">
      <PropertyGroup>
        <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)snk/MSFT.snk</AssemblyOriginatorKeyFile>
        <PublicKey>$(MicrosoftPublicKey)</PublicKey>
        <PublicKeyToken>b03f5f7f11d50a3a</PublicKeyToken>
      </PropertyGroup>
    </When>

The result is that the dev branch is building assemblies with the wrong PublicKeyToken. This gets caught when trying to build with bootstrap flow using intermediate nupkgs:

  1. On compile phase 1, NuGet.LibraryModel compiles using Microsoft key against prebuilts from NuGet.org that use Shared key in their identities. This means the intermediate nupkg contains a set of DLLs where the identity is Microsoft with references to Shared identities. This already won't work if used: the output doesn't fulfill its own references.

  2. On compile phase 2, NuGet.LibraryModel compiles using Microsoft key against source-built DLLs with Microsoft identities and references to Shared identities. Csc fails with CS0012 failing to load:

    Errors
        lib/netstandard2.0/NuGet.Commands.cs(1002,63): error CS0012: The type 'LibraryIdentity' is defined in an assembly that is not referenced. You must add a reference to assembly 'NuGet.LibraryModel, Version=5.1.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. [/work/artifacts/source-build/self/src/src/referencePackages/src/nuget.commands/5.1.0/NuGet.Commands.5.1.0.csproj]
        lib/netstandard2.0/NuGet.Commands.cs(1002,63): error CS0012: The type 'NuGetVersion' is defined in an assembly that is not referenced. You must add a reference to assembly 'NuGet.Versioning, Version=5.1.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. [/work/artifacts/source-build/self/src/src/referencePackages/src/nuget.commands/5.1.0/NuGet.Commands.5.1.0.csproj]
        lib/netstandard2.0/NuGet.Commands.cs(1002,63): error CS0012: The type 'LibraryDependencyInfo' is defined in an assembly that is not referenced. You must add a reference to assembly 'NuGet.LibraryModel, Version=5.1.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. [/work/artifacts/source-build/self/src/src/referencePackages/src/nuget.commands/5.1.0/NuGet.Commands.5.1.0.csproj]
        lib/netstandard2.0/NuGet.Commands.cs(1002,63): error CS0012: The type 'IPackageDownloader' is defined in an assembly that is not referenced. You must add a reference to assembly 'NuGet.Packaging, Version=5.1.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. [/work/artifacts/source-build/self/src/src/referencePackages/src/nuget.commands/5.1.0/NuGet.Commands.5.1.0.csproj]
        lib/netstandard2.0/NuGet.Commands.cs(1002,63): error CS0012: The type 'PackageSource' is defined in an assembly that is not referenced. You must add a reference to assembly 'NuGet.Configuration, Version=5.1.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. [/work/artifacts/source-build/self/src/src/referencePackages/src/nuget.commands/5.1.0/NuGet.Commands.5.1.0.csproj]
    

I think that I need to rebuild SBRP with this change to generate new intermediate nupkgs that I can use to get further in the sort-of-bootstrapping work I'm doing now.

I've separated this into one commit per global find-replace. (It touches one line in basically every reference package csproj.)

@dagood dagood requested review from dseefeld and crummel July 27, 2020 22:25
@dagood dagood self-assigned this Jul 27, 2020
@dagood dagood merged commit ac0bb92 into dotnet:dev/source-build-5.0 Jul 28, 2020
@dagood dagood deleted the fix-pub-key branch July 28, 2020 13:10
@dagood
Copy link
Member Author

dagood commented Jul 28, 2020

I confirmed this seems to not be a problem in the pre-Arcade code with a spot check of some DLLs from https://dev.azure.com/dnceng/internal/_build/results?buildId=745172&view=results:

// NuGet.Commands, Version=5.1.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// NuGet.Protocol, Version=5.1.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// System.Diagnostics.DiagnosticSource, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
// System.IO.Pipes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// Microsoft.AspNetCore.Antiforgery, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60

ViktorHofer added a commit to ViktorHofer/source-build-reference-packages that referenced this pull request Mar 16, 2023
Follow-up on dotnet#132 which migrated to use Arcade's strong name key layout.
ViktorHofer added a commit to ViktorHofer/source-build-reference-packages that referenced this pull request Mar 16, 2023
Follow-up on dotnet#132 which migrated to use Arcade's strong name key layout.
ViktorHofer added a commit to ViktorHofer/source-build-reference-packages that referenced this pull request Mar 16, 2023
Follow-up on dotnet#132 which migrated to use Arcade's strong name key layout.
crummel pushed a commit that referenced this pull request Mar 16, 2023
…key (#573)

* Delete snk keys

Follow-up on #132 which migrated to use Arcade's strong name key layout.

* Update Directory.Build.props

* Update System.IO.Compression.4.3.0.csproj

* Update System.IO.Compression.ZipFile.4.3.0.csproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants