gpt4 book ai didi

vb.net - 使用 GIT 自动增加 AssemblyFileVersion

转载 作者:太空狗 更新时间:2023-10-29 13:38:29 24 4
gpt4 key购买 nike

好的,我知道这可能不是传统的,但除此之外:我使用 AssemblyFileVersion 作为我的“构建名称”字符串。它的格式如下:

' File Version information for an assembly consists of the following four values:
'
' Year
' Month
' Day
' Commit Number for that day
'
' Build Name can either be alpha | beta | hotfix | release
' alpha - is a development buildname with rapid changing API
' beta - is a production build for our beta users
' hotfix - is a production version with a bug fix
' release - is a standard issue production version.

<Assembly: AssemblyVersion("0.8.3")>
<Assembly: AssemblyFileVersion("13.10.24.3")>
<Assembly: AssemblyBuildName("alpha")>

不幸的是,我不得不调整 AssemblyInfo.vb 每次 我都进行了 git 提交。现在我知道 GIT 实际上像日志文件一样将提交存储在 .git 目录中的多个位置。我的问题是:有没有办法自动从 git 文件中读取该文件以查看年/月/日/提交#ForThatDay 并自动调整 AssemblyFileVersion(甚至自定义程序集属性)?

最佳答案

我会使用 git describe为了获得代表当前提交的标签/SHA1 的 id,并将其集成到您的程序集文件中。

v1.0-2-g2414721-DEV
^ ^ ^ ^
| | | \-- if a dirtyMarker was given, it will appear here if the repository is in "dirty" state
| | \---------- the "g" prefixed commit id. The prefix is compatible with what git-describe would return - weird, but true.
| \------------- the number of commits away from the found tag. So "2414721" is 2 commits ahead of "v1.0", in this example.
\----------------- the "nearest" tag, to the mentioned commit.

类似于“Automatically versioning Android project from git describe with Android Studio/Gradle”,但要适配vb.net。
或者您可以使用“fake revision number ”。

有关更完整的构建程序集文件生成,请参阅 that maven plugin "maven-git-commit-id-plugin" (同样,要适应 vb.net 构建)。
它可以生成一个完整的文件:

{
"branch" : "testing-maven-git-plugin",
"describe" : "v2.1.0-2-g2346463",
"commitTime" : "06.01.1970 @ 16:16:26 CET",
"commitId" : "787e39f61f99110e74deed68ab9093088d64b969",
"commitIdAbbrev" : "787e39f",
"commitUserName" : "Konrad Malawski",
"commitUserEmail" : "konrad.malawski@java.pl",
"commitMessageFull" : "releasing my fun plugin :-)
+ fixed some typos
+ cleaned up directory structure
+ added license etc",
"commitMessageShort" : "releasing my fun plugin :-)",
"buildTime" : "06.01.1970 @ 16:17:53 CET",
"buildUserName" : "Konrad Malawski",
"buildUserEmail" : "konrad.malawski@java.pl"
}

这说明了如何向 git 存储库询问各种不同的信息(不仅仅是日期,还有分支、提交者、提交消息……)。
查看DescribeCommand.java有关实现的更多详细信息。

关于vb.net - 使用 GIT 自动增加 AssemblyFileVersion,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19578412/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com