9

I'm having a lot of trouble trying to sign a F# class library project. First I've tried this thread, using the AssemblyKeyFileAttribute but had no success. 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. I'm using Visual Studio 2013, and It does not shows the "Signing" tab like C# class library projects.

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.)

What am I doing wrong?

Community
  • 1
  • 1

1 Answers1

6

FWIW, here's how I sign ZeroToNine: Instead of using Visual Studio, I do it as part of the build script. Essentially, it's done by using AssemblyOriginatorKeyFile and SignAssembly:

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. 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.

Here's how I call the build script from 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.

Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
  • This is a nice solution indeed. I didn't know that msbuild has It's own signing mechanism, however I managed to solve the signing problem using ilmerge (assembly linker - al didnt worked too!) although that is not ilmerge purpose. Since this is a better solution than mine, I'll mark it as correct answer. Thanks! – Vinícius Oliveira Jun 08 '15 at 18:07