Microsoft-ui-xaml: Cannot run WinUI 3 in desktop(C#) after updating toolset

Created on 15 Jun 2020  ·  21Comments  ·  Source: microsoft/microsoft-ui-xaml

I confirmed that I can run the template app when it released at Duild.
But now, I can neither run the code I created then, nor a blank new template app.
The original version I deployed at May can run, so it's a toolset issue, not an OS issue.

What I've done from Build (May 20):

  • Update patch versions of VS(16.6.0->16.6.2, 16.7P1->16.7P2)
  • Install Windows SDK 19041, but haven't uninstalled 18362
  • Update .NET 5 from Preview 4 to Preview 5

What symptoms I've met now:

  • At the default state, deployment of the package project will fail, claims that .NET Framework 4.5.1 target pack is not found. The Universal Windows Development workload of VS requires 4.5, not 4.5.1
  • After manually select and installed the target pack, deployment successes, but the app throws at WinRT.ComWrappersSupport.InitializeComWrappers, as-if it's running unpacked

I guess the first issue is caused by new Windows SDK, and the second issue is caused by new preview of .NET 5. I don't want to downgrade them to confirm this. Please consider to update the template version.

The detailed environment of my machine (You can create a new VM and confirm if the template app will fail):

Windows 10 Pro 19041
Visual Studio Enterprise 16.6.2
  - .NET Desktop workload
  - UWP workload, 18362 and 19041 selected
Visual Studio Community 16.7 Preview 2
  - .NET Desktop workload
  - UWP workload, no optional checkbox selected
  - WinUI3 vsix template
.NET 5 SDK Preview 5 x64 (and also the versions come with VS)
question winui3preview

All 21 comments

@stevenbrix as FYI

@huoyaoyuan the issue with the latest .NET5 Preview5 is a known issue: https://github.com/microsoft/CsWinRT/issues/316

Can you elaborate a bit more on the first one? I'm surprised you need the .NET Framework SDK at all?

@stevenbrix The error was raised at Microsoft.Common.CurrentVersion.targets, L1177
Invoking Build on the package project in VS16.7P2 raises it.

Using toolset from VS16.7 Preview raises the error, but VS16.6 toolset can build succesfully.

Here are msbuild logs:

binlog.zip

@huoyaoyuan thanks for sharing the binlogs! It looks like there was a change to the Microsoft.DesktopBridge.targets in VS16.7 Preview2 that broke this.

VS 16.6:
image

VS 16.7 Preview2:
image

I'll reach out to the VS folks to see if this is a known issue. I found the commit that caused this regression, and it's weird because this should affect VS16.7 Preview1 as well, but I don't think we've had issues with that?

@huoyaoyuan can you try adding this to your .wapproj and see if that fixes it for you?


  <PropertyGroup>
    <TargetFrameworkIdentifier>.NETCore</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
  </PropertyGroup>

@huoyaoyuan can you try adding this to your .wapproj and see if that fixes it for you?

@stevenbrix Yes, it fixes building of wapproj.

@huoyaoyuan that's good to know. Do you have the .NET Framework SDK installed? VS will install that by default, so I'm wondering if maybe your install was unsuccessful?

Do you have the .NET Framework SDK installed?

The versions of .NET Framework target packs I've installed:

  • The one required by .NET Desktop workload (4.7.2)
  • The one required by UWP workload (4.5)
  • The one I've manually chosen (4.8)

But, Microsoft.Common.targets was asking for 4.5.1.
I'd expect UWP workload to ask for 4.5 because it does list 4.5 as it's dependency.

@stevenbrix Latest update:
It works with .NET 5 Preview 6 with latest CsWinRT(0.1.0-prerelease.200629.3) installed.
It still have build issue with VS 16.7P4. Your workaround is valid, but please mention the VS SDK folks.

VS bug regarding the regression is filed here: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1149356/

Closing this issue as both symptoms have been resolved

The VS issue is still present in 16.7P6. Please remember it before 16.7 is released.

@stevenbrix I have to mention you again, because this issue prevents me from building the WinUI3 desktop branch of xaml controls gallery.
It generates two errors for missing reference assemblies for .NET Framework, Version=4.5.1 and .NET Framework, Version=5.0. Your workaround only eliminates the first one. Confirmed on VS16.7.1.
Is the fix applied in 16.8?

@huoyaoyuan i'm updating to vs16.7.2 and will let you know what i find

@huoyaoyuan I wonder if your VS config is a bit off. I was able to build with VS16.7.2.

Here is a link to my vs config

See the documentation for how to import this file: https://docs.microsoft.com/en-us/visualstudio/install/import-export-installation-configurations?view=vs-2019#import-a-configuration

This should hopefully get your VS in the correct state.

@stevenbrix I've installed a brand new instance with your config, but was still not able to build it.

To be clear, the solution I built is XamlControlGallery.Desktop.sln in winui3preview branch. Could you confirm that your configuration does work with that solution? Thanks!

Hmm I was able to build and run the desktop sln as well @huoyaoyuan

@stevenbrix I tried on my another machine, and the issue is still present.
Here is the binlog produced.
XamlControlsGallery.binlog.zip

@huoyaoyuan do you have the setting in VS to enable preview versions of .NET Core SDKs?

vs-enablepreview

@stevenbrix Thanks, that solves the problem. I always use global.json to specify preview SDK and have nearly forgotten the global switch.

@huoyaoyuan, fantastic! Yeah, I usually get different errors when I don't have this enabled, you can thank @alwu-msft for this one :)

Was this page helpful?
0 / 5 - 0 ratings