2013-03-18 109 views
7

我有一个在Visual Studio中打开的项目(它恰好是Enyim.Caching)。这个程序集想要延迟签名。实际上,它渴望如此强烈地被延迟签名,以至于我无法迫使Visual Studio编译它而没有延迟签名。从程序集中删除签名

  1. 我都不选中“仅延迟签名”和“登录大会”上的Visual Studio项目属性框,并重修。该组件仍标记为延迟标志(如sn.exe -v所示)。

  2. 我已卸载项目并验证签名设置为false。重新加载项目时,选中“Sign”和“Delay Sign”复选框。

  3. 我已验证在AssemblyInfo(或其他地方)中不存在会导致此问题的属性。

  4. 我已经在互联网上搜索解决方案,但没有找到。

我该怎么做?

回答

9

在这种情况下,问题是项目“共同属性”的参考。

里面的项目的.csproj文件是这个无害的小线:

<导入项目= “.. \建立\ CommonProperties.targets”/ >

不幸的是,该文件(CommonProperties.targets)指示VS重写属性,但它不会在用户界面中提供任何明确的指示,表明正在发生这种情况。在我看来,设计这个的人应该被涂抹和羽毛。

解决的办法是进入CommonProperties.targets文件并删除以下行:

<!-- 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> 

使用以下内容替换这些行:

<PropertyGroup> 
    <DelaySign>false</DelaySign> 
    <SignAssembly>false</SignAssembly> 
    </PropertyGroup> 
+0

感谢您的回答....同样的问题,相同的程序集。为我节省了大量的头发:) – GrahamB 2013-09-19 15:21:03

+0

如果这不能解决问题,您还可以看到'AssemblyInfo.cs'中的内容:http://stackoverflow.com/a/13200542/1869660 – Sphinxxx 2016-03-29 21:21:05

0

会见了同样的问题。我禁用即使在“延迟仅注册”和“登录大会”,我还是得到了错误

error MSB3325: Cannot import the following key file: . The key file may be password protected". 

而.csproj的是正确的:

<PropertyGroup> 
    <SignAssembly>false</SignAssembly> 
    <DelaySign>false</DelaySign> 
</PropertyGroup> 

然而,有下面一个更棘手的行:

<SignAssembly Condition="Exists('..\xxx.pfx')">true</SignAssembly> 

后,才去除.csproj的线路,或删除的磁盘上的文件,那么VS是OK去。

看起来像VS的错误。我正在使用的版本:

Microsoft Visual Studio 2010 
Version 10.0.40219.1 SP1Rel 
Microsoft .NET Framework 
Version 4.5.50709 SP1Rel