Skip to content

Commit 106d2a4

Browse files
Merge branch 'build-2025-release' into cinnamon/advanced-settings
2 parents 7480965 + b64d348 commit 106d2a4

14 files changed

+148
-313
lines changed

.openpublishing.redirection.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8874,6 +8874,21 @@
88748874
"source_path": "hub/sudo/index.md",
88758875
"redirect_url": "/windows/advanced-settings/sudo/",
88768876
"redirect_document_id": false
8877+
},
8878+
{
8879+
"source_path": "hub/apps/develop/actions/action-json.md",
8880+
"redirect_url": "/windows/ai/app-actions/actions-json",
8881+
"redirect_document_id": false
8882+
},
8883+
{
8884+
"source_path": "hub/apps/develop/actions/action-provider-manifest.md",
8885+
"redirect_url": "/windows/ai/app-actions/actions-provider-manifest",
8886+
"redirect_document_id": false
8887+
},
8888+
{
8889+
"source_path": "hub/apps/develop/actions/index.md",
8890+
"redirect_url": "/windows/ai/app-actions/",
8891+
"redirect_document_id": false
88778892
}
88788893
]
88798894
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
title: Grant package identity by packaging with external location in Visual Studio
3+
description: How to use Visual Studio to grant package identity to an unpackaged Win32 app so that you can use modern Windows features in that app.
4+
ms.date: 05/09/2025
5+
ms.topic: article
6+
keywords: windows 11, windows 10, desktop, sparse, package, identity, external, location, MSIX, Win32, Visual Studio
7+
ms.localizationpriority: medium
8+
---
9+
10+
# Grant package identity by packaging with external location in Visual Studio
11+
12+
Many Windows features can be used by a desktop app only if that app has package identity at runtime. See [Features that require package identity](/windows/apps/desktop/modernize/modernize-packaged-apps). If you have an existing desktop app, with its own installer, then there's very little you need to change in order to benefit from package identity.
13+
14+
Starting in Windows 10, version 2004, you can grant package identity to an app simply by building and registering a *package with external location* with your app. Packaging with external location allows you to register a simple identity package in your existing installer without changing how or where you install your application. You might be familiar with full MSIX packaging; this is a much lighter-weight option, as described below.
15+
16+
If you already have a Visual Studio project for your application, then building an identity package in Visual Studio provides a more streamlined experience than [building an identity package manually](/windows/apps/desktop/modernize/grant-identity-to-nonpackaged-apps).
17+
18+
These are the steps that we'll be describing in detail in this topic to build and register an identity package using Visual Studio:
19+
20+
1. [Install Visual Studio components](#install-visual-studio-components)
21+
2. [Add a Packaging Project to your solution](#add-a-packaging-project-to-your-solution)
22+
3. [Configure the Packaging Project for signing](#configure-the-packaging-project-for-signing)
23+
4. [Build and test the Packaging Project in Release Mode](#build-and-test-the-packaging-project-in-release-mode)
24+
5. [Register the identity package in your installer](#register-the-identity-package-in-your-installer)
25+
6. [Optional steps](#optional-steps)
26+
27+
## Install Visual Studio components
28+
29+
Creating an identity package in Visual Studio requires the **Windows Application Packaging Project** and the **Package with External Location** extension.
30+
31+
Install the **Windows Application Packaging Project** components as described in [Required Visual Studio version and workload](/windows/msix/desktop/desktop-to-uwp-packaging-dot-net#required-visual-studio-version-and-workload).
32+
33+
In Visual Studio, via the **Extensions** > **Manage Extensions** menu item, install the **Package with External Location** extension.
34+
35+
## Add a Packaging Project to your solution
36+
37+
To add a Packaging Project to your solution with a Project Reference to your application project, see [Set up the Windows Application Packaging Project in your solution](/windows/msix/desktop/desktop-to-uwp-packaging-dot-net#set-up-the-windows-application-packaging-project-in-your-solution).
38+
39+
Enable packaging with external location by right-clicking the Packaging Project in Solution Explorer, navigating to the **External Location** tab provided by the **Package with External Location** extension, enabling the **Package with External Location** option, and saving the changes.
40+
41+
Set the **Package name** and **Publisher display name** fields of the identity package by double-clicking `Package.appxmanifest` in the Packaging Project to open the visual manifest editor, navigating to the Packaging tab, and setting the **Package name** and **Publisher display name** fields to the desired values.
42+
43+
If you have a custom application manifest in your application project, then for info about synchronizing the values with the values from `Package.appxmanifest`, see [Add identity metadata to your desktop application manifests](/windows/apps/desktop/modernize/grant-identity-to-nonpackaged-apps#add-identity-metadata-to-your-desktop-application-manifests). The **Package with External Location** extension uses **App** for the **applicationId**.
44+
45+
If you don't have a custom application manifest, then Visual Studio will produce the appropriate artifacts during the build process. .NET projects embed a manifest by default, which conflicts with the produced manifest artifacts. To resolve that, right-click the Project, open **Properties**, and in the **Application** tab under the **Manifest** section, change **Embed manifest with default settings** to **Create application without a manifest**.
46+
47+
## Configure the Packaging Project for signing
48+
49+
Generate a certificate for signing by walking through the **Publish** > **Create App Packages** wizard shown in [Create an app package using the packaging wizard](/windows/msix/package/packaging-uwp-apps#create-an-app-package-using-the-packaging-wizard).
50+
51+
On the first screen, ensure that **Sideloading** is selected, and **Enable automatic updates** is unchecked. On the second screen, create a self-signed certificate if necessary, then click the **Trust** button to trust it in the Local Machine Trusted People certificate store. On the final screen, set **Generate app bundle** to *Never*, and click **Create** to complete the signing configuration.
52+
53+
## Build and test the Packaging Project in Release Mode
54+
55+
To avoid complications from Debug mode dependencies, set the Build configuration to Release mode, and build the Packaging Project.
56+
57+
Building the Packaging Project produces a **PackageWithExternalLocation** folder in the build output. That folder contains the `MSIX` file representing the identity package, as well as `Install` and `Remove` PowerShell scripts to register and unregister the generated identity package locally for testing.
58+
59+
The `Install` PowerShell script registers the generated identity package locally, and connects it with the `ExternalLocation` sibling folder for testing purposes. To test the application with identity, run the application executable from the `ExternalLocation` folder.
60+
61+
To associate identity with your application in production, you'll need to ship the generated identity package with your application, and register it in your installer.
62+
63+
## Register the identity package in your installer
64+
65+
The last step to associate identity with your application is to register the identity package in your installer, and associate it with your application's installation directory.
66+
67+
The code listing below demonstrates registering the identity package by using the [**PackageManager.AddPackageByUriAsync**](/uwp/api/windows.management.deployment.packagemanager.addpackagebyuriasync) method.
68+
69+
```csharp
70+
using Windows.Management.Deployment;
71+
72+
...
73+
74+
var externalUri = new Uri(externalLocation);
75+
var packageUri = new Uri(packagePath);
76+
77+
var packageManager = new PackageManager();
78+
79+
var options = new AddPackageOptions();
80+
options.ExternalLocationUri = externalUri;
81+
82+
await packageManager.AddPackageByUriAsync(packageUri, options);
83+
```
84+
85+
Be aware of the following important details about this code:
86+
* Set `externalLocation` to the absolute path of your application's installation directory (without any executable names).
87+
* Set `packagePath` to the absolute path of the identity package produced in the previous step (with the file name).
88+
89+
For production-ready code in C# and C++, see [Sample apps](#sample-apps) below. The samples also demonstrate how to unregister the identity package on uninstall.
90+
91+
## Sample apps
92+
93+
For fully functional C# and C++ apps that demonstrate how to register an identity package, see the [PackageWithExternalLocation](https://aka.ms/sparsepkgsample) samples.
94+
95+
## Optional steps
96+
97+
### Localization
98+
99+
Some features that understand package identity might result in strings from your identity package manifest being displayed in the Windows OS. For example:
100+
101+
* An application that uses camera, microphone, or location APIs will have a dedicated control toggle in Windows Privacy Settings along with a brokered consent prompt that users can use to grant or deny access to those sensitive resources.
102+
* An application that registers a share target will show up in the share dialog.
103+
104+
To localize the strings in the identity package manifest, see [Localize the manifest](/windows/uwp/app-resources/using-mrt-for-converted-desktop-apps-and-games#phase-1-localize-the-manifest).

hub/apps/desktop/modernize/grant-identity-to-nonpackaged-apps.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ To build and register an identity package, follow these steps:
2020
2. [Build and sign the identity package](#build-and-sign-the-identity-package)
2121
3. [Add identity metadata to your desktop application manifests](#add-identity-metadata-to-your-desktop-application-manifests)
2222
4. [Register the identity package in your installer](#register-the-identity-package-in-your-installer)
23+
5. [Optional steps](#optional-steps)
2324

2425
## Create a package manifest for the identity package
2526

@@ -154,3 +155,14 @@ For production-ready code in C# and C++, see [Sample apps](#sample-apps) below.
154155
## Sample apps
155156

156157
See the [PackageWithExternalLocation](https://aka.ms/sparsepkgsample) samples for fully functional C# and C++ apps that demonstrate how to register an identity package.
158+
159+
## Optional steps
160+
161+
### Localization
162+
163+
Some features that understand package identity might result in strings from your identity package manifest being displayed in the Windows OS. For example:
164+
165+
* An application that uses camera, microphone, or location APIs will have a dedicated control toggle in Windows Privacy Settings along with a brokered consent prompt that users can use to grant or deny access to those sensitive resources.
166+
* An application that registers a share target will show up in the share dialog.
167+
168+
To localize the strings in the identity package manifest, see [Localize the manifest](/windows/uwp/app-resources/using-mrt-for-converted-desktop-apps-and-games#phase-1-localize-the-manifest).

hub/apps/develop/actions/action-json.md

Lines changed: 0 additions & 232 deletions
This file was deleted.

0 commit comments

Comments
 (0)