【问题标题】:How can I display the Build number and/or DateTime of last build in my app?如何在我的应用程序中显示上次构建的内部版本号和/或日期时间?
【发布时间】:2012-07-18 00:25:15
【问题描述】:

我知道我可以这样做来获取应用的官方(发布/发布)版本号:

string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();  
this.Text = String.Format("Platypi R Us - version {0}", version);

...但这仅显示我的应用程序的“发布版本”*(“1.0.0.0”)。我想显示内部版本号。

  • 来自项目 |属性 |发布标签。

除此之外,或者除此之外,我想显示最后一次构建的日期和时间,以便它显示 “Platypi R Us - 版本 3.14(2012 年 7 月 17 日 16:22 )"

【问题讨论】:

  • 我根本不会称它为重复 - 他想要我不想要的东西(显示发布版本号)。我可以这样做(目前正在这样做),但我想要一个内部版本号,以便我可以验证用户正在运行我部署的最新版本。
  • 你指的是程序集的文件版本吗?
  • 版本由 4 个数字组成:Major、Minor、Build 和 Revision。 Rafael 的链接显示了如何自动增加它,以便为每个构建提供唯一值。
  • @Rafael:任何可以区分彼此的东西;我会再看一下那个链接,因为我一开始没有看到 John 提到的内容。

标签: c# winforms build version versioning


【解决方案1】:

Assembly.GetExecutingAssembly().GetName().Version 返回的值是您项目的 AssemblyInfo.cs 文件中的值:

[assembly: AssemblyVersion("1.0.0.0")]

在构建之前修改这些以指定它返回的值。或者,如同一 AssemblyInfo.cs 文件中所述:

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-12
    • 1970-01-01
    • 2022-12-11
    • 2021-04-14
    • 2023-03-05
    相关资源
    最近更新 更多