fsprojects / Paket

A dependency manager for .NET with support for NuGet packages and Git repositories.

Home Page:https://fsprojects.github.io/Paket/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default dependencies refer to net5.0 framework

Recktenwald opened this issue · comments

Description

Initializing a new F# project and using paket breaks the project.

Repro steps

Make sure that .net6 or .net7 are installed.

  1. create a new project with dotnet new console -lang F#
  2. install paket
  3. add any dependency, e.g. dotnet paket add FSharp.Core
  4. dotnet run

Expected behavior

We see the Hello from F#! output

Actual behavior

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'FSharp.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'FSharp.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Known workarounds

Make sure that the .fsproj and paket.dependencies files agree on the framework.
For example use framework: auto-detect in the paket.dependencies file.

I would suggest changing the default template that is crated with paket init to auto-detect. This seems to me to be the easiest, and most beginner-friendly way.

I located, what I think, are the relevant lines of code. In the Environment.fs file at the very bottom

let init (directory : DirectoryInfo) =
        let sources = [PackageSources.DefaultNuGetV3Source]
        let additionalLines = [
            "storage: none"
            "framework: net5.0, netstandard2.0, netstandard2.1"
        ]
        initWithContent sources additionalLines directory

But maybe there is a good reason, which I don't know, for not using auto-detect as the default.

I guess this can be closed with the latest version?