如何使安装程序的版本号与已安装程序集的版本号保持同步? [英] How to keep the installer's version number in sync with the installed assemblies' version numbers?

查看:23
本文介绍了如何使安装程序的版本号与已安装程序集的版本号保持同步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我当前的项目中,我每周发布一次.我一直在使用 这篇文章 使我的项目中所有程序集的版本号保持同步.(我目前没有任何充分的理由单独跟踪程序集的版本号,但我确信这一天最终会到来.)

In my current project, I'm producing weekly releases. I've been using the technique described in this post to keep the version numbers of all of the assemblies in my project in sync. (I don't presently have any good reason to track the assemblies' version numbers separately, though I'm sure that day will eventually come.)

当我推出一个版本时,我会构建一个新版本的安装程序.与可以从共享的 SolutionInfo.cs 文件中获取版本号的所有程序集不同,安装程序的版本号不是,据我所知,不是程序集属性.所以我的发布过程包括在安装项目中手动推进版本号.

When I push out a release, I build a new version of the installer. Unlike all of the assemblies, which can get their version numbers from a shared SolutionInfo.cs file, the version number of the installer isn't, as best I can tell, an assembly property. So my release process includes manually advancing the version number in the setup project.

或者,我应该说,通常包括这样做.我想把它变成我不能搞砸的东西.我发现安装和部署项目的文档令人惊讶地不透明(如果用户将 MSI 安装到非默认路径,则很难找出如何使 MSI 正确卸载,这是一个非常奇怪的常见用例没有记录)并且不知道是否有可能做到这一点.

Or, I should say, usually includes doing that. I'd like to turn that into something I can't screw up. I'm finding the documentation of setup and deployment projects to be surprisingly opaque (it was quite a bit harder to find out how to make it possible for the MSI to uninstall properly if the user installed it to a non-default path, which is a pretty freaking common use case to be undocumented) and have no idea if it's even possible to do this.

有什么想法吗?

澄清一下,这是我正在谈论的 Visual Studio 设置和部署项目.

Just to clarify, this is a Visual Studio setup and deployment project I'm talking about.

推荐答案

CodeProject 有一个脚本来设置 MSI 文件的版本号,您可以在安装项目的预构建步骤中运行该脚本.你可以在这里找到它:

CodeProject has a script to set the version number of an MSI file, which you could run in the pre-built step of the setup project. You find it here:

http://www.codeproject.com/KB/install/NewSetupVersion.aspx

更多详情

请注意,使用 Windows Installer 时事情会复杂一些.MSI 文件(作为您使用 VS 安装和部署项目创建的文件)不仅具有版本号,还具有作为 GUID 值的产品代码.Windows Installer 使用此产品代码来唯一标识您的产品,例如在控制面板 -> 添加或删除程序中,您可以在其中决定卸载或修复产品.

Be aware that with Windows Installer things are a bit more complicated. MSI files (as the one that you create using a VS Setup and Deployment project) not only have a version number but also a product code which is a GUID value. This product code is used by Windows Installer to uniquely identify your product e.g. in Control Panel -> Add Or Remove programs where you can decide to uninstall or repair a product.

但是,当您更改 MSI 版本号时,在许多情况下也必须更改此产品代码.MSI 技术的文档很少,但您可以在以下 MSDN 页面上找到一些何时更改产品代码的建议:http://msdn.microsoft.com/en-us/library/aa367850(VS.85).aspx.

However, when changing you MSI version number, this product code must also be changed in a number of cases. MSI technology is poorly documented but you can find some recommendations when to also change the product code on the following MSDN page: http://msdn.microsoft.com/en-us/library/aa367850(VS.85).aspx.

在我的项目中,我总是为每个新版本生成一个新的产品代码.CodeProject 上的脚本也会为您更改产品代码.

In my projects I always generate a new product code for every new version. The script on CodeProject will also change the product code for you.

还有一件事:Windows Installer 只检查版本号 afaik 的前三位,第四位的任何内容都将被忽略,即 2.3.0.1234 被认为等于 2.3.0.5678.(产品版本)

And one more thing: Windows Installer only checks the first three places of the version number afaik, anything in the forth place will be ignored, i.e. 2.3.0.1234 is considered equal to 2.3.0.5678. (ProductVersion)

(CodeProject 上有一篇相关文章,您可能也会感兴趣:http://www.codeproject.com/KB/install/VersionVDProj.aspx)

(There is a related article on CodeProject which might also be interesting to you: http://www.codeproject.com/KB/install/VersionVDProj.aspx)

这篇关于如何使安装程序的版本号与已安装程序集的版本号保持同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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