Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fix for "Package manager key paket was not registered" in build.fsx

When I open a Fake build script in Visual Studio Code, like this:

> dotnet new -i fake-template
> dotnet new fake
> dotnet tool update fake-cli
> code build.fsx

I see this error message in the editor and none of the Fake namespaces, modules, or types are defined:

Package manager key 'paket' was not registered in
c:\Users\wallace.kelly\.vscode\extensions\ionide.ionide-fsharp-5.4.0\bin\
Currently registered: nuget

How do I correct this error?

Running dotnet fake build works fine. The error just appears in the editor.

I have "FSharp.dotNetRoot": "C:\\Program Files\\dotnet\\sdk", in my Settings file. That folder includes folders 2.1.701 2.2.401 3.1.407 5.0.103 and 5.0.104.

like image 422
Wallace Kelly Avatar asked Mar 16 '21 23:03

Wallace Kelly


2 Answers

maintainer of Ionide for VS Code here. That's error's just going to happen from here on out. FAKE is behind in its versions of the FSharp.Compiler.Services, and without updates to that component the integration we have with FAKE has atrophied to the point where the editor shows errors in that script.

There are a few solutions:

  • continue to use FAKE and just deal with editor issues
  • stop using FAKE as the script runner, but continue to use FAKE libraries from a build project or 'standard' fsx script
  • use another build system of some kind
  • contribute updates to FAKE (and by extension the deprecated code in Ionide)

etc etc.

like image 54
Chester Husk Avatar answered Nov 10 '22 23:11

Chester Husk


I just got rid of the warning by using a ifdef.

#if FAKE
#r "paket:
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem
nuget Fake.Core.Target //"
#endif
#load ".fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators

Target.initEnvironment ()

Target.create "Clean" (fun _ ->
    !! "src/**/bin"
    ++ "src/**/obj"
    |> Shell.cleanDirs 
)

Target.create "Build" (fun _ ->
    !! "src/**/*.*proj"
    |> Seq.iter (DotNet.build id)
)

Target.create "All" ignore

"Clean"
  ==> "Build"
  ==> "All"

Target.runOrDefault "All"
like image 29
Luiz Felipe Avatar answered Nov 11 '22 00:11

Luiz Felipe