如何获得发布版本? [英] how to get publish version?

查看:136
本文介绍了如何获得发布版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示我的桌面应用程序的发布版本.我正在尝试使用以下代码:

I would like to show the publish version of my desktop application. I am trying to do it with this code:

_appVersion.Content = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

问题是我没有完全获得项目属性中的发布版本.下面是它的屏幕截图:

The problem is that I am not getting exactly the publish version I have in my project properties. Below is a screenshot of it:

但是我得到了3.0.0.12546.有人知道问题出在哪里吗?

But I am getting 3.0.0.12546. Does someone know where is the problem?

推荐答案

我也遇到了这个问题,发现AssemblyInfo.cs中设置的版本号干扰了Properties中设置的版本号:

I was also having this issue and found that the version number set in AssemblyInfo.cs was interfering with the one set in Properties:

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

我通常从AssemblyInfo中注释掉这些行,并用

I usually comment those lines out of AssemblyInfo and replace them with

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

检查这些值是否已硬编码到您的AssemblyInfo文件中.

Check whether these values have been hard-coded into your AssemblyInfo file.

请参见此SO问题关于自动版本控制的有趣讨论.检查AssemblyInfo.cs时,请确保您的自动增量(*-如果正在使用它)仅针对AssemblyVersion,而不针对AssemblyFileVersion.

See this SO question for an interesting discussion on automatic versioning. When checking AssemblyInfo.cs, make sure your auto-increment (* - if you are using it) only targets AssemblyVersion and not AssemblyFileVersion.

调试程序时,可以在以下位置检查程序集的属性

When debugging the program, you could check the properties of the assembly in

\bin\Release\app.publish

Details选项卡下,检查版本号.这是否与您在VS中指定的任何设置相符?

Under the Details tab, check the version number. Does this match up with any of the settings you specified in VS?

这篇关于如何获得发布版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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