发布 .NET Core 时如何解决 PFX 签名不受支持的错误
How to work around the PFX signing not supported error when publishing .NET Core
我一直在尝试使用 PFX 文件对程序集进行签名。一切正常,我在 Visual Studio 访问了 Properties/Signing 但每当我 运行 dotnet publish 命令时,我都会收到此错误:
C:\Program Files\dotnet\sdk.1.201\Microsoft.Common.CurrentVersion.targets(3210,5): .NET Core 不支持错误 PFX 签名
我一直在寻找解决这个问题的方法,但到目前为止还没有成功。
所以我认为我应该使用 SNK 签名而不是 PFX,因为 PFX 不再支持它。
- 从 PFX 导出 public 密钥:
sn -p key.pfx key.pub
- 通过将
<DelaySign>true</DelaySign>
添加到项目文件或通过 AssemblyDelaySignAttribute
为程序集启用延迟签名。使用步骤 1 中的 public 密钥而不是 PFX 进行签名。
- 构建后重新签署程序集:
sn -R assembly.dll key.pfx
https://docs.microsoft.com/en-us/dotnet/framework/tools/sn-exe-strong-name-tool
我一直在尝试使用 PFX 文件对程序集进行签名。一切正常,我在 Visual Studio 访问了 Properties/Signing 但每当我 运行 dotnet publish 命令时,我都会收到此错误:
C:\Program Files\dotnet\sdk.1.201\Microsoft.Common.CurrentVersion.targets(3210,5): .NET Core 不支持错误 PFX 签名
我一直在寻找解决这个问题的方法,但到目前为止还没有成功。
所以我认为我应该使用 SNK 签名而不是 PFX,因为 PFX 不再支持它。
- 从 PFX 导出 public 密钥:
sn -p key.pfx key.pub
- 通过将
<DelaySign>true</DelaySign>
添加到项目文件或通过AssemblyDelaySignAttribute
为程序集启用延迟签名。使用步骤 1 中的 public 密钥而不是 PFX 进行签名。 - 构建后重新签署程序集:
sn -R assembly.dll key.pfx
https://docs.microsoft.com/en-us/dotnet/framework/tools/sn-exe-strong-name-tool