Update a non store App deployed via MSIX using the PackageManager API, no ForceShurdown

Copper Contributor

I managed to create a MSIX Package for my WPF Desktop App and successfully included the Windows.Management.Deployment dependency.
My goal is to get some kind of auto update going by calling:

 

var uri = new Uri(Bootstrapping.UpdateUrl); //URL to .msix file
var res = await pm.AddPackageAsync(uri, null, DeploymentOptions.None).AsTask(new UpdateProgress(mAppState)); 

 

Using the code above, the process will just run forever, await never returns. The progress event tells me the update is startet but then progress stops.
As soon as I change the deployment options to ForceApplicationShutdown the App will be shut down without notice, which is not appropriate in my case.
I would like to start the Update, then notify the user "Update will be finished when restarting the App" (or similar) and let the user decide when to restart (saving all the work before).

Is this even possible?

 

Any ideas are welcome,
Cheers,
Nothi

 

 

6 Replies
Any Ideas? Is it even possible to do this? Any alternative approaches?
I think you could use DeferRegistrationWhenPackagesAreInUse. It is a Boolean value, TRUE indicates that registration of the main package or dependency packages will be delayed until the next time the application is activated if the packages are currently in use; otherwise, FALSE.
We will update the doc to reflect this.

References:
AddPackageOptions Class
https://docs.microsoft.com/en-us/uwp/api/windows.management.deployment.addpackageoptions?view=winrt-...

AddPackageOptions.DeferRegistrationWhenPackagesAreInUse Property
https://docs.microsoft.com/en-us/uwp/api/windows.management.deployment.addpackageoptions.deferregist...

Hello Harshada,

many thanks for your reply, I already tried to implement your proposal:

 

var res = await pm.AddPackageByUriAsync(uri, new AddPackageOptions() { DeferRegistrationWhenPackagesAreInUse = true});

 

Unfortunately this will throw an exception: Object reference not set to an instance of an object.

In the background though, something is actually happening because catching this exception and restarting the app will apply the update.

Do I miss some more input?

 

Another thing that puzzles me is that the docs say:
"The URI of the package to add. The URI must follow the file URI scheme (file://) since the only supported URI schemes are local file paths and local network paths."

Well, I am using a URL pointing to a Azure Blob. Is this even possible?

 

Sorry for the delay, let me check and revert.
DeferRegistrationWhenPackagesAreInUse seems like the right approach. For us to get a better understanding of the error and the issue, do you mind submitting a Feedback Hub bug under Developer Platform -> App Deployment?