Search code examples
visual-studio-2017.net-assemblystrongname

Visual Studio 2017 does not sign an assembly


I need to make an assembly, which I have developed in C# under Visual Studio 2017, a strong-named assembly.
My customer provided me with an .snk file, and I turned on the Sign the assembly checkbox in the Signing tab of my project properties. Under the hood, in the .csproj file the following elements were added:

    <SignAssembly>true</SignAssembly>
    <AssemblyOriginatorKeyFile>ZZZ.snk</AssemblyOriginatorKeyFile>
    <DelaySign>false</DelaySign>

The issue is that the produced assembly is not signed.

Another visible awkwardness, which may indicate the cause of the issue, is that in spite of having

    <DelaySign>false</DelaySign>

in the .csproj file, every time I open the Signing tab the Delay sign only checkbox is in an undefined state as shown below

I am quite lost here and in the community here I trust.
Thank you all in advance for your help.

A few details on the my environment:

    Visual Studio Enterprise 2017
    Version 15.9.14
The project is in the new format and targets .NET 4.7.1

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFramework>net471</TargetFramework>

Solution

  • The answer is quite embarrassing; however, I owe it to the community:
    Quoting the question "The issue is that the produced assembly is not signed."
    Now, how did I check that the assembly is signed or not? By running sn -v bin\x64\Release\XYZ.dll
    Well, the bin\x64\Release indeed contained an obsolete copy of XYZ.dll for the reason, which I could not even remember right now.
    The produced assembly is actually placed in bin\Release\net471, and running sn -v bin\Release\net471\XYZ.dll confirms that the assembly is signed...

    Well, that is it :o|