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
9.06k stars 736 forks source link

Exists in both Microsoft.Windows.SDK.Net and Uno #5663

Closed sigmarsson closed 3 years ago

sigmarsson commented 3 years ago

Current behavior

I have been migrating about 20-30 projects, earlier was a pure WinUI 3 preveiw 4 solution, but by today I rendered them to net5 libraries so I wish to expect the Uno heads soon be starting up.... So I moved the WinUI pages to the shared project and referenced in Desktop and Wasm heads.

image

Desktop:

image

Wasm:

image

The error's contexts

image

image

(Btw, why are the Storage related bits situated in the Uno.UI package? did not even think it was in this particular package)

image

The Suspending event ought to be neat separated by the #ifdef.

image

Throws the error again as this event arg exists in both assembly.

Project files

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>WinExe</OutputType>
        <TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
        <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
        <RootNamespace>Weather.History</RootNamespace>
        <ApplicationManifest>app.manifest</ApplicationManifest>
        <Platforms>x86;x64;</Platforms>
        <RuntimeIdentifiers>win10-x86;win10-x64;</RuntimeIdentifiers>
    </PropertyGroup>
<?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>

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

You need something else of this environment ?

Environment

Nuget Package:

Nuget Package Version(s): Please see above the referenced Nuget packages.

Affected platform(s):

IDE:

image

image

Windows 10 OS spec:

image

xperiandri commented 3 years ago

I have the same issue. What I did is moved all the stuff in Windows projects to Microsoft native packages: WCT, Behaviors, etc. and removed Uno.WinUI reference as a workaround.

jeromelaban commented 3 years ago

To build for Project Reunion, you'll need to reference the Uno.WinUI.* packages. You can get a sample for this using the WinUI 3 dotnet new templates.

sigmarsson commented 3 years ago

I had those Uno.WinUI.* for Wasm as depicted as the last two ones. Just cranked up one solution for desktop with this template, no reference for such packages are configured for the desktop head. As mine lacks them too. dotnet new unoapp-winui -o MyApp

Really beyond me, Cleaned, VS Restart, Rebuild, now having 11446 Errors.

image

These references are set up by that template :

image

sigmarsson commented 3 years ago

1.txt Attached the log file in case any1 has time to review it.

jeromelaban commented 3 years ago

If you can reproduce the issue in small sample app based on the dotnet new template, it'll help.

sigmarsson commented 3 years ago

Template I used : dotnet new unoapp-winui -o "Weather.History" -uwp=false -ios=false -android=false -macos=false -sw=false -sg=false 0.05% of my source : https://github.com/sigmarsson/5663

image

Heads are starting up but throwing run time errors.

GitHub
sigmarsson/5663
Exists in both Microsoft.Windows.SDK.Net and Uno #5663 - sigmarsson/5663
jeromelaban commented 3 years ago

Thanks for the repro. The error you are seeing is an intellisense error only, as the build is likely to work properly.

For the original issue you mentioned, it is likely that you are including Uno.WinUI in library projects that are cross-targeted with WinUI 3. In such case, you'll need to conditionally include the nuget package:

  <ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
    <PackageReference Include="Uno.WinUI" Version="3.6.6" />
  </ItemGroup>

As some of your library projects are failing to build. Ensure those build individually first.

sigmarsson commented 3 years ago

Cool, dependencies are compiling fine and now I am try ing to compile the Desktop head only and c only 16 errors;

image

1.txt

Why is it seeking the types in both Microsoft.WinUI Version=3.0.0.0 and Uno.UI Version=255.255.255.255

sigmarsson commented 3 years ago

I can only succeed to launch the app if I obliterate all references of Uno.UI package and all ones requires it. <!--<PackageReference Include="Uno.UI" Version="3.6.6" />--> <!--<PackageReference Include="Infragistics.Uno.Charts" Version="20.2.59-alpha" />--> Had to remove for example the Infragistics package as well , since it requires Uno.UI. Something is wrong with that package.

jeromelaban commented 3 years ago

Infragistics does not support Uno.WinUI yet, and making a combination of the two is likely to produce the errors you're experiencing.

Have you tried using Uno.UI instead ? (dotnet new unoapp instead of dotnet new unoapp-winui)

sigmarsson commented 3 years ago

I had to reference Uno.UI explicit since I need the Windows.Devices.* and Windows.Storage namespaces but I had to remove them. And without having Infragistics included here, I cannot compile as long as Uno.UI is being referenced.

The Infragistics issue is a separate one then.

sigmarsson commented 3 years ago

App.xaml.cs(89,23): error CS1061: 'LaunchActivatedEventArgs' does not contain a definition for 'UWPLaunchActivatedEventArgs' and no accessible extension method 'UWPLaunchActivatedEventArgs' accepting a first argument of type 'LaunchActivatedEventArgs' could be found (are you missing a using directive or an assembly reference?)

App.xaml.cs(60,44): 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'

Any1 idea why these errors occuring ?

msbuild.zip

jeromelaban commented 3 years ago

This is happening because you have uno installed on your Windows application. Your application seems to be a mix of WinUI and UWP, and I suggest that you restart the migration from a dotnet new unoapp to avoid these conversion errors.

fsol11 commented 1 year ago

This issue is happening for me as well. First I create a blank application which works fine, but as soon as I add Uno.Cupertino, it starts giving a lot of build errors similar to this one:

App.xaml.cs(108,50,108,69): error CS0433: The type 'SuspendingEventArgs' exists in both 'Microsoft.Windows.SDK.NET, Version=10.0.22000.24, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'Uno, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null'

jeromelaban commented 1 year ago

@kazo0 have you noticed this as well?

ghost commented 1 year ago

It is happening right now in a new machine here.

I tried using: dotnet new unoapp -o ProjectName Uno-check is ok, but WSL.

But creating the app using the Visual Studio GUI and selecting Net6, it works fine.