unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.79k stars 706 forks source link

Unhandled exception. System.Exception: Could not resolve PresentationCore :: 2.1.0-dev.48\build\Uno.Wasm.Bootstrap.targets 173 #5719

Closed sigmarsson closed 3 years ago

sigmarsson commented 3 years ago

Wasm head compilation errors

image

This is the project file :

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5</TargetFramework>
    <NoWarn>NU1701</NoWarn>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)'=='Debug'">
    <MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled>
    <DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
    <DebugType>portable</DebugType>
    <DebugSymbols>true</DebugSymbols>
  </PropertyGroup>
  <ItemGroup>
    <Content Include="Assets\SplashScreen.png" />
  </ItemGroup>
  <ItemGroup>
    <UpToDateCheckInput Include="..\Weather.History.Shared\**\*.xaml" />
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="WasmCSS\Fonts.css" />
    <EmbeddedResource Include="WasmScripts\AppManifest.js" />
  </ItemGroup>
  <ItemGroup>
    <LinkerDescriptor Include="LinkerConfig.xml" />
  </ItemGroup>
  <ItemGroup>
    <!--
    This item group is required by the project template because of the
    new SDK-Style project, otherwise some files are not added automatically.

    You can safely remove this ItemGroup completely.
    -->
    <None Include="Program.cs" />
    <None Include="LinkerConfig.xml" />
    <None Include="wwwroot\web.config" />
  </ItemGroup>
  <ItemGroup>
    <!--<PackageReference Include="Infragistics.Uno.Wasm.Charts" Version="20.2.59-alpha" />-->
    <PackageReference Include="Microsoft.NETCore.Targets" Version="6.0.0-preview.3.21201.4" PrivateAssets="all" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0-preview.3.21201.4" />
    <PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.0.1" />
    <PackageReference Include="Uno.WinUI.WebAssembly" Version="3.7.0-dev.195" />
    <PackageReference Include="Uno.WinUI.RemoteControl" Version="3.7.0-dev.195" Condition="'$(Configuration)'=='Debug'" />
    <PackageReference Include="Uno.Wasm.Bootstrap" Version="2.1.0-dev.48" />
    <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="2.1.0-dev.48" />
    <!--<PackageReference Include="Uno.UI" Version="3.6.6" />-->
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Weather.History.Abstract\Weather.History.Abstract.csproj" />
    <ProjectReference Include="..\Weather.History.AppService\Weather.History.AppService.csproj" />
    <ProjectReference Include="..\Weather.History.CrossCutting\Weather.History.CrossCutting.csproj" />
    <ProjectReference Include="..\Weather.History.Dal\Weather.History.Dal.csproj" />
    <ProjectReference Include="..\Weather.History.DataService\Weather.History.DataService.csproj" />
    <ProjectReference Include="..\Weather.History.Entity\Weather.History.Entity.csproj" />
    <ProjectReference Include="..\Weather.History.IoC\Weather.History.IoC.csproj" />
    <ProjectReference Include="..\Weather.History.Log\Weather.History.Log.csproj" />
  </ItemGroup>
  <Import Project="..\Weather.History.Shared\Weather.History.Shared.projitems" Label="Shared" Condition="Exists('..\Weather.History.Shared\Weather.History.Shared.projitems')" />
  <ItemGroup>
    <PackageReference Update="Microsoft.Windows.Compatibility" Version="6.0.0-preview.3.21201.4" />
  </ItemGroup>
</Project>

How to reproduce it (as minimally and precisely as possible)

Perhaps the presence of the preview packages ?

Workaround

Yet undisclosed.

Environment

Nuget Package:

Nuget Package Version(s):

    <PackageReference Include="Microsoft.NETCore.Targets" Version="6.0.0-preview.3.21201.4" PrivateAssets="all" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0-preview.3.21201.4" />
    <PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.0.1" />
    <PackageReference Include="Uno.WinUI.WebAssembly" Version="3.7.0-dev.195" />
    <PackageReference Include="Uno.WinUI.RemoteControl" Version="3.7.0-dev.195" Condition="'$(Configuration)'=='Debug'" />
    <PackageReference Include="Uno.Wasm.Bootstrap" Version="2.1.0-dev.48" />
    <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="2.1.0-dev.48" />

Affected platform(s):

IDE:

Relevant plugins:

Anything else we need to know?

Perhaps <TargetFramework>net5</TargetFramework> causin problems ?

Build log

jeromelaban commented 3 years ago

It looks like you've added a reference to a package that uses WPF somehow, which is not supported by Uno. You're also trying to use net6 packages, which are not yet tested with Uno.

sigmarsson commented 3 years ago

Okay, set them back down to 5 and also obliterated that Desktop build target but still witness exactly the same 9 errors as earlier.

image

Build log

