fabulous-dev / Fabulous.XamarinForms

Declarative UIs for Xamarin.Forms with F# and MVU, using Fabulous
https://docs.fabulous.dev/xamarinforms
Apache License 2.0
13 stars 1 forks source link

[Bug] Getting error while trying to build project created from "fabulous-xf-app" template #20

Closed sumeetdas closed 1 year ago

sumeetdas commented 2 years ago

Description

Steps to Reproduce

  1. Created new project from scratch via dotnet new fabulous-xf-app -n SqueakyApp
  2. Try deploying app to android virtual device via Debug Any CPU for SqueakyApp.Android.

Expected Behavior

Should be able to deploy the app to android emulator.

Actual Behavior

Getting the following build error:

Build started... 1>------ Build started: Project: SqueakyApp.Android, Configuration: Debug Any CPU ------ 1>packages.config: warning XA0101: @(Content) build action is not supported 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(157,3): error APT2260: resource style/Theme.AppCompat.Light.Dialog (aka com.companyname:style/Theme.AppCompat.Light.Dialog) not found. 1>Resources\values\styles.xml(4,0): error APT2260: style attribute 'attr/colorAccent (aka com.companyname:attr/colorAccent)' not found. 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(157,3): error APT2260: resource style/Theme.AppCompat.Light.DarkActionBar (aka com.companyname:style/Theme.AppCompat.Light.DarkActionBar) not found. 1>Resources\values\styles.xml(2,0): error APT2260: style attribute 'attr/windowNoTitle (aka com.companyname:attr/windowNoTitle)' not found. 1>Resources\values\styles.xml(2,0): error APT2260: style attribute 'attr/windowActionBar (aka com.companyname:attr/windowActionBar)' not found. 1>Resources\values\styles.xml(2,0): error APT2260: style attribute 'attr/colorPrimary (aka com.companyname:attr/colorPrimary)' not found. 1>Resources\values\styles.xml(2,0): error APT2260: style attribute 'attr/colorPrimaryDark (aka com.companyname:attr/colorPrimaryDark)' not found. 1>Resources\values\styles.xml(3,0): error APT2260: style attribute 'attr/colorAccent (aka com.companyname:attr/colorAccent)' not found. 1>Resources\values\styles.xml(4,0): error APT2260: style attribute 'attr/windowActionModeOverlay (aka com.companyname:attr/windowActionModeOverlay)' not found. 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(157,3): error APT2062: failed linking references. 1>Done building project "SqueakyApp.Android.fsproj" -- FAILED. 1> 1>Build FAILED. ========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ========== ========== Deploy: 0 succeeded, 0 failed, 0 skipped ========

Basic Information

Environment

Microsoft Visual Studio Community 2019 (2) Version 16.11.10 VisualStudio.16.Release/16.11.10+32126.315 Microsoft .NET Framework Version 4.8.04161

Installed Version: Community

Azure App Service Tools v3.0.0 16.11.106.23128 Azure App Service Tools v3.0.0

C# Tools 3.11.0-4.21602.3+fc14a1355c0461af5110b74b26f6478f22d26565 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus 1.2.6 (master@34d6af2) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers

Mono Debugging for Visual Studio 16.10.15 (552afdf) Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 5.11.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info

Visual Basic Tools 3.11.0-4.21602.3+fc14a1355c0461af5110b74b26f6478f22d26565 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 16.11.0-beta.21514.6+b6c2c4f53ea3a08fa603ea93d6d2f808a62a21d1 Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

VisualStudio.DeviceLog 1.0 Information about my package

VisualStudio.Foo 1.0 Information about my package

VisualStudio.Mac 1.0 Mac Extension for Visual Studio

Xamarin 16.11.000.197 (d16-11@6934992) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 16.11.0.47 (remotes/origin/d16-11@e0d612363) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.10.5 (355b57a) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 12.0.0.3 (d16-11/f0e3c2d) Xamarin.Android Reference Assemblies and MSBuild support. Mono: c633fe9 Java.Interop: xamarin/java.interop/d16-11@476bb5b ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.35.4@85460d3 Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-11@87af37b

