内部版本号增量未反映在 AssemblyVersion 中
我浏览了一些关于自动递增版本号的讨论,但由于年轻人的不耐烦,我决定自己动手并重新发明轮子。我知道可能有更好的方法来解决这个问题(我肯定会调查),但我的问题更多地围绕 Assembly 和/或 Version 类。
我的方法是编写一个单独的 exe (BuildIncrementer),它采用命令行参数作为文件名,对内容进行正则表达式匹配以获取 [assemble: AssemblyVersion...]
字符串,执行以下操作我想要的修改(增加内部版本号等),然后将内容写回文件。这种方法按原样工作。
我做的下一件事是在我想要使用它的项目中,我设置了一个预构建命令行,该命令行只是在该项目的 AssemblyInfo.cs 文件上执行 BuildIncrementer.exe 的命令。这也有效,可以根据需要更新程序集信息。
当我运行该项目时,问题出现了,它发送了一封包含当前版本的电子邮件,该版本是通过 Assembly.GetExecutingAssembly().GetName().Version.ToString() 获取的。但是,显示的版本是之前的版本。当我的 AssemblyInfo.cs 显示 [assemble: AssemblyVersion("1.0.2.49667")]
时,我收到 1.0.1.45660,这是之前的版本。
任何人都知道为什么会这样?
I've browsed through some of the discussion on auto-incrementing build numbers, but in the impatience of youth decided to roll my own and re-invent the wheel. I know there are probably better ways to go about this (which I'm definitely going to investigate), but my question centers more around the Assembly and/or Version classes.
My approach was to write a separate exe (BuildIncrementer) that takes a command line parameter for file name, does a regex match on the contents to grab the [assembly: AssemblyVersion...]
string, do the modifications that I want (increment the build number, etc.), then write the contents back to the file. This approach works as-is.
The next thing I did was in the project that I wanted to use this on, I set up a pre-build command line that is simply the command to execute that BuildIncrementer.exe on this project's AssemblyInfo.cs file. This too works, updating the assembly info as desired.
The problem comes when I run the project, it sends an email containing the current version, obtained with Assembly.GetExecutingAssembly().GetName().Version.ToString()
. BUT, the version showing up is the previous version. When my AssemblyInfo.cs says [assembly: AssemblyVersion("1.0.2.49667")]
, I get sent 1.0.1.45660, which was the previous build.
Anyone have any ideas why that might be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您的 exe 在整个构建过程完成(或开始)之前运行,因此反映了旧版本......也许
I think your exe runs before your entire build process gets completed(or gets started) hence reflecting an old vesion...maybe