Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Windows compilation of WeatherApp sample #799

Open
ikarmus2001 opened this issue Aug 4, 2024 · 0 comments
Open

Issues with Windows compilation of WeatherApp sample #799

ikarmus2001 opened this issue Aug 4, 2024 · 0 comments

Comments

@ikarmus2001
Copy link

ikarmus2001 commented Aug 4, 2024

Addressing the problem

  • Problem: Unable to compile WeatherApp right after cloning
  • Expected behavior: Succesfully compile, eventually require minimal changes to TargetFrameworks tag in WeatherApp.csproj
  • Repro:
    • Clone repository (branch master, commit 1de0a8145b60b02b83afbd1aeb7014679718e9e0)
    • Open WeatherApp.sln in Visual Studio 22
    • Build WeatherApp (not any subprojects, like .Windows or .Wasm)

HI, I wanted to try Uno, decided to run sample on my machine, but I couldn't make it work "right-out-from-the-box".

Clean building from master resulted with some errors:

Rebuild started at 16:51...
Restored D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp.Skia.Gtk\WeatherApp.Skia.Gtk.csproj (in 362 ms).
Restored D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp.Windows\WeatherApp.Windows.csproj (in 489 ms).
Restored D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp.Wasm\WeatherApp.Wasm.csproj (in 511 ms).
Restored D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp.Mobile\WeatherApp.Mobile.csproj (in 784 ms).
Restored D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\WeatherApp.csproj (in 1,09 sec).
1>------ Rebuild All started: Project: WeatherApp, Configuration: Debug Any CPU ------
1>D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\GlobalUsings.cs(15,46,15,57): error CS0234: The type or namespace name 'Application' does not exist in the namespace 'Microsoft.UI.Xaml' (are you missing an assembly reference?)
1>D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\GlobalUsings.cs(8,24,8,34): error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
1>D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\GlobalUsings.cs(9,24,9,34): error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
1>D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\GlobalUsings.cs(11,32,11,40): error CS0234: The type or namespace name 'Controls' does not exist in the namespace 'Microsoft.UI.Xaml' (are you missing an assembly reference?)
1>D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\GlobalUsings.cs(12,32,12,37): error CS0234: The type or namespace name 'Media' does not exist in the namespace 'Microsoft.UI.Xaml' (are you missing an assembly reference?)
1>D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\GlobalUsings.cs(13,32,13,42): error CS0234: The type or namespace name 'Navigation' does not exist in the namespace 'Microsoft.UI.Xaml' (are you missing an assembly reference?)
1>D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\WeatherModel.cs(3,7,3,10): error CS0246: The type or namespace name 'Uno' could not be found (are you missing a using directive or an assembly reference?)
1>D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\MainPage.xaml.cs(3,40,3,44): error CS0246: The type or namespace name 'Page' could not be found (are you missing a using directive or an assembly reference?)
1>D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\WeatherModel.cs(7,12,7,30): error CS0246: The type or namespace name 'IFeed<>' could not be found (are you missing a using directive or an assembly reference?)
1>D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\App.cs(5,23,5,29): error CS0246: The type or namespace name 'Window' could not be found (are you missing a using directive or an assembly reference?)
1>D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\App.cs(7,44,7,68): error CS0246: The type or namespace name 'LaunchActivatedEventArgs' could not be found (are you missing a using directive or an assembly reference?)
1>D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\App.cs(45,48,45,73): error CS0246: The type or namespace name 'NavigationFailedEventArgs' could not be found (are you missing a using directive or an assembly reference?)
1>Done building project "WeatherApp.csproj" -- FAILED.
1>WeatherApp -> D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\bin\Debug\net8.0\WeatherApp.dll
1>WeatherApp -> D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\bin\Debug\net8.0-maccatalyst\maccatalyst-x64\WeatherApp.dll
1>WeatherApp -> D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\bin\Debug\net8.0-ios\iossimulator-x64\WeatherApp.dll
1>WeatherApp -> D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\bin\Debug\net8.0-android\WeatherApp.dll
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
========== Rebuild completed at 16:51 and took 08,839 seconds ==========

Possible (partial) workaround / solution

Came up to docs about .NET 8 Rid Graph breaking changes.

Applying recommended action, which is specifying RuntimeIdentifier to targeted platform (win-x64 in my case) made me able to compile and run the app.

WeatherApp.csproj

<TargetFrameworks>$(TargetFrameworks);net8.0</TargetFrameworks>  <!--;net8.0-ios;net8.0-android;net8.0-maccatalyst  COMMENTED OUT VERSIONS-->
<!--<RuntimeIdentifiers>win-x86</RuntimeIdentifiers> --><!--Added line-->
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers> <!--Or this one-->
Rebuild started at 16:58...
Restored D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp.Skia.Gtk\WeatherApp.Skia.Gtk.csproj (in 207 ms).
Restored D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp.Windows\WeatherApp.Windows.csproj (in 214 ms).
Restored D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\WeatherApp.csproj (in 223 ms).
Restored D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp.Wasm\WeatherApp.Wasm.csproj (in 244 ms).
Restored D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp.Mobile\WeatherApp.Mobile.csproj (in 497 ms).
1>------ Rebuild All started: Project: WeatherApp, Configuration: Debug Any CPU ------
1>WeatherApp -> D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\bin\Debug\net8.0\WeatherApp.dll
1>C:\Program Files\dotnet\sdk\8.0.303\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(284,5): warning NETSDK1206: Found version-specific or distribution-specific runtime identifier(s): win10-arm64, win10-x64, win10-x86. Affected libraries: Microsoft.WindowsAppSDK. In .NET 8.0 and higher, assets for version-specific and distribution-specific runtime identifiers will not be found by default. See https://aka.ms/dotnet/rid-usage for details.
1>WeatherApp -> D:\gitRepos\Uno.Samples\UI\MvuxHowTos\WeatherApp\WeatherApp\bin\Debug\net8.0-windows10.0.19041\WeatherApp.dll
1>Done building project "WeatherApp.csproj".
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
========== Rebuild completed at 16:58 and took 04,407 seconds ==========

