How do I debug a UWP UpdateTask?
First, let's look at some context in the UWP UpdateTask: its a background task that your app can implement to start the system when your UWP gets an update. It runs your code from the updated app package in the background, so you can keep track of any service related to a particular update (such as a data structure change). To customize UpdateTask for your application, you need to do two things:
a) Declare UpdateTask in your appx manifest:
<Extension Category="windows.updateTask" EntryPoint="BackgroundTasks.UpdateTask" />
b) Add a Windows Runtime Component that implements the task in a type that matches the EntryPoint declaration and references the component from your application project.
Before debugging the upgrade procedure, first make sure that your original version of the application is deployed. Then change the debug setting in your project properties as follows:
Then, to make sure UpdateTask is running, increase the package version number in the manifest editor:
Now when you hit F5 in VS 2017, your application will be updated and the system will activate the UpdateTask component in the background. The debugger automatically attaches to the background process. Your breakpoint will hit and you will be able to walk through the update code logic (just toast in my example).
When the background task is complete, you can also launch the foreground app from the app list in the same debug session. The debugger automatically attaches again, now to your foreground process, and you can execute your main application logic.
Notes for VS 2015 users: The above applies to VS 2017. If you are using VS 2015, you can use the same methods to run and test UpdateTask, but VS will not attach to it. An alternative procedure in VS 2015 would be to set an ApplicationTrigger , which has the same UpdateTask as the entry point, and triggers execution directly from the foreground.
Thank you Stefan Wick - Windows Developer Platform
source to share