Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Strong name signing fails with the PublicSign option #11546

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

Closed
robertpi opened this issue May 11, 2021 · 2 comments
Closed

Strong name signing fails with the PublicSign option #11546

robertpi opened this issue May 11, 2021 · 2 comments
Labels
Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.

Comments

@robertpi
Copy link
Contributor

Using the MSBuild property 'PublicSign' causes strong name signing to fail and breaks the build.

Repro steps

Create a new F# project:

dotnet new classlib --language F#

Create a new strong named key:

sn -k sgKey.snk

Add the following property group to the fsproj file:

  <PropertyGroup>
    <SignAssembly>true</SignAssembly>
    <AssemblyOriginatorKeyFile>sgKey.snk</AssemblyOriginatorKeyFile>
    <PublicSign>true</PublicSign>
    <DelaySign>false</DelaySign>
  </PropertyGroup>

Build and you'll see the following output:

c:\code\fsharp-publicsign-repo
>dotnet build
Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
FSC : error FS2014: A problem occurred writing the binary 'c:\code\fsharp-publicsign-repo\obj\Debug\net5.0\fsharp-publicsign-repo.dll': A call to StrongNameSignatureSize failed (Invalid Public Key blob) [c:\code\fsharp-publicsign-repo\fsharp-publicsign-repo.fsproj]

Build FAILED.

FSC : error FS2014: A problem occurred writing the binary 'c:\code\fsharp-publicsign-repo\obj\Debug\net5.0\fsharp-publicsign-repo.dll': A call to StrongNameSignatureSize failed (Invalid Public Key blob) [c:\code\fsharp-publicsign-repo\fsharp-publicsign-repo.fsproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.32

Same method works fine without PublicSign option.

Related information

  • Operating system

Tested on:

Ubuntu 18.04 LTS

Edition Windows 10 Pro
Version 20H2
OS build 19042.928

  • .NET Core 5.0.202
@cartermp
Copy link
Contributor

Curious, is there a reason to use strong name signing for you? It's discouraged unless you're on .NET Framework.

@KevinRansom KevinRansom added Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. labels Jul 7, 2021
@dsyme
Copy link
Contributor

dsyme commented Mar 3, 2022

You have to do this

sn -p sgKey.snk sgKey.pub

and

    <AssemblyOriginatorKeyFile>sgKey.pub</AssemblyOriginatorKeyFile>
    <PublicSign>true</PublicSign>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Projects
None yet
Development

No branches or pull requests

4 participants