好的我明白这可能不是传统的,但除此之外:我使用AssemblyFileVersion作为我的" Build Name"串。它形成如下:
' 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(甚至自定义程序集属性)?
答案 0 :(得分:4)
我会使用git describe
来获取表示当前提交的标记/ SHA1的id,并将其集成到Assembly文件中。
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 repo询问各种不同的信息(不仅仅是日期,还有分支,提交者,提交消息......)。
有关实施的详细信息,请参阅DescribeCommand.java
。