Xamarin.iOS and Xamarin.Mac SDK 15.2.0.17 (738fde344) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

Have pasted above under Actual Result section.

Screenshots

Build error issue; no screenshots.

Reproduction Link

Tried installing the app locally.

Workaround

No workaround so far.

Confuset commented 1 year ago

Even so this issue seems to be old i have a similar problem when trying to build it. First I installed the templates:

dotnet new install Fabulous.XamarinForms.Templates
  Fabulous.XamarinForms.Templates

Erfolg: Fabulous.XamarinForms.Templates::2.1.3 installierte die folgenden Vorlagen:
Vorlagenname            Kurzname           Sprache  Tags
----------------------  -----------------  -------  ----------------------
Fabulous XF Blank       fabulous-xf        F#       Fabulous/Xamarin.Forms
Fabulous XF VS Windows  fabulous-xf-vswin  F#       Fabulous/Xamarin.Forms

Then I create the fresh app:

dotnet new fabulous-xf-vswin -n SplitApp
Die Vorlage "Fabulous XF VS Windows" wurde erfolgreich erstellt.

Then I tried to build the app via command line:

dotnet build

MSBuild version 17.4.0+18d5aef85 for .NET
C:\Users\confuset\source\repos\SplitApp\SplitApp.iOS\SplitApp.iOS.fsproj : warning NU1503: Skipping restore for project 'C:\Users\confuset
\source\repos\SplitApp\SplitApp.iOS\SplitApp.iOS.fsproj'. The project file may be invalid or missing targets required for restore. [
C:\Users\confuset\source\repos\SplitApp\SplitApp.sln]
C:\Users\confuset\source\repos\SplitApp\SplitApp.Android\SplitApp.Android.fsproj : warning NU1503: Skipping restore for project 'C:\Use
rs\confuset\source\repos\SplitApp\SplitApp.Android\SplitApp.Android.fsproj'. The project file may be invalid or missing targets require
d for restore. [C:\Users\confuset\source\repos\SplitApp\SplitApp.sln]
  Determining projects to restore...
  Restored C:\Users\confuset\source\repos\SplitApp\SplitApp\SplitApp.fsproj (in 452 ms).
C:\Users\confuset\source\repos\SplitApp\SplitApp.Android\SplitApp.Android.fsproj(282,5): error MSB4019: The imported project "C:\Progra
m Files\dotnet\sdk\7.0.101\Xamarin\Android\Xamarin.Android.FSharp.targets" was not found. Confirm that the expression in the Import
declaration "C:\Program Files\dotnet\sdk\7.0.101\\Xamarin\Android\Xamarin.Android.FSharp.targets" is correct, and that the file exis
ts on disk.
C:\Users\confuset\source\repos\SplitApp\SplitApp.iOS\SplitApp.iOS.fsproj(156,5): error MSB4019: The imported project "C:\Program Files\
dotnet\sdk\7.0.101\Xamarin\iOS\Xamarin.iOS.FSharp.targets" was not found. Confirm that the expression in the Import declaration "C:\
Program Files\dotnet\sdk\7.0.101\\Xamarin\iOS\Xamarin.iOS.FSharp.targets" is correct, and that the file exists on disk.
  SplitApp -> C:\Users\confuset\source\repos\SplitApp\SplitApp\bin\Debug\netstandard2.1\SplitApp.dll

Build FAILED.

