我在Visual Studio中打开了一个项目(恰好是Enyim.Caching)。这个集会希望延迟签署。事实上,它需要如此强烈地延迟签名,我无法强制Visual Studio编译它没有延迟签名。
我在Visual Studio项目属性框中取消选中“仅延迟符号”和“签署程序集”,然后重新构建。程序集仍标记为延迟符号(如sn.exe -v
所示)。
我已卸载项目并验证签名是否设置为false。重新加载项目时,将选中“签名”和“延迟签名”复选框。
我已经确认AssemblyInfo(或其他地方)中没有可能导致此问题的属性。
我在互联网上搜索了一个解决方案,但没找到。
我该怎么做?
答案 0 :(得分:9)
在这种情况下,问题是项目“常用属性”引用。
项目内部.csproj文件是这个无害的小行:
< Import Project =“.. \ build \ 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>
答案 1 :(得分: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.
好像是VS的一个bug。我正在使用的版本:
Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel
Microsoft .NET Framework
Version 4.5.50709 SP1Rel