简体   繁体   English

签署F#程序集

[英]Signing F# Assembly

I'm having a lot of trouble trying to sign a F# class library project. 我在尝试签署F#类库项目时遇到了很多麻烦。 First I've tried this thread , using the AssemblyKeyFileAttribute but had no success. 首先,我使用AssemblyKeyFileAttribute尝试了这个线程 ,但没有成功。 I also tried to add the flag "--keyfile:keyfile.snk" to the project properties ("Other Flags" field in "Build" tab) and It did't worked too. 我还尝试将标志“--keyfile:keyfile.snk”添加到项目属性(“构建”选项卡中的“其他标志”字段),它也没有用。 I'm using Visual Studio 2013, and It does not shows the "Signing" tab like C# class library projects. 我正在使用Visual Studio 2013,它没有像C#类库项目那样显示“签名”选项卡。

All the attempts results in the following error: 所有尝试都会导致以下错误:

FSC: error FS2014: A problem occurred writing the binary 'obj\\Release\\ExcelFinancialFunctions.dll': A call to StrongNameGetPublicKey failed (Value does not fall within the expected range.) FSC:错误FS2014:写入二进制文件'obj \\ Release \\ ExcelFinancialFunctions.dll'时出现问题:对StrongNameGetPublicKey的调用失败(值不在预期范围内。)

What am I doing wrong? 我究竟做错了什么?

FWIW, here's how I sign ZeroToNine : Instead of using Visual Studio, I do it as part of the build script. FWIW,这是我如何签署ZeroToNine :我不是使用Visual Studio,而是将其作为构建脚本的一部分。 Essentially, it's done by using AssemblyOriginatorKeyFile and SignAssembly : 基本上,它是通过使用AssemblyOriginatorKeyFileSignAssembly

MSBuild.exe /property:AssemblyOriginatorKeyFile=mykey.snk /property:SignAssembly=true

You can see (almost) all the nitty-gritty details in the ZeroToNine repo, including the actual build script I use for signing . 您可以看到(几乎)ZeroToNine仓库中的所有细节,包括我用于签名的实际构建脚本 The only detail missing from the public repo is the actual .snk file, because it would make no sense to have a strong name key if it was publicly available. 公共存储库中唯一缺少的细节是实际的.snk文件,因为如果它是公开可用的,那么拥有强名称密钥是没有意义的。

Here's how I call the build script from Bash: 以下是我从Bash调用构建脚本的方法:

build-release.sh ../ZeroToNine.snk

As you can see, I have my .snk file residing outside of the repo, and pass it in as an argument to the script. 如您所见,我将.snk文件驻留在repo之外,并将其作为参数传递给脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM