How to show application version in VS.NET Deployment Project?

时光毁灭记忆、已成空白 提交于 2019-11-30 05:30:16

问题


I have set up a Deployment Project for my application. The problem is that I want to show application version (eg. MyApplication 1.2.3.1) during installation so the user can see the version before installing.

The only way I can think of is to modify the WelcomeText in Welcome dialog. Is there an easier or more elegant way to achieve this?


回答1:


You should be able to use the Windows Installer ProductVersion property for this. If you change the Welcome dialog's WelcomeText property to:

The installer will guide you through the steps required to install [ProductName] [ProductVersion] on your computer.

Then you can change the Deployment Project's Version property and have the value automatically displayed. Any string-based property can do this; just use the [] syntax to have the value inserted.

For other properties that are provided out of the box, see the Windows Installer Property Reference




回答2:


You can get the version number that is set in the executing AssemblyInfo.cs using this code

System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()

Similarly if you want to get the version number for a specific assembly you can use

System.Reflection.Assembly.GetAssembly([type in my assembly]).GetName().Version.ToString()

You could then change the welcome text automatically at runtime.



来源:https://stackoverflow.com/questions/3222840/how-to-show-application-version-in-vs-net-deployment-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!