After provided changes the app is compiled properly, can be debugged etc.

Environmental details:

Windows 10 22H2 19045.4651
Uno platform VSIX: 5.3.18.22
Visual Studio 22 v 17.10.5

>dotnet --list-runtimes
Microsoft.AspNetCore.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

>dotnet sdk check
Zestawy .NET SDK:
Wersja       Stan
----------------------
8.0.206      Aktualne.
8.0.303      Aktualne.

Wypróbuj najnowsze funkcje zestawu .NET SDK, używając platformy .NET 9.0.100-preview.6.24328.19.

Środowiska uruchomieniowe platformy .NET:
Nazwa                             Wersja      Stan
--------------------------------------------------------------------------------------------------
Microsoft.AspNetCore.App          6.0.32      Platforma .NET 6.0 wkrótce przestanie być wspierana.
Microsoft.NETCore.App             6.0.32      Platforma .NET 6.0 wkrótce przestanie być wspierana.
Microsoft.WindowsDesktop.App      6.0.32      Platforma .NET 6.0 wkrótce przestanie być wspierana.
Microsoft.AspNetCore.App          8.0.6       Poprawka 8.0.7 jest dostępna.
Microsoft.NETCore.App             8.0.6       Poprawka 8.0.7 jest dostępna.
Microsoft.WindowsDesktop.App      8.0.6       Poprawka 8.0.7 jest dostępna.
Microsoft.AspNetCore.App          8.0.7       Aktualne.
Microsoft.NETCore.App             8.0.7       Aktualne.
Microsoft.WindowsDesktop.App      8.0.7       Aktualne.

uno-check

> OpenJDK 11.0 Checkup...
  - 11.0.20.1 (C:\Program Files\Microsoft\jdk-11.0.20.101-hotspot\bin\..)
  - 21.0.2 (C:\Program Files\Eclipse Adoptium\jdk-21.0.2.13-hotspot)

> Visual Studio 17.9.0 Checkup...
  - 17.10.5 - C:\Program Files\Microsoft Visual Studio\2022\Community

> Visual Studio Workloads Checkup...
  - .NET desktop development is installed (17.10.5)
  - .NET Multi-platform App UI development is installed (17.10.5)
  - ASP.NET and web development is installed (17.10.5)

> Android SDK Checkup...
  - emulator (34.2.16)
  - build-tools;34.0.0 (34.0.0)
  - platforms;android-34 (3)
  - system-images;android-34;google_apis;x86_64 (13)
  - platform-tools (34.0.5)
  - cmdline-tools;5.0 (5.0)

> Android Emulator Checkup...
  - Emulator: Android_Emulator_34 found.

> .NET SDK Checkup...
  - 8.0.206 - C:\Program Files\dotnet\sdk\8.0.206
  - 8.0.303 - C:\Program Files\dotnet\sdk\8.0.303

> PowerShell Execution Policy Checkup...

> Windows Python Installation Checkup...
  - Python is installed in C:\Windows\.

> Windows Long Path Checkup...
  - Long paths are enabled on Windows!

> Git Checkup...
SHELL: git --version
git version 2.45.2.windows.1

> Windows Hyper-V Checkup...
  - Hyper-V is configured

> dotnet new Uno Project Command Line Templates Checkup...

> Uno SDK Checkup...

> Edge WebView2 Checkup...
  - Found Edge WebView2 version 126.0.2592.113

> .NET SDK - Workloads (8.0.300) Checkup...
  - microsoft.net.sdk.android (34.0.95/8.0.100) installed.
  - microsoft.net.sdk.ios (17.2.8053/8.0.100) installed.
  - microsoft.net.sdk.maccatalyst (17.2.8053/8.0.100) installed.
  - microsoft.net.sdk.macos (14.2.8053/8.0.100) installed.
  - microsoft.net.sdk.maui (8.0.61/8.0.100) installed.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
- Congratulations, everything looks great!

Additional remarks

I was unable to build project due to App.cs _window possible null dereference in OnLaunched(LaunchActivatedEventArgs):17

        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
#if NET6_0_OR_GREATER && WINDOWS && !HAS_UNO
		_window = new Window();
#else
            _window = Microsoft.UI.Xaml.Window.Current;
#endif

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (_window.Content is not Frame rootFrame)

It could be resolved by marking _windows explicitely not null - _window!.Content.
I wanted to make PR, but wasn't sure if it is not my environmental error or something.

If any detail is missing I'll be more than happy to help. Tried searching for other issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant