Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove signing from an assembly

I have a project open in Visual Studio (it happens to be Enyim.Caching). This assembly wants to be delay-signed. In fact, it desires so strongly to be delay-signed, that I am unable to force Visual studio to compile it without delay signing.

  1. I have unchecked "Delay sign only" and "Sign the assembly" on the Visual Studio project properties box, and rebuilt. The assembly is still marked for delay sign (as shown by sn.exe -v).

  2. I have unloaded the project and verified that the signing is set to false. When reloading the project, the check boxes for "Sign" and "Delay Sign" are checked.

  3. I have verified that no attributes are present in the AssemblyInfo (or elsewhere) that would cause this.

  4. I have searched the Internet for a solution, but have found none.

How can I do this?

like image 218
theMayer Avatar asked Mar 18 '13 03:03

theMayer


1 Answers

In this case, the problem is a project "common properties" reference.

Inside of the project .csproj file is this innocuous little line:

<Import Project="..\build\CommonProperties.targets" />

Unfortunately, the file (CommonProperties.targets) instructs VS to re-write the properties, but it does not provide any clear indication in the user interface that this is taking place.

The solution is to go into the CommonProperties.targets file and delete the following lines:

<!-- delay sign the assembly if the PrivateKeyPath property is not specified -->
<PropertyGroup Condition=" '$(PrivateKeyPath)' == '' And '$(PrivateKeyName)' == ''">
    <AssemblyOriginatorKeyFile>..\public_key.snk</AssemblyOriginatorKeyFile>
    <DelaySign>true</DelaySign>
</PropertyGroup>

<!-- sign the assembly using the specified key file containing both the private and public keys -->
<PropertyGroup Condition=" '$(PrivateKeyPath)' != '' ">
    <AssemblyOriginatorKeyFile>$(PrivateKeyPath)</AssemblyOriginatorKeyFile>
    <DelaySign>false</DelaySign>
</PropertyGroup>

<!-- sign the assembly using the specified key container containing both the private and public keys -->
<PropertyGroup Condition=" '$(PrivateKeyName)' != '' ">
    <AssemblyOriginatorKeyFile></AssemblyOriginatorKeyFile>
    <DelaySign>false</DelaySign>
</PropertyGroup>

Replace those lines with the following:

  <PropertyGroup>
    <DelaySign>false</DelaySign>
    <SignAssembly>false</SignAssembly>
  </PropertyGroup>
like image 135
theMayer Avatar answered Oct 14 '22 14:10

theMayer