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

%3CLINGO-SUB%20id%3D%22lingo-sub-3065439%22%20slang%3D%22en-US%22%3EUpdate%20a%20non%20store%20App%20deployed%20via%20MSIX%20using%20the%20PackageManager%20API%2C%20no%20ForceShurdown%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3065439%22%20slang%3D%22en-US%22%3E%3CP%3EI%20managed%20to%20create%20a%20MSIX%20Package%20for%20my%20WPF%20Desktop%20App%20and%20successfully%20included%20the%20Windows.Management.Deployment%20dependency.%3CBR%20%2F%3EMy%20goal%20is%20to%20get%20some%20kind%20of%20auto%20update%20going%20by%20calling%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Evar%20uri%20%3D%20new%20Uri(Bootstrapping.UpdateUrl)%3B%20%2F%2FURL%20to%20.msix%20file%0Avar%20res%20%3D%20await%20pm.AddPackageAsync(uri%2C%20null%2C%20DeploymentOptions.None).AsTask(new%20UpdateProgress(mAppState))%3B%20%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20the%20code%20above%2C%20the%20process%20will%20just%20run%20forever%2C%20await%20never%20returns.%20The%20progress%20event%20tells%20me%20the%20update%20is%20startet%20but%20then%20progress%20stops.%3CBR%20%2F%3EAs%20soon%20as%20I%20change%20the%20deployment%20options%20to%20ForceApplicationShutdown%20the%20App%20will%20be%20shut%20down%20without%20notice%2C%20which%20is%20not%20appropriate%20in%20my%20case.%3CBR%20%2F%3EI%20would%20like%20to%20start%20the%20Update%2C%20then%20notify%20the%20user%20%22Update%20will%20be%20finished%20when%20restarting%20the%20App%22%20(or%20similar)%20and%20let%20the%20user%20decide%20when%20to%20restart%20(saving%20all%20the%20work%20before).%3C%2FP%3E%3CP%3EIs%20this%20even%20possible%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%20are%20welcome%2C%3CBR%20%2F%3ECheers%2C%3CBR%20%2F%3ENothi%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3254405%22%20slang%3D%22en-US%22%3ERe%3A%20Update%20a%20non%20store%20App%20deployed%20via%20MSIX%20using%20the%20PackageManager%20API%2C%20no%20ForceShurdown%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3254405%22%20slang%3D%22en-US%22%3EI%20think%20you%20could%20use%20DeferRegistrationWhenPackagesAreInUse.%20It%20is%20a%20Boolean%20value%2C%20TRUE%20indicates%20that%20registration%20of%20the%20main%20package%20or%20dependency%20packages%20will%20be%20delayed%20until%20the%20next%20time%20the%20application%20is%20activated%20if%20the%20packages%20are%20currently%20in%20use%3B%20otherwise%2C%20FALSE.%20%3CBR%20%2F%3EWe%20will%20update%20the%20doc%20to%20reflect%20this.%3CBR%20%2F%3E%3CBR%20%2F%3EReferences%3A%3CBR%20%2F%3EAddPackageOptions%20Class%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fuwp%2Fapi%2Fwindows.management.deployment.addpackageoptions%3Fview%3Dwinrt-22000%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fuwp%2Fapi%2Fwindows.management.deployment.addpackageoptions%3Fview%3Dwinrt-22000%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EAddPackageOptions.DeferRegistrationWhenPackagesAreInUse%20Property%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fuwp%2Fapi%2Fwindows.management.deployment.addpackageoptions.deferregistrationwhenpackagesareinuse%3Fview%3Dwinrt-22000%23windows-management-deployment-addpackageoptions-deferregistrationwhenpackagesareinuse%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fuwp%2Fapi%2Fwindows.management.deployment.addpackageoptions.deferregistrationwhenpackagesareinuse%3Fview%3Dwinrt-22000%23windows-management-deployment-addpackageoptions-deferregistrationwhenpackagesareinuse%3C%2FA%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3251458%22%20slang%3D%22en-US%22%3ERe%3A%20Update%20a%20non%20store%20App%20deployed%20via%20MSIX%20using%20the%20PackageManager%20API%2C%20no%20ForceShurdown%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3251458%22%20slang%3D%22en-US%22%3EAny%20Ideas%3F%20Is%20it%20even%20possible%20to%20do%20this%3F%20Any%20alternative%20approaches%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3254755%22%20slang%3D%22en-US%22%3ERe%3A%20Update%20a%20non%20store%20App%20deployed%20via%20MSIX%20using%20the%20PackageManager%20API%2C%20no%20ForceShurdown%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3254755%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Harshada%2C%3C%2FP%3E%3CP%3Emany%20thanks%20for%20your%20reply%2C%20I%20already%20tried%20to%20implement%20your%20proposal%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Evar%20res%20%3D%20await%20pm.AddPackageByUriAsync(uri%2C%20new%20AddPackageOptions()%20%7B%20DeferRegistrationWhenPackagesAreInUse%20%3D%20true%7D)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUnfortunately%20this%20will%20throw%20an%20exception%3A%26nbsp%3BObject%20reference%20not%20set%20to%20an%20instance%20of%20an%20object.%3C%2FP%3E%3CP%3EIn%20the%20background%20though%2C%20something%20is%20actually%20happening%20because%20catching%20this%20exception%20and%20restarting%20the%20app%20will%20apply%20the%20update.%3C%2FP%3E%3CP%3EDo%20I%20miss%20some%20more%20input%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnother%20thing%20that%20puzzles%20me%20is%20that%20the%20docs%20say%3A%3CBR%20%2F%3E%3CSPAN%3E%22The%20URI%20of%20the%20package%20to%20add.%20The%20URI%20must%20follow%20the%20file%20URI%20scheme%20(file%3A%2F%2F)%20since%20the%20only%20supported%20URI%20schemes%20are%20local%20file%20paths%20and%20local%20network%20paths.%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EWell%2C%20I%20am%20using%20a%20URL%20pointing%20to%20a%20Azure%20Blob.%20Is%20this%20even%20possible%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3414455%22%20slang%3D%22en-US%22%3ERe%3A%20Update%20a%20non%20store%20App%20deployed%20via%20MSIX%20using%20the%20PackageManager%20API%2C%20no%20ForceShurdown%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3414455%22%20slang%3D%22en-US%22%3EAny%20more%20thought%20on%20this%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3416301%22%20slang%3D%22en-US%22%3ERe%3A%20Update%20a%20non%20store%20App%20deployed%20via%20MSIX%20using%20the%20PackageManager%20API%2C%20no%20ForceShurdown%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3416301%22%20slang%3D%22en-US%22%3ESorry%20for%20the%20delay%2C%20let%20me%20check%20and%20revert.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3440698%22%20slang%3D%22en-US%22%3ERe%3A%20Update%20a%20non%20store%20App%20deployed%20via%20MSIX%20using%20the%20PackageManager%20API%2C%20no%20ForceShurdown%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3440698%22%20slang%3D%22en-US%22%3EDeferRegistrationWhenPackagesAreInUse%20seems%20like%20the%20right%20approach.%20For%20us%20to%20get%20a%20better%20understanding%20of%20the%20error%20and%20the%20issue%2C%20do%20you%20mind%20submitting%20a%20Feedback%20Hub%20bug%20under%20Developer%20Platform%20-%26gt%3B%20App%20Deployment%3F%3C%2FLINGO-BODY%3E
New 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?