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.04k stars 734 forks source link

[F#] Cannot build F# project referencing Uno 4.0.* FS0226: The file extension of 'obj\Debug\net6.0\uno.reload.cookie.g.cs' is not recognized. #7598

Closed xperiandri closed 2 years ago

xperiandri commented 2 years ago

Current behavior

Uno generates empty uno.reload.cookie.g.cs file causing F# not to build error FS0226: The file extension of 'obj\Debug\net6.0\uno.reload.cookie.g.cs' is not recognized. Source files must have extension .fs, .fsi, .fsx, .fsscript, .ml or .mli.

Expected behavior

Uno.Core/Uno.UI/Uno.WinUI does not generate any C# file if project does not contain any XAML file

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

  1. Create F# libaray targeting net6.0
  2. Reference
    <PackageReference Include="Uno.Core" Version="4.0.*" />
    <PackageReference Include="Uno.WinUI" Version="4.0.*" />
  3. Build

Workaround

No

Works on UWP/WinUI

Yes

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

4.0.*

Affected platforms

iOS, Android, WebAssembly, macOS, Skia (WPF), Skia (GTK on Linux/macOS/Windows), Skia (Tizen)

IDE

Visual Studio 2022

IDE version

17.1 preview

Relevant plugins

No response

Anything else we need to know?

No response

xperiandri commented 2 years ago

@jeromelaban, blocking issue

jeromelaban commented 2 years ago

The file is created here: https://github.com/unoplatform/uno/blob/546441d12f12e27cd07fc75851039c7404efc2cf/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props#L423

It's likely that there's a way to determine that the currently built project is not CSharp.

xperiandri commented 2 years ago

That is strange that it is created even though it is empty

jeromelaban commented 2 years ago

It's not strange, it's used in the VS Code scenario. It's generating a .cs file, so this is why F# does not like this much.

xperiandri commented 2 years ago

So do you suggest just adding a condition that disables the target for non C# projects?

xperiandri commented 2 years ago

Thanks!

jeromelaban commented 2 years ago

@xperiandri did this fix your build issue?

xperiandri commented 2 years ago

I'll check and let you know. From the change I supposed so and didn't check yet.

xperiandri commented 2 years ago

Yes, builds. Checked with 4.1.0-dev.324