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

Support .NET 7 for Fable 3? #3294

Closed
MangelMaxime opened this issue Dec 11, 2022 · 18 comments
Closed

Support .NET 7 for Fable 3? #3294

MangelMaxime opened this issue Dec 11, 2022 · 18 comments

Comments

@MangelMaxime
Copy link
Member

Description

I see more and more people reporting issues with their dependencies not being found.

The cause of the error is that Fable 3 doesn't support .NET 7 but because the error is not obvious they can't figure it out.

Would it be possible to post the changes made for Fable 4 to Fable 3? If not is it possible to detect the error and indicate to the user to add a global.json to their project to lock to .NET 6?

Option 1 would be better if doable :)

ThisFunctionalTom added a commit to ThisFunctionalTom/Html2Feliz that referenced this issue Dec 13, 2022
Fable 3 is currently not working with .NET SDK 7 (fable-compiler/Fable#3294)

Update README to not forget `dotnet tool install`
@MangelMaxime
Copy link
Member Author

MangelMaxime commented Dec 18, 2022

Workaround:

Create a global.json with the following content:

{
    "sdk": {
        "version": "6.0.0",
        "rollForward": "latestMinor"
    }
}

This will tell dotnet to use .NET 6 for the current directory and children.

The other solution is to move to Fable 4 (in beta stage at the time of writing).

@AlbertoLeon
Copy link

Maybe another approach is update the template with this approach and also, adding the Fable 4 templates?

@AlbertoLeon
Copy link

There is a complete log after adding the global.json
image

@MangelMaxime
Copy link
Member Author

@AlbertoLeon The template has been updated to include a global.json file.

https://github.com/fable-compiler/fable-templates/blob/master/minimal/CHANGELOG.md#390---2021-12-12

Make sure you deleted all temporary artefacts like bin and obj folders. One way to do it in general is to commit your work and then run git clean -xdf to remove all the files that are not tracked

@MangelMaxime
Copy link
Member Author

MangelMaxime commented Jan 10, 2023

@alfonsogarciacaro

I think not having support of .NET 7 or an error report in Fable 3 is hurting Fable. This is because new users and even old users are hitting a wall and they don't know what is happening.

This can lead to frustration and less adoption of Fable.

Are the changes required to support .NET 7 in Fable 3 complex? Would checking dotnet --version be enough to provide an hint for a solution to the user?

@object
Copy link

object commented Jan 10, 2023

I second @MangelMaxime's proposal. This failure can be quite frustrating because the error message doesn't give a clue about possible cause of failure except that it looks like nothing works. With growing .NET 7 adoption it's quite important to enhance Fable 3 with support for it.

@ken-okabe
Copy link

ken-okabe commented Jan 13, 2023

Readme suggests

and looking at the page

image

.NET 7.0
Standard Term Support
Recommended

and
.NET 6.0 became LTS

#3028 (comment)

Fable 4 is already looking very nice.
Is there a timeframe for a ready-for-production Fable 4 release?

I also wish Fable4 become the production-ready release with the official templates soon.

@rfrerebe
Copy link
Contributor

I think this issue should be pinned above all issues until it's solved.
I think it would help.

@kspeakman
Copy link

VS 2022 requires .NET 7 for most of its workloads. So now all my existing Fable projects are broken. Why is a global.json file required to fix this? The project already has net6.0 as the SDK version in the project file. AFAIK, this is what VS uses to compile to net6.0 even tho dotnet --version reports 7.

@MangelMaxime
Copy link
Member Author

The global.json is required to force .NET to use the correct version.

This is because something changed in .NET 7 in how dependencies resolution should be done (like with every release of .NET I think...)

If you use the global.json file with the setting I provided then dotnet --version should return 6 otherwise you probably miss configured that file.

@kspeakman
Copy link

Point is: dotnet build compiles to net6.0 even with 7 installed, presumably because it uses the target SDK version from the .fsproj file. Could Fable use a similar strategy?

Simply having .NET 7 installed -- which is now a prerequisite for most VS 2022 workloads -- breaks all Fable 3 projects. It is very disconcerting when a project suddenly and inexplicably stops working. Adding a global.json is a work-around, but only after half a day of trying to figure it out, confidence destroyed.

@MangelMaxime
Copy link
Member Author

Point is: dotnet build compiles to net6.0 even with 7 installed, presumably because it uses the target SDK version from the .fsproj file. Could Fable use a similar strategy?

It could if dependencies resolution is fixed when running with .NET 7.

You can install several version of dotnet side by side, so you can have both .NET 6 and .NET 7 installed at the same time.

Simply having .NET 7 installed -- which is now a prerequisite for most VS 2022 workloads -- breaks all Fable 3 projects. It is very disconcerting when a project suddenly and inexplicably stops working. Adding a global.json is a work-around, but only after half a day of trying to figure it out, confidence destroyed.

Indeed, this bug is annoying.

In general, it is a good idea to lock your runtimes in the same way you do it for your dependancies. This help makes the code reproducible between machines and easier to spot why something is breaking.

@kspeakman
Copy link

kspeakman commented Feb 27, 2023

I do have both SDK versions installed. (Even if I didn't, later SDK versions will typically compile to older targets.) But the correct target is specified in the .fsproj file. The dotnet build tool has the -r <runtime identifier> option. But I don't have to use that to get it to compile net6.0 -- it does so by itself. So it seems possible for Fable to avoid this issue going forward, too.

update: Just adding global.json file without having NET 6 SDK installed, project won't build. Have to manually install .NET 6 SDK too. Or downgrade to VS 17.3 (17.2 is LTS) to avoid all of this. NET 7 was added in 17.4.

@PaigeM89
Copy link

PaigeM89 commented Mar 1, 2023

For what it's worth, this story gets a bit more complex on linux - or at least it was weird for me on Ubuntu.

I had the 6.0.406 and 7.0.200 dotnet SDKs installed, but even with the global.json configured to point at 6.0.406 I was having issues where Fable would hang with no output when I tried to run it.

I'm adding this anecdote for 2 reasons:

  1. It's a use case for getting Fable 3 to support dotnet 7, to avoid the headache I ran into.
  2. It may be of help to someone running into the same issues.

For anyone stumbling across this issue and having similar symptoms, I had to manually extract the dotnet 6 binaries & copy the content of shared/Microsoft.NETCore.App/6.0.14 over to /usr/share/dotnet/shared/Microsoft.NETCore.App/ before Fable would give me output. My global.json was unchanged, still pointed at 6.0.406.

@JoostVanVelthoven
Copy link

How is this issue prioritized?

@MangelMaxime
Copy link
Member Author

We don't have a blog post announcement yet, but today Fable 4 has been released with JavaScript considered stable.

The idea is that the maintainers want to avoid spending time fixing issues in Fable 3, and encourage people to move to Fable 4 in order to get the latest features ans support for .NET 7 is part of it.

@kspeakman
Copy link

This break occurs from a supposedly backward compatible tool update and the cause is hard to discover. (Google didn't find it... a kind soul on F# slack directed me here.) Is there no way to address this economically?

Asking everyone to upgrade to a newly released major version is pretty intense.

@MangelMaxime
Copy link
Member Author

I would love to have it supported in Fable 3 or at least have an explicit error message.

However, the main maintainers of Fable are focused on Fable 4 now. I tried to port the changes from Fable 4 to Fable 3 but encounter errors that I don't understand. My PR his here: #3363

I think if someone is able to make my PR work or submit another PR that works or improve the situation we could have it accepted. Contributions are always welcomed

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

8 participants