c# - 如何在我的应用程序中显示上次构建的内部版本号和/或日期时间?

标签 c# winforms build version versioning

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

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 )"

最佳答案

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.*")]

关于c# - 如何在我的应用程序中显示上次构建的内部版本号和/或日期时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11532705/

相关文章:

eclipse - (Eclipse) 在构建项目 : copying resources to output folder 时挂起

android - 错误 :(232) Ignore: Unknown issue id "InlineApi"

c# - 字符串比较 : InvariantCultureIgnoreCase vs OrdinalIgnoreCase?

c# - ASP.NET Core WebApi

c# - 使用 C# 组合框放置图像和字符串

c# - 如何在两种不同形式(同一程序)之间引发事件

c# - Winforms 基于角色的安全限制

build - 每个开发人员的Gradle “private”配置

c# - PowerShell Stop-Job/Stop Job() 需要 2 分钟才能停止作业

c# - 通过 C# 将 SSRS RDL 导出为 PDF