好的,我知道这可能不是传统的,但除此之外:我使用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")>很不幸,我每次做git提交时,都必须调整AssemblyInfo.vb 。现在我知道GIT实际上将提交存储在.git目录中的几个位置,就像日志文件一样。我的问题是:是否有自动读取该文件的git文件来查看年份/月/日/提交#ForThatDay并自动调整AssemblyFileVersion (甚至是自定义程序集属性)?
发布于 2013-11-01 22:31:42
我将使用git describe来获取表示当前提交的标记/SHA1 1的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“。
有关更完整的生成程序集文件,请参见" (同样,要适应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。
https://stackoverflow.com/questions/19578412
复制相似问题