Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

While I can get the assembly version using the following code

        var assembly = typeof(App).GetTypeInfo().Assembly;
        var assemblyVersion = assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;

I would like to retrieve the Version from Package.appxmanifest in this case 1.0.0.4

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
  <Identity Name="zzz" Publisher="CN=zzz" Version="1.0.0.4" />

I expected to have access to Windows.ApplicationModel, but this is not available to me

See Question&Answers more detail:os

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

1 Answer

Here's what you can do to retrieve the version in code:

using Windows.ApplicationModel;

public static string GetAppVersion()
{
  Package package = Package.Current;
  PackageId packageId = package.Id;
  PackageVersion version = packageId.Version;

  return string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);
}

Reference: http://www.michielpost.nl/PostDetail_67.aspx


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...