Display the TFS server Build number in the UI of a

2019-08-27 16:23发布

问题:

If I look at the interface of TFS-server, under category "build & release", I can see the build number:

I want to know how can I get access to the value of the last build: 23112017-8 in my WPF application (I want to display in my WPF app - "Last Build: 23112017-8"). How can I get this value via C# code, for example in my view model?

回答1:

Try this :

string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();  
this.Text = String.Format("Last Build: - version {0}", version);

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

[assembly: AssemblyVersion("1.0.0.0")]

You can use the extension Update AssemblyInfo to modify the version as build number before a build to specify the value it returns.

Just use the predefined variable Build.BuildNumber to get the build number.

Reference :

  • How to display the running version in a C# WPF app
  • How can I display the Build number and/or DateTime of last build in my app?



标签: c# wpf tfs build