While it's possible to upgrade your Preview 1 application to use the new Preview 2 bits, please be careful and follow all steps in order below when doing so. The steps below outline the process that the team had to take while updating their own Preview 1 apps.
If these steps don't work for you, feel free to file an issue. The easiest way to work around this is to just create a new Preview 2 project and copy your content over.
- Make sure all Preview 2 prerequisites are installed. See installation instructions here.
- Use the NuGet package manager (right-click on the project and select “Manage NuGet Packages…” from the context menu)
- Select the “Microsoft.WinUI” package, ensure that “Include prerelease” is checked
- Open the "Package source" dropdown in the top right corner and make sure that WinUI.Dependencies is selected.
- Select the latest version of the package, and then click “Upgrade”, accepting prompts that appear
- If your project is a C# “Blank App (UWP)”, C# “Class Library (UWP)”, C# “Windows Runtime Component (UWP)”, C++ “Blank App (UWP)”, or C++ “Windows Runtime Component (UWP)” project, then no further changes are necessary.
- If your project is a C# “Class Library (WinUI in Desktop)” project:
- Open the .csproj and change netcoreapp5.0 to net5.0
- If your project is a C# “Blank App, Packaged (WinUI in Desktop)” project :
-
Open the .csproj in the main app project and change netcoreapp5.0 to net5.0
-
Open the .wapproj in the associated Windows Application Packaging Project and make the following edits:
- Add the following line to the first
<PropertyGroup>
element after<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
:
<AppxTargetsLocation Condition="'$(AppxTargetsLocation)'==''">$(MSBuildThisFileDirectory)build\</AppxTargetsLocation>
-
Change
<Import Project="build\Microsoft.WinUI.AppX.targets" />
to<Import Project="$(AppxTargetsLocation)Microsoft.WinUI.AppX.targets" />
-
Create a new C# “Blank App, Packaged (WinUI in Desktop)” project, locate the folder containing the associated Windows Application Packaging Project, and copy the contents of the
“build\”
subdirectory (LiftedWinRTClassRegistrations.xml
andMicrosoft.WinUI.AppX.targets
) into the corresponding“build\”
subdirectory of your app’s associated Windows Application Packaging Project, overwriting any existing files when prompted.
- Add the following line to the first
-
- If your project is a C++ “Blank App, Packaged (WinUI in Desktop)” project:
-
Open the .wapproj in the associated Windows Application Packaging Project and make the following edits:
- Add the following line to the first
<PropertyGroup>
element after<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
:
<AppxTargetsLocation Condition="'$(AppxTargetsLocation)'==''">$(MSBuildThisFileDirectory)build\</AppxTargetsLocation>
-
Change
<Import Project="build\Microsoft.WinUI.AppX.targets" />
to<Import Project="$(AppxTargetsLocation)Microsoft.WinUI.AppX.targets" />
-
Create a new C++ “Blank App, Packaged (WinUI in Desktop)” project, locate the folder containing the associated Windows Application Packaging Project, and copy the contents of the
“build\”
subdirectory (LiftedWinRTClassRegistrations.xml
andMicrosoft.WinUI.AppX.targets
) into the corresponding“build\”
subdirectory of your actual project’s associated Windows Application Packaging Project, overwriting any existing files when prompted
- Add the following line to the first
-