英文:
How to set the "file version" field in PE header of EXE files?
问题
我使用go build
命令来构建一个exe
文件。然后我查看文件的属性(右键点击文件->属性),在“详细信息”选项卡中,文件的版本为空。
我该如何设置exe
文件的版本?
英文:
I use go build
to build a exe
file.Then i view the property of the file(Right click the file -> property),In detail
tab,the file's version is empty.
How i to set the version of the exe
file.
答案1
得分: 9
EXE文件版本和其他信息被嵌入为资源,这些资源是特定于Windows的,因此Go编译器不支持。你可以使用GoVersionInfo包来实现这一点(它还支持嵌入图标)。我自己没有尝试过,但它看起来很有前途,并且有很好的文档说明。
英文:
The EXE file version and other info are embedded as resources, which are specific to Windows and thus not supported by the Go compiler. You can use the package GoVersionInfo to accomplish this (it also supports embedding an icon). I haven't tried it myself, but it looks promising and well documented.
答案2
得分: 3
有一个名为go-winres的工具可以帮助你实现这个目标,你可以在go build
之前或之后使用它。
运行go install github.com/tc-hib/go-winres@latest
来安装它。
然后,在你的项目文件夹中运行go-winres init
,这将创建一个名为winres
的子文件夹。
修改winres/winres.json
文件,替换图标。
运行go-winres make
,这将创建一个.syso
文件。
然后运行go build
,查看结果。
如果你想添加一种语言,readme文件中有一个示例。我没有成功使用goversioninfo
来实现,但使用go-winres
可以。
英文:
There is go-winres which lets you do this, either before or after go build
.
Run go install github.com/tc-hib/go-winres@latest
to install it.
Then, inside your project folder, run go-winres init
. This creates a subfolder named winres
.
Modify winres/winres.json
, and replace the icon.
Run go-winres make
. This creates a .syso
file.
Run go build
and see the result.
If you want to add a language, there's an example in the readme file. I didn't manage to do it with goversioninfo
, while it works with go-winres
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论