You can use Visual Studio to generate a package for your desktop app. Then, you can publish that package to the Windows store or sideload it onto one or more PCs.
This guide shows you how to set up your solution and then generate a package for your desktop application.
First, consider how you'll distribute your app
If you plan to publish your app to the Windows Store, start by filling out this form. Microsoft will contact you to start the onboarding process. As part of this process, you'll reserve a name in the store, and obtain information that you'll need to package your app.
Add a packaging project to your solution
In Visual Studio, open the solution that contains your desktop application project.
You won't have to add any code to it. It's just there to generate a package for you. We'll refer to this project as the "packaging project".
Add the desktop application binaries to the packaging project
Add the binaries directly to the packaging project.
In Solution Explorer, expand the packaging project folder, create a subfolder, and name it whatever you want (For example: win32).
Right-click the subfolder, and then choose Add Existing Item.
In the Add Existing Item dialog box, locate and then add the files from your desktop application's output folder. This includes not just the executable files, but any dlls or .config files that are located in that folder.
Every time you make a change to your desktop application project, you'll have to copy a new version of those files to the packaging project. You can automate this by adding a post-build event to the project file of the packaging project. Here's an example.
<Target Name="PostBuildEvent"> <Copy SourceFiles="..\MyWindowsFormsApplication\bin\Debug\MyWindowsFormsApplication.exe" DestinationFolder="win32" /> <Copy SourceFiles="..\MyWindowsFormsApplication\bin\Debug\MyWindowsFormsApplication.exe.config" DestinationFolder="win32" /> <Copy SourceFiles="..\MyWindowsFormsApplication\bin\Debug\MyWindowsFormsApplication.pdb" DestinationFolder="win32" /> <Copy SourceFiles="..\MyWindowsFormsApplication\bin\Debug\MyBusinessLogicLibrary.dll" DestinationFolder="win32" /> <Copy SourceFiles="..\MyWindowsFormsApplication\bin\Debug\MyBusinessLogicLibrary.pdb" DestinationFolder="win32" /> </Target>
Modify the package manifest
The packaging project contains a file that describes the settings of your package. By default, this file describes a UWP app, so you'll have to modify it so that the system understands that your package includes a desktop application that runs in full trust.
In Solution Explorer, expand the packaging project, right-click the package.appxmanifest file, and then choose View Code.
Add this namespace to the top of the file, and add the namespace prefix to the list of
When you're done, your namespace declarations will look something like this:
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap">
TargetDeviceFamilyelement, and set the
Nameattribute to Windows.Desktop, the
MinVersionattribute to the minimum version of the packaging project, and the
MaxVersionTestedto the target version of the packaging project.
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.10586.0" MaxVersionTested="10.0.15063.0" />
You can find the minimum version and target version in the property pages of the packaging project.
StartPageattribute from the
Applicationelement. Then, add the
Applicationelement will look like this.
<Application Id="App" Executable=" " EntryPoint=" ">
Executableattribute to the name of your desktop application's executable file. Then, set the
EntryPointattribute to Windows.FullTrustApplication.
Applicationelement will look similar to this.
<Application Id="App" Executable="win32\MyWindowsFormsApplication.exe" EntryPoint="Windows.FullTrustApplication">
runFullTrustcapability to the
Blue squiggly marks might appear beneath this declaration, but you can safely ignore them.
If your creating a package for a C++ desktop application, you'll have to make a few extra changes to your manifest file so that you can deploy the Visual C++ runtimes along with your app. See Using Visual C++ runtimes in a desktop bridge project.
Build the packaging project to ensure that no errors appear.
If you want to test your package, see Run, debug, and test a packaged desktop app (Desktop Bridge).
Then, return to this guide, and see the next section to generate your package.
Generate a package
To generate a package your app, follow the guidance described in this topic: Packaging UWP Apps.
When you reach the Select and Configure Packages screen, Take a moment to consider what sorts of binaries you're including in your package before you select any of the checkboxes.
If you've extended your desktop application by adding a adding a C#, C++, or VB.NET-based Universal Windows Platform project to your solution, select the x86 and x64 checkboxes.
Otherwise, choose the Neutral checkbox.
The reason that you'd have to explicitly choose each supported platform is because an solution that you've extended contains two types of binaries; one for the UWP project and one for the desktop project. Because these are different types of binaries, .NET Native needs to explicitly produce native binaries for each platform.
Run your app / find and fix issues
Enhance your desktop app by adding UWP APIs
Extend your desktop app by adding UWP components
Distribute your app
Find answers to specific questions
Our team monitors these StackOverflow tags.
Give feedback about this article
Use the comments section below.