title: How to access local WPF app version from Windows Application Packaging Project using the UWP Windows.ApplicationModel.Package or other libraries?
body: <p>I have an internal WPF application (.NET Framework 4.8), that has recently been changed to utilize the Windows Application Packaging Project. Using side loading and auto updating (on run).
  This is all setup and working fine; certificates are installed, app deploys properly, and it updates automatically.</p>
  <p>What I would like to do now, is update our current display of the version number. Originally we were deploying via ClickOnce and utilized <code>ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString()</code> to get the Version number.</p>
  <p>I have been struggling for a while as to how to accomplish this with the new deployment strategy.</p>
  <p>As far as I have found I need to use <code>Windows.ApplicationModel</code> in order to use the <code>Package</code> class. But for the life of me I cannot figure out how to bring this package into my WPF app (The <code>MainWindow.xaml.cs</code> to be exact). I need the same code as <a href="https://stackoverflow.com/a/28635481/6552757">Here</a>.</p>
  <p>What I have currently tried:</p>
  <ul>
  <li>Importing the <code>Microsoft.Windows.SDK.Contracts</code> nuGet package. <a href="https://blogs.windows.com/windowsdeveloper/2019/09/30/windows-10-winrt-api-packs-released/" rel="nofollow noreferrer">Reference</a></li>
  <li>Importing the <code>UwpDesktop</code> nuGet Package. <a href="https://github.com/Foda/uwp-desktop" rel="nofollow noreferrer">Reference</a></li>
  <li>Following the blog <a href="https://blogs.windows.com/windowsdeveloper/2017/01/25/calling-windows-10-apis-desktop-application/" rel="nofollow noreferrer">Here</a></li>
  <li>Review Microsoft documentation <a href="https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-supported-api" rel="nofollow noreferrer">Here</a> and <a href="https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/get-activation-info-for-packaged-apps" rel="nofollow noreferrer">Here</a></li>
  <li>and other internet searches.</li>
  </ul>
  <p>I have been able to get to the point where I can have a <code>using Windows.ApplicationModel</code> in the application without error but I still cant access the <code>Package</code> class.</p>
  <p>The only things I need to accomplish is to get the version number to display in the footer bar, and to know if there is a new version so we can prompt the user to restart the application. We have no need for any of the other UWP/WinRT libraries. We have some elements to the software that have expensive affect on the real world, and do not want a silent update. People will typically open the software and not close it for the entire day. Most users could then run the software without knowing there is a fix or improvement.</p>
  <p>My last resort would be to manually query and parse the deployment location, checking for a new version, but I am still not sure how to get the local application version.</p>
  <p>Most of the resources I have been reading are more than 2 years old and it seems a lot has changed with the interaction for Desktop Bridges and other deployment related elements with UWP. I get the feeling that something has changed just enough to cause all this headache, or I am completely missing something stupid and it is all me. I also have zero experience with UWP so some of the documentation is a little cryptic.</p>
  <p>We needed to change to this deployment strategy for fairly important reasons relating to the certificates and some libraries we use. It would be more headache to maintain the deployment with ClickOnce, than the current headache trying to solve this.</p>
  <p>Does anyone know of a way to retrieve the version number of a WPF application deployed via a Windows Application Packaging Project?</p>