Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read msix package appxmanifest version

Tags:

c#

.net-core

msix

We have a .NET Core application which only will be used in-house. We changed from Click-Once to MSIX during our switch from WPF to .NET Core. In the window caption/title of our application we also "output" the current version (major, minor, ...). Previously, we took the version of our startup project (called "view"). Now using MSIX, this project has got the version number we need (the startup project is referenced to "view"). How can we read the correct version now?

Using Assembly.GetEntryAssembly or Assembly.GetCallingAssembly returns the wrong version - the version of the startup project. The application is not in the Windows Store, it will be side loaded as a package. Any ideas to get the "correct" version we "produce" when deploying our package?

like image 718
dsTny Avatar asked Jun 02 '20 21:06

dsTny


People also ask

How do I open an Appxmanifest package?

Open the Package. appxmanifest file. In Microsoft Visual Studio, open the file with the XML (Text) Editor. To do that, in Solution Explorer, right-click the file and click Open with.

What is package Appxmanifest?

Package.appxmanifest This is an XML style file that developers use to configure the details of an app, such as publisher information, logos, processor architectures, etc. This is an easily configurable, temporary version of the app package manifest used during app development.

How do I open a MSIX bundle file?

To open an MSIX file and begin installation of the packaged app in Windows 10, simply double-click the file. App Installer opens the MSIX file and displays information about the app, such as the name, publisher, and version, as well as the capabilities requested by the app.


1 Answers

You need to install the Windows 10 WinRT API pack. Install from Nuget the package: Microsoft.Windows.SDK.Contracts

URL: https://www.nuget.org/packages/Microsoft.Windows.SDK.Contracts

Then you can do something like this:

var version = Windows.ApplicationModel.Package.Current.Id.Version;
applicationVersion = string.Format("{0}.{1}.{2}.{3}",
    version.Major,
    version.Minor,
    version.Build,
    version.Revision);

If you want to DEBUG or Run with the current Package available, just set your package deployment project as the Startup Project.

Additional References:

https://blogs.windows.com/windowsdeveloper/2019/09/30/windows-10-winrt-api-packs-released/

https://docs.microsoft.com/en-us/uwp/api/

https://www.thomasclaudiushuber.com/2019/04/26/calling-windows-10-apis-from-your-wpf-application/

like image 74
Doug Knudsen Avatar answered Sep 27 '22 19:09

Doug Knudsen