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

Parameter name: The language 'F#' is not supported #21

Open
oleksandrmeister opened this issue Jul 21, 2022 · 11 comments
Open

Parameter name: The language 'F#' is not supported #21

oleksandrmeister opened this issue Jul 21, 2022 · 11 comments

Comments

@oleksandrmeister
Copy link

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

@TimLariviere
Copy link
Member

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

@ChristophSchmidpeter
Copy link

Still reproducible (100%) with VS 17.3.0 on Windows.

@ChristophSchmidpeter
Copy link

ChristophSchmidpeter commented Aug 12, 2022

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

@PureWeen
Copy link

mauihead.zip

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.

@WillEhrendreich
Copy link

@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?

@TimLariviere
Copy link
Member

@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.

@WillEhrendreich
Copy link

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?

@TimLariviere
Copy link
Member

TimLariviere commented Nov 15, 2022

@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:

  • Create your project using the fabulous-mauicontrols template
  • Add a C# library to the solution (eg. YourApp.WinUI)
  • Change the C# target to net7.0-windows.10-xxx (xxx is your WinSDK version, check the MAUI project file)
  • Copy App.xaml and App.xaml.cs (from MauiLib1\Platforms\Windows\) of @PureWeen's zip file
  • Paste them directly inside YourApp.WinUI
  • Edit YourApp.WinUI.csproj and add <DefineConstants>DISABLE_XAML_GENERATED_MAIN;$(DefineConstants)</DefineConstants> under the first <PropertyGroup> tag
  • Change the namespace's name of those files (search for both strings MauiApp56 and MauiLib1) to match yours.
  • Edit the file YourApp.fsproj
  • Under <ItemGroup Condition=" ... == 'windows' ">, remove both App.xaml and App.xaml.fs
  • Add a new tag <Compile Include="$(WindowsProjectFolder)App.fs" />
  • Create the file 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

@TimLariviere
Copy link
Member

TimLariviere commented Nov 16, 2022

@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 ¯\(ツ)

@WillEhrendreich
Copy link

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.

@WillEhrendreich
Copy link

microsoft/WindowsAppSDK#1762 <- here is the issue i was trying to reference to help resolve things but have as of yet been unsuccessful.

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

5 participants