固定组件版本有自动递增的文件版本? [英] Fixed Assembly Version with Auto Incremented File Version?

查看:188
本文介绍了固定组件版本有自动递增的文件版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一种更有意义的方式来处理版本为我的应用程序,我来到acrossed此知识库文章

I'm trying to find a more meaningful way to handle versioning for my app and I came acrossed this KB article

http://support.microsoft.com/kb/556041

基本上它的建议,大会版本是固定的,文件版本进行imcremented为每个制作。现在,这个让我感觉良好,但对我的生活中,我似乎无法实现它。

Basically it's recommending that the Assembly version be fixed, and the File Version be imcremented for each build. Now this makes perfect sense to me but for the life of me I can't seem to implement it.

以下代码段自动增量为大会版本和文件版本。

The below snippet auto increments both Assembly version and FileVersion.

[assembly: AssemblyVersion("1.0.*")]

虽然这下一个似乎设置一个固定的程序集版本 1.0.0.0 和固定文件的版本 1.0。*

While this next one seems to set a fixed Assembly version of 1.0.0.0 and a fixed File Version of 1.0.*.

[assembly: AssemblyVersion("1.0")]
[assembly: AssemblyFileVersion("1.0.*")]

顺便说一句,产品版本在文件属性的细节选项卡中读取 1.0。* 现在也是如此。现在,我可以修复的产品版本在文件属性与此...

Incidentally, the Product Version in Details tab of the file properties reads 1.0.* now as well. Now I can fix the Product Version in the file properties with this...

[assembly: AssemblyInformationalVersion("1.0")]

但是,这并不能帮助我原来的任务。出于好奇,我尝试了下面的文件版本改为 2.0。* ,所以它至少是使用它。它只是没有自动递增。

But that doesn't help with my original task. Out of curiosity I tried the below and the File version changed to 2.0.*, so it is at least using it. It's just not auto incrementing.

[assembly: AssemblyVersion("1.0")]
[assembly: AssemblyFileVersion("2.0.*")]

因此​​,从我所知的唯一版本号自动递增是集版本,但在起飞的机会,你没有指定一个文件版本它被设置为相同的程序集的版本。

So from what I can gather the only version number that auto increments is the Assembly Version, but on the off chance you haven't specified a File Version it gets set to the same as the Assembly Version.

有谁知道的一种方式自动递增文件版本,同时使大会版本固定的吗?

Does anyone know of a way to auto increment the File Version while leaving the Assembly Version fixed?

推荐答案

是的,它是一个有点傻,微软似乎已经得到了错误的方式轮。 的AssemblyVersion 用于.NET程序集版本系统,因此你永远不应该自动递增,但 AssemblyFileVersion 写入在该文件的版本资源文件版本的条目,所以你可能会合理地期望它总是自动递增默认情况下。

Yes it's a bit silly, Microsoft seems to have got it the wrong way round. AssemblyVersion is used in the .NET assembly versioning system, so you should never auto-increment it, but AssemblyFileVersion is written to the file version entry in the file's version resource, so you might reasonably expect it to always auto-increment by default.

我敢肯定,有一些第三方构建系统,有可以为你做这一点,但我只是写了一个小的命令行C#应用程序来做到这一点,它被运行在每一个项目作为我们构建的一部分处理。这是非常简单的:

I'm sure that there are some 3rd party build systems out there that can do this for you, but I just wrote a little command line C# app to do it, and it gets run on every project as part of our build process. It's very straightforward:

  1. 阅读的AssemblyInfo.cs 文件一行一行。
  2. 请在正则表达式搜索 AssemblyFileVersion 线,捕捉所有版本四部分为独立的捕捉组。你可以自己分析它,而是一个正则表达式会做所有的检测和解析一气呵成,因此它似乎傻不占便宜。
  3. 一旦你有了四个整数,实现自己的递增逻辑,你认为合适的。
  1. Read the AssemblyInfo.cs file line by line.
  2. Do a RegEx search for the AssemblyFileVersion line, capturing all four version parts into separate capture groups. You could parse it yourself, but a regex will do all the detecting and parsing in one go, so it seems silly not to take advantage.
  3. Once you have the four integers, implement your own incrementing logic as you see fit.

这篇关于固定组件版本有自动递增的文件版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