C:\Users\confuset\source\repos\SplitApp\SplitApp.iOS\SplitApp.iOS.fsproj : warning NU1503: Skipping restore for project 'C:\Users\confuset
\source\repos\SplitApp\SplitApp.iOS\SplitApp.iOS.fsproj'. The project file may be invalid or missing targets required for restore. [
C:\Users\confuset\source\repos\SplitApp\SplitApp.sln]
C:\Users\confuset\source\repos\SplitApp\SplitApp.Android\SplitApp.Android.fsproj : warning NU1503: Skipping restore for project 'C:\Use
rs\confuset\source\repos\SplitApp\SplitApp.Android\SplitApp.Android.fsproj'. The project file may be invalid or missing targets require
d for restore. [C:\Users\confuset\source\repos\SplitApp\SplitApp.sln]
C:\Users\confuset\source\repos\SplitApp\SplitApp.Android\SplitApp.Android.fsproj(282,5): error MSB4019: The imported project "C:\Progra
m Files\dotnet\sdk\7.0.101\Xamarin\Android\Xamarin.Android.FSharp.targets" was not found. Confirm that the expression in the Import
declaration "C:\Program Files\dotnet\sdk\7.0.101\\Xamarin\Android\Xamarin.Android.FSharp.targets" is correct, and that the file exis
ts on disk.
C:\Users\confuset\source\repos\SplitApp\SplitApp.iOS\SplitApp.iOS.fsproj(156,5): error MSB4019: The imported project "C:\Program Files\
dotnet\sdk\7.0.101\Xamarin\iOS\Xamarin.iOS.FSharp.targets" was not found. Confirm that the expression in the Import declaration "C:\
Program Files\dotnet\sdk\7.0.101\\Xamarin\iOS\Xamarin.iOS.FSharp.targets" is correct, and that the file exists on disk.
    2 Warning(s)
    2 Error(s)

Time Elapsed 00:00:07.07

Any ideas?

TimLariviere commented 1 year ago

@Confuset I believe your issue is related to dotnet build. Xamarin.Forms do not support the new .NET Core framework (like .NET 7.0). Instead, it still relies on the old Mono framework.

If you want to compile it from the command line, you will need to execute msbuild SplitApp.sln instead. Visual Studio and JetBrains Rider should figure it out by themselves and compile it correctly also.

Confuset commented 1 year ago

Understood.

But when doing this I receive the following result: First Split.IOS fails with this error:

C:\Users\Basti\source\repos\SplitApp\SplitApp.iOS\AppDelegate.fs(9,1): error FS0074: The type referenced through 'Fabul
ous.CollectionBuilder`3' is defined in an assembly that is not referenced. You must add a reference to assembly 'Fabulo
us'. [C:\Users\Basti\source\repos\SplitApp\SplitApp.iOS\SplitApp.iOS.fsproj]

C:\Users\Basti\source\repos\SplitApp\SplitApp.iOS\AppDelegate.fs(18,30): error FS0039: The value, namespace, type or mo
dule 'Program' is not defined. Maybe you want one of the following:↔   ProgressBar↔   Progress↔   ProgressBarRenderer [
C:\Users\Basti\source\repos\SplitApp\SplitApp.iOS\SplitApp.iOS.fsproj]

And I get this warning for SplitApp.Android:

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targ
ets(2352,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Fabulous". Check to make
 sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\User
s\Basti\source\repos\SplitApp\SplitApp.Android\SplitApp.Android.fsproj]

And then the build process seems to freeze here: grafik

Fun fact: In VS22 it does the same, the build freezes and never finishes.

Regarding the Fabulous not found I created this ticket: https://github.com/fabulous-dev/Fabulous.XamarinForms/issues/5

TimLariviere commented 1 year ago

This should be fixed in Fabulous.XamarinForms 2.1.4

Confuset commented 1 year ago

That first step is fixed. Now I have to figure out why the build never finishes.

TimLariviere commented 1 year ago

@Confuset Could you try to set the build verbosity flag to Detailed or Diagnostics? This should tell us where the build process is hanging

Confuset commented 1 year ago

Just did that: grafik That is the last output

Confuset commented 1 year ago

The taskmanager is telling me its doing something: grafik But strangly its constantly using 8% CPU. Memory does not change either.

Confuset commented 1 year ago

Any ideas how to proceed from here? I fear that I have to look into the F# compiler :(

BTW. It does react ctrl-c and cancels the build as requested, so its not fully stuck. Thats the output:

Build FAILED.

"c:\Users\Basti\source\repos\SplitApp\SplitApp.sln" (default target) (1) ->
"c:\Users\Basti\source\repos\SplitApp\SplitApp.iOS\SplitApp.iOS.fsproj" (default target) (3) ->
(ResolveAssemblyReferences target) ->
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.ta
rgets(2352,5): warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set t
he "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.c
om/fwlink/?LinkId=294190. [c:\Users\Basti\source\repos\SplitApp\SplitApp.iOS\SplitApp.iOS.fsproj]

"c:\Users\Basti\source\repos\SplitApp\SplitApp.sln" (default target) (1) ->
"c:\Users\Basti\source\repos\SplitApp\SplitApp.Android\SplitApp.Android.fsproj" (default target) (4) ->
(CoreCompile target) ->
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\Microsof
t.FSharp.Targets(325,9): warning MSB5021: Terminating the task executable "fscAnyCpu" and its child processes because t
he build was canceled. [c:\Users\Basti\source\repos\SplitApp\SplitApp.Android\SplitApp.Android.fsproj]

    2 Warning(s)
    0 Error(s)

Time Elapsed 00:01:56.45
Confuset commented 1 year ago

For some reason I believe something is broken with my xamarin setup. If I change the properties to this: grafik The build does not freeze but fail:

1>------ Build started: Project: SplitApp.Android, Configuration: Debug Any CPU ------
1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(527,3): warning XA1026: Using AAPT is deprecated in favor of AAPT2. Please enable 'Use incremental Android packaging system (aapt2)' in the Visual Studio project property pages or edit the project file in a text editor and set the 'AndroidUseAapt2' MSBuild property to 'true'.
1>C:\Users\xxx\source\repos\SplitApp\SplitApp.Android\obj\Debug\lp\96\jl\res\values\values.xml(1482,0): error APT1000: Attribute "android:translationX" has already been defined
1>C:\Users\xxx\source\repos\SplitApp\SplitApp.Android\obj\Debug\lp\96\jl\res\values\values.xml(1486,0): error APT1000: Attribute "android:translationY" has already been defined
1>C:\Users\xxx\source\repos\SplitApp\SplitApp.Android\obj\Debug\lp\96\jl\res\values\values.xml(1489,0): error APT1000: Attribute "android:translationZ" has already been defined
1>C:\Users\xxx\source\repos\SplitApp\SplitApp.Android\obj\Debug\lp\71\jl\res\values\values.xml(4,0): error APT1000: Found tag id where item is expected
1>C:\Users\xxx\source\repos\SplitApp\SplitApp.Android\obj\Debug\lp\68\jl\res\values\values.xml(4,0): error APT1000: Found tag id where item is expected
1>C:\Users\xxx\source\repos\SplitApp\SplitApp.Android\obj\Debug\lp\67\jl\res\values\values.xml(4,0): error APT1000: Found tag id where item is expected
1>Done building project "SplitApp.Android.fsproj" -- FAILED.
1>
1>Build FAILED.
TimLariviere commented 1 year ago

I never saw this issue, but a broken xamarin setup is unfortunately too common :/

Maybe after changing that property, you could try deleting the bin/obj folders of all the projects. It's often that the build breaks because of old files in bin/obj.

Confuset commented 1 year ago

Wow. It really looks like a deadlock in the compiler. I downgraded from v12.0.5 to v12.0.4 of fsc.exe and the build now finishes without a problem..

Confuset commented 1 year ago

From my point of view this can be closed. It was an error in the compiler which has already fixed in the current preview. Thank you for all the effort to help me out 👍

edgarfgp commented 1 year ago

Closing this as the issue has been resolved as per this comment https://github.com/dotnet/fsharp/issues/14651#issuecomment-1407505478