jeromelaban commented 3 years ago

Can you share the build binlog as mentioned here: https://platform.uno/docs/articles/uno-builds-troubleshooting.html ?

Troubleshooting build issues
sigmarsson commented 3 years ago
  1. $msbuild Weather.History.sln /bl without PackageReference Include="Uno.UI" Version="3.6.6"

msbuild.zip image

  1. $msbuild Weather.History.sln /bl with PackageReference Include="Uno.UI" Version="3.6.6"

msbuild.Uno.UI.3.6.6.zip image

jeromelaban commented 3 years ago

Thanks for the binlog. You're importing a dependency to vanara.pinvoke.gdi32, which uses WPF. You'll need to remove it from your dependencies for this to work on WebAssembly.

sigmarsson commented 3 years ago

Done. Whats more, vanara* removed but still 11432 errors while building the Wasm head and those 14 errors in winUI head still vexing if Uno.UI 3.6.6 is being referenced, exhibited by #5663

jeromelaban commented 3 years ago

Can you post again a binlog ?

sigmarsson commented 3 years ago

msbuild.Uno.UI.3.6.6.-vanara.zip

jeromelaban commented 3 years ago

Thanks. You cannot mix Uno.UI and Uno.WinUI in the same solution. Your project file contains this:

    <PackageReference Include="Uno.WinUI.WebAssembly" Version="3.7.0-dev.195" />
    <PackageReference Include="Uno.WinUI.RemoteControl" Version="3.7.0-dev.195" Condition="'$(Configuration)'=='Debug'" />
    <PackageReference Include="Uno.Wasm.Bootstrap" Version="2.1.0-dev.48" />
    <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="2.1.0-dev.48" />
    <PackageReference Include="Uno.UI" Version="3.6.6" />

You need to remove the last Uno.UI reference.

sigmarsson commented 3 years ago

Merci. That was helping everything to resolve on the Wasm head. Did you mean those WinUI and UI packages are exclusive incompatible for any head ? e.g. Like these ones in the Desktop head ?

<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.5.0" />
<PackageReference Include="Uno.UI" Version="3.6.6" />
jeromelaban commented 3 years ago

That's exactly right, you cannot have both packages in a project, directly or indirectly.

sigmarsson commented 3 years ago

Okay. But how shall I harness the Windows.Devices and Windows.Storage namespaces in this case ?

jeromelaban commented 3 years ago

If you're on the UWP project, you can use those APIs directly, they are readily available. If on non-windows platforms, you can use Uno.UI or Uno.WinUI but not both. Also you cannot use Microsoft.ProjectReunion.WinUI but it is already part of the Uno.WinUI package for the non-windows platforms.

sigmarsson commented 3 years ago

Okay, cool. You will introduce a new package or multiple ones later for Windows non-UWP to make Windows.Devices and Windows.Storage namespaces available. Is that true?

jeromelaban commented 3 years ago

Those namespaces are already available in all targets. The errors you are getting are caused by both packages (Uno.UI and Uno.WinUI) being present, you need only one.

sigmarsson commented 3 years ago

Would you mind I am dispatching you another binlog ? Just replaced the WinUI pgks with Uno.UI and got this :

msbuild.zip

I can find no more refs on Uno.WinUI pkg.

jeromelaban commented 3 years ago

Thanks. Replacing Uno.WinUI with Uno.UI also implies moving most of the Microsoft.UI.Xaml to Windows.UI.Xaml as well (WinUI to UWP).

sigmarsson commented 3 years ago

Okay, changed the NS and droped Microsoft.ProjectReunion* too and now under 20 errors.

msbuild.zip

Why TabView cannot be found now ?

sigmarsson commented 3 years ago

https://stackoverflow.com/questions/60053616/tabview-suddenly-missing-from-uwp

Perhaps TabView isnt existing any more in UWP? Shall I install the Microsoft.UI.Xaml pkg?

Stack Overflow
TabView suddenly missing from UWP
Was trying to implement a TabView in my UWP project yesterday but it doesn't show up in the ToolBox and if I add it via code it says TabView is not supported in a Windows Universal Project. Th...
sigmarsson commented 3 years ago

Okay, Microsoft.UI.Xaml pkg added and hopefully the remaining error is the one exhibited in #5663

With.Microsoft.UI.Xaml.nuget.zip

error CS0433: The type 'LaunchActivatedEventArgs' exists in both 'Microsoft.Windows.SDK.NET, Version=10.0.19041.10, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'Uno, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null'

jeromelaban commented 3 years ago

The Microsoft.UI.Xaml package cannot be added to the Uno heads, and only on the UWP head. You will have to uninstall it from the Uno heads.

sigmarsson commented 3 years ago

Pkg dropped.

The rest ones found in App.xaml.cs

msbuild.zip

image