简体   繁体   English

.NET版本号(安装程序版本)

[英].NET Version Number (Installer Version)

I'm trying to add a feature to my winforms app that prints the version number on the main screen. 我正在尝试为我的winforms应用程序添加一个功能,在主屏幕上打印版本号。 I currently have this: 我目前有这个:

txtVersion.Text = ProductVersion.ToString();

Which tells me the version of the program – all well and good. 这告诉我程序的版本 - 一切都很好。

However, what I'd ideally like it to do is to pick up the version of the installer program that was used to create the msi. 但是,我理想的做法是选择用于创建msi的安装程序版本。 Is there a way to either interrogate this from within the installed program, or to transfer the information during installation somehow? 有没有办法在安装的程序中询问这个问题,或者在安装过程中以某种方式传输信息?

It sounds like you want the ProductVersion property . 听起来你想要ProductVersion属性 You can get that at run time by calling the ::MsiGetProductInfo() function providing the ProductCode for the MSI that installed you. 您可以通过调用:: MsiGetProductInfo()函数在运行时获取该函数 ,该函数为安装了您的MSI提供ProductCode。

If doesn't work out for you, then writing the ProductVersion to a registry key and reading that at run-time is fairly popular. 如果没有为您服务,那么将ProductVersion写入注册表项并在运行时读取它是相当流行的。 You can use that registry key to solve the ICE38 troubles described here as well: http://robmensching.com/blog/posts/2007/4/27/How-to-create-an-uninstall-shortcut-and-pass-all-the 您可以使用该注册表项来解决此处描述的ICE38问题: http ://robmensching.com/blog/posts/2007/4/27/How-to-create-an-uninstall-shortcut-and-pass- 一切

最好不要从安装程序中获取应用程序版本,而是从app(AssemblyInfo.cs),imo获取安装程序版本。

您可以在安装期间将版本保存在注册表项中,然后从程序中查询注册表项。

You can very well do from your installation program (MSI) through custom actions using Wix3 您可以通过使用Wix3的自定义操作从安装程序(MSI)中完成

Following links can get you started 以下链接可以帮助您入门

WIX at Sourceforge 来自Sourceforge的WIX

Wix Tutorial Wix教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM