2013-03-18 52 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