Open oleksandrmeister opened 2 years ago
I only see this error on Windows. I think it's a problem with the Windows target of MAUI where F# is not allowed...
If you don't plan on targeting Windows, I would recommend you remove the net6.0-windows
target in the fsproj file
Still reproducible (100%) with VS 17.3.0 on Windows.
I think it's a problem with the Windows target of MAUI where F# is not allowed...
I agree; it indeed seems to be a problem within MAUI itself. So I think we should file a bug report in the MAUI repo if it hasn't already been done yet. Is there a respective ticket in the MAUI repo yet? If not, I can file one.
Edit: I have created a MAUI ticket
Not 100 percent ideal but I have a workaround here that we could put into the templates for now. Basically it just adds a referenced project that's C# so that WinUI can generate its code inside there and then the head project can just use that. I asked the WinUI team if there's a better way to go about doing this but for now this seems to work alright.
@PureWeen How would you use fabulous with the mauihead project you've linked? I'm rather new and I'm interested in trying to build a small crud app with this, but I'm more interested in doing it MVU vs MVVM, so I'm not entirely sure how to bridge the gap? Or is it not entirely possible yet?
@WillEhrendreich You should be able to do a full MVU MAUI app using Fabulous.MauiControls (templates here)
I believe the head project shared by @PureWeen is literally just a drop-in to the F# MAUI template that can be found in this repository or in Fabulous.MauiControls.Templates. The current F# template can't compile for net7.0-windows
because of toolchain issue, but if you add a C# windows project that reference the F# lib, it will work.
hey @TimLariviere , thanks for responding!
I'm hoping you can give an example..
I have no idea how to make this work.. I've been trying all day to do what you're saying.. I don't know what I'm missing. @PureWeen 's template is an fsharp and csharp project on maui that interact with each other, but I have no idea how to integrate it with Fabulous.
What do I replace with what.. and where?
@WillEhrendreich I didn't had time to prepare you a full sample, but I understand better how to make it work.
Those steps should lead you to a working WinUI project:
fabulous-mauicontrols
templateYourApp.WinUI
)net7.0-windows.10-xxx
(xxx is your WinSDK version, check the MAUI project file)App.xaml
and App.xaml.cs
(from MauiLib1\Platforms\Windows\
) of @PureWeen's zip fileYourApp.WinUI
YourApp.WinUI.csproj
and add <DefineConstants>DISABLE_XAML_GENERATED_MAIN;$(DefineConstants)</DefineConstants>
under the first <PropertyGroup>
tagMauiApp56
and MauiLib1
) to match yours.YourApp.fsproj
<ItemGroup Condition=" ... == 'windows' ">
, remove both App.xaml
and App.xaml.fs
<Compile Include="$(WindowsProjectFolder)App.fs" />
YourApp\Platforms\Windows\App.fs
and add the following content:namespace YourApp.WinUI
open Microsoft.UI.Xaml
open Microsoft.Maui
open Microsoft.Maui.Controls.Xaml
open YourApp
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
type App() =
inherit YourApp.WinUI.App()
override this.CreateMauiApp() = MauiProgram.CreateMauiApp()
This should let you build for WinUI
@WillEhrendreich I created this library to take care of most of the steps above: https://github.com/fsharp-mobile/FSharp.Maui.WinUICompat
The idea is to remove the App.xaml
and App.xaml.fs
files from Platforms\Windows
in the MAUI project, add this package and create a new file call App.fs
in Platforms\Windows
with this:
type App() =
inherit FSharp.Maui.WinUICompat.App()
override this.CreateMauiApp() = YourApp.MauiProgram.CreateMauiApp()
module Main =
[<EntryPoint; STAThread>]
let main args =
FSharp.Maui.WinUICompat.Program.Main(args, typeof<App>)
This will let the app compile and run.
But when trying it, it was crashing at runtime because Microsoft.ui.xaml.dll
was not found.
Following a comment about this issue on GitHub, I installed the C++ redistribuable.
... and now I can't even compile because the NuGet package winappsdk
tries to include a C# file into the F# project ¯\(ツ)/¯
Yeah, I've been chasing this down all yesterday. I got exactly as far as that, the exact library was "missing". I was going to try to comment back with how far I got, but I guess you got the same result. Haha.
https://github.com/microsoft/WindowsAppSDK/issues/1762 <- here is the issue i was trying to reference to help resolve things but have as of yet been unsuccessful.
I have new templates installed but after creating the new maui-fsharp application and running build command I have the following error:
PS C:\temp\maui\TestApp> dotnet build -c Release MSBuild version 17.3.0-preview-22329-01+77c72dd0f for .NET Determining projects to restore... All projects are up-to-date for restore. You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview TestApp -> C:\temp\maui\TestApp\bin\Release\net6.0-maccatalyst\maccatalyst-x64\TestApp.dll TestApp -> C:\temp\maui\TestApp\bin\Release\net6.0-ios\iossimulator-x64\TestApp.dll EXEC : Xaml Internal error : Specified argument was out of the range of valid values. [C:\temp\maui\TestApp\TestApp.fsp roj] Parameter name: The language 'F#' is not supported