Skip to content

Commit 8598fb2

Browse files
author
Santosh Chintalapati
committed
DeploymentManager spec update for the new Repair API
1 parent 5372c81 commit 8598fb2

File tree

1 file changed

+52
-9
lines changed

1 file changed

+52
-9
lines changed

specs/Deployment/DeploymentAPI.md

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ This is the spec for proposal
66
The Windows App SDK (WinAppSDK) for packaged apps involves the framework, main, and singleton
77
packages, which are all signed and published by Microsoft. The framework package contains the
88
WinAppSDK binaries used at run time, and it is installed with the application. The main package
9-
contains out-of-process services that are brokered between apps, such as push notifications, and it
10-
is also needed for the framework to be serviced by the Microsoft Store. The singleton package
11-
supports a single long-running process that is brokered between apps for features like push
9+
contains out-of-process services that are brokered between apps, such as Dynamic Dependency data
10+
store, and it is also needed for the framework to be serviced by the Microsoft Store. The singleton
11+
package supports a single long-running process that is brokered between apps for features like push
1212
notifications.
1313

1414
Currently, packaged apps can only declare dependencies on WinAppSDK framework package. In order to
@@ -42,12 +42,13 @@ are already present on the system, or that the version present is the minimum ve
4242
the application. Instead, the Deployment API should be used to validate that the WinAppSDK is at the
4343
correct version and that all required packages are present.
4444

45-
The Deployment API addresses the following two developer scenarios:
45+
The Deployment API addresses the following three developer scenarios:
4646

4747
1. Does this system have the min version of the WinAppSDK main and singleton packages required by my
4848
app?
4949
2. How do I install the WinAppSDK main and singleton packages, if they are not already present on
5050
the system?
51+
3. How do I repair the already installed WinAppSDK main and singleton pacakges, if needed ?
5152

5253
The API addresses #1 by a simple query of the version needed and a check for OS updates.
5354

@@ -60,6 +61,14 @@ The API addresses #1 by a simple query of the version needed and a check for OS
6061
packageManagement restricted capability can use the Deployment API to get these packages
6162
installed.
6263

64+
#3 has two possible answers.
65+
66+
- First, the developer can repair these packages directly through the app by reinstalling them, if
67+
possible. These MSIX packages can be acquired through
68+
[Downloads page](https://docs.microsoft.com/windows/apps/windows-app-sdk/downloads).
69+
- Alternatively, unpackaged apps that are full trust or MSIX packaged apps that have the
70+
packageManagement restricted capability can use the Deployment API to get these packages repair.
71+
6372
# Examples
6473

6574
## GetStatus
@@ -143,10 +152,8 @@ by using DeploymentInitializeOptions object and setting ForceDeployment option b
143152
this API. This option when set will shut down the application(s) associated with WinAppSDK packages,
144153
update the WinAppSDK packages and restart the application(s).
145154

146-
// OPENISSUE: If this option is set when updating main package, then whether the out of process com
147-
server from the main package such as push Notifications needs to be explicitly restarted needs to be
148-
understood. If restart it is needed, then the API will handle explicitly restarting it. This is
149-
under investigation.
155+
If this option is set when updating singleton package, then the out of process com server from the
156+
singleton package such as push Notifications is explicitly restarted.
150157

151158
When the API is updating framework package and ForceDeployment option is set, then all dependent
152159
packages that are NOT currently in use will be immediately re-installed to refer to the updated
@@ -179,12 +186,43 @@ they shut down, to refer to the updated framework package.
179186
}
180187
```
181188

189+
## Repair
190+
191+
This API performs a status check, and if the main and singleton packages are already installed at
192+
the required version, it will attempt to repair those packages. All information about the version,
193+
channel, and architecture needed are derived from the current WinAppSDK framework package.
194+
195+
Since both the main _and_ the singleton packages may need to be repaired, it is possible that one
196+
package is repaired successfully but not the other. If so, the returned WindowsAppRuntimeStatus will
197+
contain the error, if one occurs during package install.
198+
199+
```C#
200+
if (DeploymentManager.GetStatus().Status != DeploymentStatus.Ok)
201+
{
202+
// Repair does a status check, and if the status is OK it will attempt to get
203+
// the WindowsAppRuntime into a good state by deploying packages. Unlike a simple
204+
// status check, Repair can sometimes take several seconds to deploy the packages.
205+
// These should be run on a separate thread so as not to hang your app while the
206+
// packages deploy.
207+
var repairTask = Task.Run(() => DeploymentManager.Repair());
208+
repairTask.Wait();
209+
210+
// Check the result.
211+
if (repairTask.Result.Status != DeploymentStatus.Ok)
212+
{
213+
// The WindowsAppRuntime is in a bad state which Repair() did not fix.
214+
// Do error reporting or gather information for submitting a bug.
215+
// Gracefully exit the program or carry on without using the WindowsAppRuntime.
216+
}
217+
}
218+
```
219+
182220
# API Details
183221

184222
```C# (but really MIDL3)
185223
namespace Microsoft.Windows.ApplicationModel.WindowsAppRuntime
186224
{
187-
[contractversion(2)]
225+
[contractversion(3)]
188226
apicontract DeploymentContract{};
189227

190228
/// Represents the current Deployment status of the WindowsAppRuntime
@@ -241,6 +279,11 @@ namespace Microsoft.Windows.ApplicationModel.WindowsAppRuntime
241279
[contract(DeploymentContract, 2)]
242280
[overload("Initialize")]
243281
static DeploymentResult Initialize(Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions deploymentInitializeOptions);
282+
283+
/// Checks the status of the WindowsAppRuntime of the current package and attempts to
284+
/// repair already installed WinAppSDK packages.
285+
[contract(DeploymentContract, 3)]
286+
static DeploymentResult Repair();
244287
};
245288
}
246289
```

0 commit comments

Comments
 (0)