Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get publish version?

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:

enter image description here

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

like image 605
IrApp Avatar asked Sep 27 '16 10:09

IrApp


People also ask

How do I publish in Visual Studio?

To publish your app from Visual Studio, do the following: Change the solution configuration from Debug to Release on the toolbar to build a Release (rather than a Debug) version of your app. Right-click on the project (not the solution) in Solution Explorer and select Publish. In the Publish tab, select Publish.


1 Answers

We can create one property which will return the Version information as mention below and we can use that property.

public string VersionLabel
{
    get
    {
        if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
        {
            Version ver = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion;
            return string.Format("Product Name: {4}, Version: {0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision, Assembly.GetEntryAssembly().GetName().Name);
        }
        else
        {
            var ver = Assembly.GetExecutingAssembly().GetName().Version;
            return string.Format("Product Name: {4}, Version: {0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision, Assembly.GetEntryAssembly().GetName().Name);
        }
    }
}
like image 59
Gorakh Nath Avatar answered Oct 13 '22 17:10

Gorakh Nath