Auto updater for my side loaded UWP apps

简介: 原文: Auto updater for my side loaded UWP apps As I described before, i have a few tasks to solve for my home automation project.

原文: Auto updater for my side loaded UWP apps

As I described before, i have a few tasks to solve for my home automation project. One of the things I wanted to do is to be able to update my application on the different devices easily. I could publish my home automation app to the store, but it’s hard to provide a test environment for the store testers and it takes a while when the app gets certified before i can roll it out to all my devices. Of course I can sign up for an Intune account and use regular MDM to manage my apps, but 1st i need to have this Intune environment which I think is a bit over the top, and 2nd I would be depending on an internet connection. This is also a topic which comes up with some of my customers so I thought I could solve this differently.

Since the app is going to be side loaded I am allowed to use restricted capabilities. The store app uses these capabilities to be able to download and update apps from the store so what APIs are used by this app? It uses (among others) the PackageManager class. This API is protected by the restricted capability packageManagement.

So the first experiment I tried was to build an update button in a test app and I tried to update myself. I created a version 1.0.0.0 (Project, Store, Create App Package and set the version to 1.0.0.0, I also created a version 2.0.0.0) In my code I added the following line in the click event:

 

 

Where the packageLocation pointed to a file on my disk (but could also be a URL to a website). But updating yourself didn’t work. So the next idea I had was to write a little app which I could call with app2app communication and the only thing that little app would do was update the calling app. This works perfectly. So I created a new project called AppUpdate (Blank App). I added another project to the solution called AppUpdaterService (Windows Runtime Component).  I defined 2 parameters (I only use 1 currently) to be passed to this background service and that’s the package family name and the package location.

The entire code of this class looks like this:

Make sure you add the reference to this project to your AppUpdater project.

Inside my dashboard app I call the following code to update myself through the updater app:

The cool thing that happens is my app is closed when the update starts and automatically restarted after the update. This works on both Desktop as Mobile. I still need to test this on my RPI3 and in combination with Assigned Access/Kiosk mode on mobile.

So what’s left? I need to implement something which checks for a new version regularly. I am still debating if I am going to use the updater app to get registrations from other apps and checks if there is an update and if it finds one starts updating the app, it is more generic this way. On the other hand, the app might know better when it should be updating or not and implement the logic itself and just uses the appupdater to do the update.

I was also thinking about using some kind of broadcast in the app to send an update command to the apps on all devices to be able to force an update after I published a newer version on my internal website.

How I need to check for a newer version could be as simple as providing a little text file on the webserver with the latest version number. If the app has a lower version it will update. Or perhaps I should test what happens if I call the update command and the version of the app on the server is the same. If the update is ignored i don’t need to write any specific code to handle this. It might not be the most optimal solution, although we only download the changes in packages.

目录
相关文章
|
2月前
|
API 开发工具 UED
在 UWP 中使用 Windows App SDK
【10月更文挑战第17天】在UWP中使用Windows App SDK可增强应用功能和性能。首先了解SDK特性,接着安装Visual Studio 2022及以上版本,并从微软官网下载安装SDK。配置项目时,确保目标版本支持SDK,添加SDK引用后即可使用新API提升应用体验。开发过程中应充分利用调试工具进行测试,确保应用的兼容性和稳定性。
|
API C++ Windows
利用 Win32 启动和检测 UWP App 的方法
原文:利用 Win32 启动和检测 UWP App 的方法 一种启动和检测 UWP 应用的方法 背景 我们发布过多款 UWP 平台的同类型 App ,最近有一个需求:用传统 Win32 程序启动我们的 UWP 程序。
1507 0
|
数据库 数据库管理 容器
[UWP小白日记-1]判断APP是否是第一次运行初始化SQLITE数据库
原文:[UWP小白日记-1]判断APP是否是第一次运行初始化SQLITE数据库   利用应用程序设置来实现此功能。   1.首先,获取APP设置的容器: ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;   由于获取容器的时候并没有给key为FirestStart的赋值,所以下面就直接判断是不是为null,为null就是第一次运行APP, 然后在else里给key为FirestStart的赋值,那么else的代码就只能执行一次了。
1433 0
|
jenkins 持续交付 Windows
UWP Jenkins + NuGet + MSBuild 手把手教你做自动UWP Build 和 App store包
原文:UWP Jenkins + NuGet + MSBuild 手把手教你做自动UWP Build 和 App store包 背景 项目上需要做UWP的自动安装包,在以前的公司接触的是TFS来做自动build。
2391 0
UWP 重启App
原文:UWP 重启App 今天看见了阿迪王的博客,写到了重启App自身的代码,微软终于在16299加进来了 其实就加上一句话 await CoreApplication.RequestRestartAsync(string.Empty); 需要引用 using Windows.ApplicationModel.Core; 函数原型 // // 摘要: // 重启应用。
1170 0
|
Java Go Windows
DEPLOYING NATIVE UWP (UNIVERSAL WINDOWS PLATFORM) APPS FOR JAVA DEVELOPERS & PUBLISHING THEM TO THE MICROSOFT STORE
原文: DEPLOYING NATIVE UWP (UNIVERSAL WINDOWS PLATFORM) APPS FOR JAVA DEVELOPERS & PUBLISHING THEM TO THE MICROSOFT STORE UWP Apps may distributed in 2 different ways: In the Windows App Store.
1449 0
|
Windows
在 UWP 应用中创建、使用、调试 App Service (应用服务)
原文:在 UWP 应用中创建、使用、调试 App Service (应用服务) 在 Windows 10 中微软为 UWP 引入了 App Service (即应用服务)这一新特性用以提供应用间交互功能。
1656 0
|
Web App开发 移动开发 JavaScript
Win10 UWP开发系列:使用VS2015 Update2+ionic开发第一个Cordova App
原文:Win10 UWP开发系列:使用VS2015 Update2+ionic开发第一个Cordova App 安装VS2015 Update2的过程是非常曲折的。还好经过不懈的努力,终于折腾成功了。 如果开发Cordova项目的话,推荐大家用一下ionic这个框架,效果还不错。
1795 0
|
Windows C++
设置UWP程序自启动(Automate launching Windows 10 UWP apps)
原文:设置UWP程序自启动(Automate launching Windows 10 UWP apps) 在开发UWP程序的过程中,有时候需要设置程序的自启。本人实现的步骤如下: 1.在VS中激活Protocol  (Package.appxmanifest --> Declarations --> Add Protocol),图示如下: 2.编译并发布项目(Build and Deploy)  发布之后Protocol被激活,在(控制面板 --> 程序 --> 默认程序 --> 设置关联)中可以找到MYAPPLICATION的关联。
1905 0

热门文章

最新文章