How to Get the Windows Phone App version from WMAppManifest file ?

This blog post will explain how to get the Windows Phone App version from the WMAppManifest file using C# in Windows Phone 8.

The WMAppManifest file contains the configurations items related to the Windows Phone app. It includes the following tabs
– Application UI
– Capabilities
– Requirements
– Packaging

The Packaging tab contains the Version Number of the App.

image

How to Get the Windows Phone App version from WMAppManifest file ?

The WMAppManifest file is just an XML file and hence we can use the XDocument class to retreive this element from the file.

Below is a sample code snippet which retreives the App version number from WMAppManifest.xml using XDocument.

private void Button_Click_1(object sender, RoutedEventArgs e)
{
  string appVersionNumber = XDocument.Load("WMAppManifest.xml")
         .Root.Element("App").Attribute("Version").Value;
  MessageBox.Show(appVersionNumber);
}

image