增强的强命名 [英] Enhanced Strong Naming

查看:66
本文介绍了增强的强命名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试增强型强命名( http://msdn.microsoft.com/en-us/library/hh415055.aspx ),并且在将其纳入构建过程时遇到了一些问题.根据本文所述,您必须先对程序集进行延迟签名,然后再对它们进行重新签名,以获取正确的增强字符串名称.这不适用于构建过程.通常,我们在开发时延迟对程序集进行签名,然后在构建服务器上对它们进行完全签名.有没有人对增强强命名有任何经验?

I am testing Enhanced Strong Naming (http://msdn.microsoft.com/en-us/library/hh415055.aspx) and having some problems getting it into a build process. According to the article you have to delay-sign assemblies first and then re-sign them to get proper Enhanced String Name. That does not work well with the build process. Usually we delay-sign assemblies while developing, and fully sign them on build servers. Does anyone have any experience with Enhanced Strong Naming?

也发布在推荐答案

我不确定这是否是 @hbw 指的是他的话:

I'm not sure if this is what @hbw was referring to when he said:

...似乎已经有人建议在MSDN论坛上使用MSBuild任务

... it looks like someone already suggested using MSBuild tasks on the MSDN forum

但是,我一直在使用的解决方案是:

But, the solution I've been using is:

  1. 使用Microsoft在文档,用于将完整snk文件(具有公共密钥和私有密钥的密钥)密钥中的公共密钥导出到单独的.snk文件中.
    sn.exe -p FullKeyPair.snk PubKeySha256.snk sha256

  1. Use the steps Microsoft outlines at the bottom of their Enhanced Strong Naming documentation for exporting the public key from the full snk file (the one with both public and private keys) key into separate .snk file.
    sn.exe -p FullKeyPair.snk PubKeySha256.snk sha256

配置Visual Studio以使用 PubKeySha256.snk (在项目属性的 Signing 部分下)对项目程序集进行延迟签名.

Configure Visual Studio to delay-sign the project assemblies using PubKeySha256.snk (under the Signing section of your project properties).

创建一个运行后的构建后事件(在项目属性的 Build Events 部分中):
< sn.exe的路径>"-Ra"$(TargetPath)"< FullKeyPair.snk的路径"".

例如,我的解决方案将这些关键文件(以及sn.exe工具和相关文件)存储在解决方案正下方的名为"Build Tools"的目录中.因此,我的构建后事件运行:
"$(SolutionDir)生成工具\ sn.exe" -Ra"$(TargetPath)""$(SolutionDir)生成工具\ FullKeyPair.snk"

Create a post-build event (in the Build Events section of your project properties) that runs:
"<path to sn.exe>" -Ra "$(TargetPath)" "<path to FullKeyPair.snk>".

For example, my solution stores these key files (and the sn.exe tool and dependent files) in a directory named "Build Tools" directly under the solution. So, my post-build event runs:
"$(SolutionDir)Build Tools\sn.exe" -Ra "$(TargetPath)" "$(SolutionDir)Build Tools\FullKeyPair.snk"

如果您想像我一样将sn.exe工具复制到解决方案下的目录中(我建议这样做),则需要从SDK目录中复制以下文件:

If you want to copy your sn.exe tool to a directory under solution like I did (I recommend this), you'll need to copy the following files from the SDK directory:

  • sn.exe
  • sn.exe.config
  • snrc.dll

如果您不想这样做,那么您的项目/构建后版本将取决于您决定对所有正在构建项目的开发人员使用相同的SDK路径.在这种情况下,您的构建后内容应类似于:

If you don't want to do that, then your project/post-build will be dependent the SDK path you decide to use being the same for all developers that are building your project. Your post-build in that scenario would look something like:

SET SDKTools=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64

"%SDKTools%\sn.exe" -Ra "$(TargetPath)" "$(ProjectDir)FullKeyPair.snk"

这篇关于增强的强命名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