WinUI 3 Preview 2
I didn’t notice for about half a month, but WinUI 3 Preview 2 was released.
So, I tried updating the following WinUI 3 Desktop project, which I previously created using WinUI 3 Preview 1, to Preview 2.
This is a record of that process.
Since I basically just followed the official instructions, there isn’t much useful information here.
Updating the Environment
I’ll check the environment according to the description on the official page.
Ensure Windows 10 version 1803 (build 17134) or later is installed on your development computer
I have Windows 10 2004, so it’s OK.
Install Visual Studio 2019 version 16.7 Preview 3
Checking the version of the installed VS2019 Preview, it was 16.7.0 Preview 3.1.
So, I decided to proceed with this version.

When I checked for updates, 16.8.0 Preview 1.0 was available, but since updating the .NET 5 version to the latest previously caused WinUI 3 Preview 1 to fail to launch, I decided against recklessly updating to the latest version.

.NET 5 Preview 5
It seems WinUI 3 Preview 2 supports .NET 5 Preview 5. Checking the current latest version, Preview 7 was available, but to ensure it works reliably, I’ll stick with Preview 5.
However, this time, the official page description didn’t include the note “Don’t install anything newer than Preview 5” (it did last time), so perhaps Preview 7 might work as well.
Install the WinUI 3 Preview 2 VSIX package
Install the extension for VS. However, when I downloaded and tried to install it, it indicated that it was already installed, so I think it hasn’t changed from Preview 1.
Updating the Project
It seems that projects created with WinUI Preview 1 won’t work as-is with Preview 2, and some edits are necessary.
Details are written on the following page.
Now, let’s edit according to the page above.
Install Microsoft.WinUI Preview 2 via NuGet
It didn’t show up when searching in the NuGet Package Manager.
However, the workaround was also described: install it from the Package Manager Console by entering install-package Microsoft.WinUI -Version 3.0.0-preview2.200713.0
.
Edit .csproj
Change the TargetFramework description from netcoreapp5.0
to net5.0
.
That’s all for this file.
Edit .wapproj
Edit the package project’s configuration file (.wapproj) in a few places.
Change 1
Insert the line <AppxTargetsLocation Condition="'$(AppxTargetsLocation)'==''">$(MSBuildThisFileDirectory)build\</AppxTargetsLocation>
inside the PropertyGroup
after <Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
.
Change 2
Change <Import Project="build\Microsoft.WinUI.AppX.targets" />
to <Import Project="$(AppxTargetsLocation)Microsoft.WinUI.AppX.targets" />
.
Replace files in the package project’s build folder
First, create a new project. This is disposable, so creating it in a temporary folder is fine.
Use the Blank App, Packaged (WinUI in Desktop)
template.
Once the project is created, copy the following two files from [Package project folder]/build/
:
- LiftedWinRTClassRegistrations.xml
- Microsoft.WinUI.AppX.targets
Then, overwrite the files in the same hierarchy in your own package project.
Build and Run
After restarting VS, building, and running, it launched properly.
儀式完了。WinUI Preview1のプロジェクトをPreview2にアップデートできた。 pic.twitter.com/b509OoP6K8
— ayuma (@ayuma_x) August 5, 2020
It seems many bugs have been fixed in WinUI 3 Preview 2 compared to Preview 1, so I’d like to explore various aspects.