使用命令行编译强命名程序集

发布于 2024-09-02 03:55:25 字数 1544 浏览 7 评论 0原文

我正在尝试使用 NAnt 来使用 vbc 编译器编译和签署程序集。我已经设置了一个项目,并且能够成功签署使用 VS2010 编译的程序集。当我尝试使用命令行对其进行签名时,出现此错误:

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

我什至创建了一个非常简单的应用程序(只是一个 assemblyinfo.vb 文件),该应用程序不会使用 vbc.exe 进行编译和签名 我做错了什么?

这是我的 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 与 assemblyinfo.vb 位于同一文件夹中

以下是我尝试编译它的方式:

vbc /target:library /verbose assemblyinfo.vb

我还尝试使用

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

并尝试使用 /keyfile 参数而不使用 AssemblyDelaySign 和 AssemblyKeyFile 属性

如果我删除AssemblyDelaySign 和 AssemblyKeyFile 属性并保留 /keyfile 命令行参数,它可以正常编译。使用 vbc 执行此操作的正确方法是什么?

- 编辑: 我发现 MSBuild 也不喜欢具有 AssemblyKeyFile 属性,因为我在 AssemblyInfo.vb 中定义了它,它给出了相同的失败消息。因此,我当前正确构建此项目的唯一方法是在项目上设置属性,以告诉它要使用哪个密钥文件并对程序集进行签名。

- 编辑: 这似乎可以在 VS2010 中构建项目的原因是 msbuild 在命令行上将 /keycontainer 传递给 vbc.exe,而不是使用 /keyfile。仍然不知道如何使用 /keyfile 命令行参数。

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.

--EDIT:
The reason this appears to work building the project from within VS2010 is that msbuild is passing /keycontainer to vbc.exe on the command line instead of using /keyfile. Still don't know how to use the /keyfile command line parameter.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蛮可爱 2024-09-09 03:55:25

我发现 MSBuild 也不喜欢具有 AssemblyKeyFile 属性,因为我在 AssemblyInfo.vb 中定义了它,它给出了相同的失败消息。因此,我当前正确构建此项目的唯一方法是在项目上设置属性,以告诉它要使用哪个密钥文件并对程序集进行签名。

之所以能够在 VS2010 中构建项目,是因为 msbuild 在命令行上将 /keycontainer 传递给 vbc.exe,而不是使用 /keyfile。仍然不知道如何使用 /keyfile 命令行参数。

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.

The reason this appears to work building the project from within VS2010 is that msbuild is passing /keycontainer to vbc.exe on the command line instead of using /keyfile. Still don't know how to use the /keyfile command line parameter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文