Strong Naming an assembly using command line compile

Posted by David on Stack Overflow See other posts from Stack Overflow or by David
Published on 2010-05-18T14:03:41Z Indexed on 2010/05/18 14:20 UTC
Read the original article Hit count: 979

Filed under:
|
|
|
|

I am trying to use NAnt in order to compile and sign an assembly using the vbc compiler. I have a project set up and am able to successfully sign the assembly compiling with VS2010. When I try to sign it using the command line I get this error:

vbc : error BC30140: Error creating assembly manifest: Error signing assembly -- The parameter is incorrect.

I even created a trivially simple app (just an assemblyinfo.vb file) that will not compile and sign using vbc.exe What am I doing wrong?

here is my assemblyinfo.vb:

Option Strict Off
Option Explicit On

Imports System
Imports System.Reflection
<Assembly: AssemblyVersionAttribute("2010.05.18.0918"),  _
 Assembly: AssemblyCopyrightAttribute("Copyright © Patient First 2007"),  _
 Assembly: AssemblyCompanyAttribute("Patient First, Inc."),  _
 Assembly: AssemblyProductAttribute("Patient First Framework"),  _
 Assembly: AssemblyDelaySign(false),  _
 Assembly: AssemblyKeyFile("test.pfx"), _
 Assembly: AssemblyTitleAttribute("PatientFirst.Framework")>

test.pfx is located in the same folder as assemblyinfo.vb

Here is how I am trying to compile it:

vbc /target:library /verbose assemblyinfo.vb

I also tried using

vbc /target:library /verbose assemblyinfo.vb /keyfile:test.pfx

and tried using /keyfile parameter without the AssemblyDelaySign and AssemblyKeyFile attributes

If I remove the AssemblyDelaySign and AssemblyKeyFile attributes and leave off the /keyfile command line parameter it compiles fine. What is the correct way to do this with vbc?

--EDIT: I have found that MSBuild also does not like having the AssemblyKeyFile attribute as I have defined it in the AssemblyInfo.vb, it gives the same failure message. So the only way I can currently get this to build correctly is to set properties on the project to tell it which key file to use and to sign the assembly.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about vb.net