Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
220 views
in Technique[技术] by (71.8m points)

c# - How can I display the Build number and/or DateTime of last build in my app?

I know that I can do this to get the app's official (release/publish) version number:

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

...but this only shows a "Publish version" of my app* ("1.0.0.0"). I want to show the build number.

  • From the Project | Properties | Publish tab.

Barring that, or in addition to that, I'd like to show the date and time of the last build, so that it says "Platypi R Us - version 3.14 (7/17/2012 16:22)"

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The value returned from Assembly.GetExecutingAssembly().GetName().Version is that in your project's AssemblyInfo.cs file:

[assembly: AssemblyVersion("1.0.0.0")]

Modify these before a build to specify the value it returns. Or, as documented in the same AssemblyInfo.cs file:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...