FAKE
FAKE copied to clipboard
Error FS0039: The namespace or module 'Fake' is not defined.
Description
Invoking the latest fake 5.21.0-alpha001 gives the following error:
Error FS0039: The namespace or module 'Fake' is not defined.
Worked fine with the previous version (which doesn't support .NET6)
Repro steps
The head of my build.fsx file looks like this
#r "paket: groupref Build //"
#load ".fake/build.fsx/intellisense.fsx"
open System.IO
open Fake.Core
open Fake.IO
open Fake.DotNet
open Fake.IO.Globbing.Operators
open Fake.IO.FileSystemOperators
open Fake.Core.TargetOperators
Expected behavior
Fake runs and executes correctly
Actual behavior
F# compilation errors are produced, as above
Known workarounds
Please provide a description of any known workarounds.
Related information
- OSX
- latest
- .NET6 6.0.100
- Fatal
- Version of FAKE 5.21.0-alpha001
Welcome to the FAKE community! Thank you so much for creating your first issue and therefore improving the project!
@zelenij Ran into the same problem and resolved it by switching the framework for the Build
group to "net6.0" (was "netstandard2.0" before. Tested with 5.21.0-alpha003
.
paket.dependencies
version 6.2.1
group Build
source https://api.nuget.org/v3/index.json
framework: net6.0
storage: none
nuget Fake.Api.GitHub
nuget Fake.BuildServer.TeamFoundation
nuget Fake.Core.Environment
nuget Fake.Core.Process
nuget Fake.Core.ReleaseNotes
nuget Fake.Core.Target
nuget Fake.Core.Xml
nuget Fake.DotNet.AssemblyInfoFile
nuget Fake.DotNet.Cli
nuget Fake.DotNet.MSBuild
nuget Fake.Dotnet.NuGet
nuget Fake.DotNet.Paket
nuget Fake.DotNet.Testing.XUnit2
nuget Fake.IO.FileSystem
nuget Fake.IO.Zip
build.fsx
#r "paket: groupref Build //"
#load ".fake/build.fsx/intellisense.fsx"
open System.IO
open Fake.Core
open Fake.IO
open Fake.DotNet
open Fake.IO.Globbing.Operators
open Fake.IO.FileSystemOperators
open Fake.Core.TargetOperators
printfn "Hello World"
Output with "netstandard2.0"
Updating group Build in X:\action-bi-toolkit\pbi-tools\fake-debug\paket.dependencies
Resolving dependency graph for group Build...
Resolving dependency graph...
Starting full restore process.
Script is not valid:
X:\action-bi-toolkit\pbi-tools\fake-debug\build.fsx (5,5)-(5,9): Error FS0039: The namespace or module 'Fake' is not defined.
X:\action-bi-toolkit\pbi-tools\fake-debug\build.fsx (6,5)-(6,9): Error FS0039: The namespace or module 'Fake' is not defined.
X:\action-bi-toolkit\pbi-tools\fake-debug\build.fsx (7,5)-(7,9): Error FS0039: The namespace or module 'Fake' is not defined.
X:\action-bi-toolkit\pbi-tools\fake-debug\build.fsx (8,5)-(8,9): Error FS0039: The namespace or module 'Fake' is not defined.
X:\action-bi-toolkit\pbi-tools\fake-debug\build.fsx (9,5)-(9,9): Error FS0039: The namespace or module 'Fake' is not defined.
X:\action-bi-toolkit\pbi-tools\fake-debug\build.fsx (10,5)-(10,9): Error FS0039: The namespace or module 'Fake' is not defined.
Hint: If you have updated your dependencies you might need to run 'paket install' or delete 'X:\action-bi-toolkit\pbi-tools\fake-debug\build.fsx.lock' for
fake to pick them up.
Hint: If this doesn't help but you are sure this should work try to clean your nuget cache and delete the .fake directory. If this helps please report this problem to Paket.
Output with "net6.0"
Updating group Build in X:\action-bi-toolkit\pbi-tools\fake-debug\paket.dependencies
Resolving dependency graph for group Build...
Resolving dependency graph...
Starting full restore process.
Hello World
Thanks, I already figured the problem out. I was updating just fake-cli, while I needed to update the fake nuget packages as well. I think your approach forces the update, but I did it like that, also worked:
nuget FSharp.Core prerelease
nuget Fake.Core.ReleaseNotes prerelease
nuget Fake.Core.Target prerelease
nuget Fake.DotNet.Cli prerelease
nuget Fake.IO.FileSystem prerelease
Neither of your solutions or a combination thereof worked for me. All I got was a different error instead.
Script is not valid:
unknown (1,0)-(1,0): Error FS0193: The module/namespace 'System' from compilation unit 'netstandard' did not contain the namespace, module or type 'IAsyncDisposable'
At this point I'm considering ditching Fake completely.
I don't have a stake in fake, and I also don't know how to help you. Your problem seem to be slightly different. Maybe try raising a new issue with full description, including your fake script?
One thing I forgot to mention - I also upgraded my paket to the latest beta version. And try deleting the .fake directory before trying again. See if this helps...
@kerams IAsyncDisposable
is only available in .Net Standard 2.1 (see https://docs.microsoft.com/en-us/dotnet/api/system.iasyncdisposable). Could your issue be that you're (explicitly or implicitly) relying on 2.0? That would explain the error message. Work switching the framework explicitly to net6.0
as I have done in my example above?
None, net6.0, netstandard2.1 result in the error above. netstandard2.0 results in the OP error.
Async and task computation expressions are causing this.
As @zelenij suggested, would create a new issue for this. I'm also not a Fake maintainer, just an active user. Came here to share how I resolved the OP issue, but yours seems to be something different.
Is there any news or solutions? I didn't find a new issue with that but I've got exactly the same error right now. A few month ago this script works fine but now doesn't.
Script is not valid: 10:19:31 unknown (1,0)-(1,0): Error FS0193: The module/namespace 'System' from compilation unit 'netstandard' did not contain the namespace, module or type 'IAsyncDisposable'
I remember getting the same error out of nowhere. I can't guarantee this will work, but it seems to, for me. First, upgrade every project you might have, that uses netstandard2.0 to 2.1. Second, use net6.0 (or 5.0) in Fake's paket section:
group Build
source https://api.nuget.org/v3/index.json
framework: net6.0
storage: none
nuget FSharp.Core
nuget Fake.Core.ReleaseNotes
nuget Fake.Core.Target
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem
https://github.com/fsprojects/FAKE/issues/2641#issuecomment-1027815211 worked for me
@zelenij Thanks, the following worked for me too:
use net6.0 (or 5.0) in Fake's paket section
group Build
source https://api.nuget.org/v3/index.json
framework: net6.0
I remember getting the same error out of nowhere. I can't guarantee this will work, but it seems to, for me. First, upgrade every project you might have, that uses netstandard2.0 to 2.1. Second, use net6.0 (or 5.0) in Fake's paket section:
group Build source https://api.nuget.org/v3/index.json framework: net6.0 storage: none nuget FSharp.Core nuget Fake.Core.ReleaseNotes nuget Fake.Core.Target nuget Fake.DotNet.Cli nuget Fake.IO.FileSystem
It worked, update the packet, delete the lock file, run the command again to install. Thanks.
#r "paket:
source https://api.nuget.org/v3/index.json
framework: net6.0
nuget FSharp.Core 6.0.3
...