linux - 创建强命名程序集时版本 0.0.0.0

标签 linux mono version sn

我们正在为嵌入式 Linux 中的 C 库构建 C# 包装器,我们希望将其安装到目标系统的 GAC 中。

为此,我使用 sn 创建 key 对并使用 mcs 编译代码:

sn -k keypair.snk
mcs /target:library -keyfile:keypair.snk -out:MyLib.dll src/*.cs

现在,构建完成后,我使用 gacutil 将其注入(inject) GAC:

gacutil /i -gacdir /path/to/gac MyLib.dll

我最终得到的是正确的文件结构,但版本号设置为 0.0.0.0:

.../usr/lib/mono/gac/MyLib
.../usr/lib/mono/gac/MyLib/0.0.0.0__3141592653589fff
.../usr/lib/mono/gac/MyLib/0.0.0.0__3141592653589fff/MyLib.dll

我希望包装器的版本与正在使用的底层 C 代码的版本相匹配,所以我的问题(希望)是一个简单的问题。当前版本来自哪里,如何将其变为 3.14.15.9(例如)?

最佳答案

将名为 AssemblyVersion 的程序集级别属性添加到您的 C# 源代码。这通常添加到名为 AssemblyInfo.cs 的文件中:

注意:这是一个自动生成的项目文件的剪切/粘贴,我更新了 AssemblyVersion 属性,您只需包含您希望 CIL 程序集包含的属性

using System.Reflection;
//using System.Runtime.CompilerServices;

// Information about this assembly is defined by the following attributes. 
// Change them to the values specific to your project.

[assembly: AssemblyTitle("Sushi.Task.Lib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("SushiHangover")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("SushiHangover - 2016")]
[assembly: AssemblyTrademark("SushiHangover")]
[assembly: AssemblyCulture("")]

// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("3.14.15.9")]

// The following attributes are used to specify the signing key for the assembly, 
// if desired. See the Mono documentation for more information about signing.

//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

将该源文件添加到您正在编译的其他文件中。

安装它:

>gacutil /i Sushi.Task.Lib.dll

并检索详细信息:

>gacutil /l |grep -i sushi

Sushi.Task.Lib, Version=3.14.15.9, Culture=neutral,....

文件系统:

ls -Rl /Frameworks/Mono.framework/gac | grep -i sushi
drwxr-xr-x   3 root  admin  102 Jun  8 20:25 Sushi.Task.Lib
/Frameworks/Mono.framework/gac/Sushi.Task.Lib:
/Frameworks/Mono.framework/gac/Sushi.Task.Lib/3.14.15.9__629e3fd32ae394a7:.....

关于linux - 创建强命名程序集时版本 0.0.0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37716005/

相关文章:

linux - 如何更改linux gcc版本

elasticsearch - elasticsearch版本编号算法

linux - 在特定模式之前在多个文件中插入文本

f# - 为什么即使使用连续传递风格,遍历大型二叉树也会导致堆栈溢出?

dll - 为什么 Xamarin.Android 重新映射程序集请求?

iphone - 如何隐藏 UINavigationController 的后退按钮?

java - @version 标签是否应该表示该源文件所属的工件的版本,或者该文件上次更改时的版本?

ruby-on-rails - 在 bash 中执行 rake 命令

linux - 通过syslog-ng转发日志

linux - 单元格/BE : make use of the SPEs under Linux