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

Error FS0039: The namespace or module 'Fake' is not defined. #2619

Open
zelenij opened this issue Nov 10, 2021 · 14 comments
Open

Error FS0039: The namespace or module 'Fake' is not defined. #2619

zelenij opened this issue Nov 10, 2021 · 14 comments

Comments

@zelenij
Copy link

zelenij commented Nov 10, 2021

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
@github-actions
Copy link

Welcome to the FAKE community! Thank you so much for creating your first issue and therefore improving the project!

@mthierba
Copy link

@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

@zelenij
Copy link
Author

zelenij commented Dec 21, 2021

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

@kerams
Copy link
Contributor

kerams commented Dec 22, 2021

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.

@zelenij
Copy link
Author

zelenij commented Dec 22, 2021

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...

@mthierba
Copy link

@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?

@kerams
Copy link
Contributor

kerams commented Dec 22, 2021

None, net6.0, netstandard2.1 result in the error above. netstandard2.0 results in the OP error.

@kerams
Copy link
Contributor

kerams commented Dec 23, 2021

Async and task computation expressions are causing this.

@mthierba
Copy link

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.

@mav10
Copy link

mav10 commented Feb 1, 2022

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'

@zelenij
Copy link
Author

zelenij commented Feb 1, 2022

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

@queil
Copy link
Contributor

queil commented Feb 8, 2022

#2641 (comment) worked for me

@dsyme
Copy link
Collaborator

dsyme commented Mar 19, 2022

@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

@mocxi
Copy link

mocxi commented May 6, 2022

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
...

knocte added a commit to knocte/FSharpLint that referenced this issue Dec 25, 2023
knocte added a commit to knocte/FSharpLint that referenced this issue Dec 25, 2023
Update Paket restrictions by editing paket.dependencies
changing frameworks to net6.0.

And two additional things:
1) change netstandard2.0 to net6.0 as a workaround[2] to
a FAKE bug[1].
2) use 'strategy: min' to avoid dependencies be upgraded
to versions that require net8.0 (e.g. Microsoft.Build.Framework 15.1.0.0
depending on FSharp.Core 8.0.0.0).

[1] fsprojects/FAKE#2619
[2] fsprojects/FAKE#2619 (comment)
knocte added a commit to knocte/FSharpLint that referenced this issue Dec 26, 2023
Update Paket restrictions by editing paket.dependencies
changing frameworks to net6.0.

And two additional things:
1) change netstandard2.0 to net6.0 as a workaround[2] to
a FAKE bug[1].
2) use 'strategy: min' to avoid dependencies be upgraded
to versions that require net8.0 (e.g. Microsoft.Build.Framework 15.1.0.0
depending on FSharp.Core 8.0.0.0).

[1] fsprojects/FAKE#2619
[2] fsprojects/FAKE#2619 (comment)
knocte added a commit to knocte/FSharpLint that referenced this issue Dec 28, 2023
Update Paket restrictions by editing paket.dependencies
changing frameworks to net6.0.

And two additional things:
1) change netstandard2.0 to net6.0 as a workaround[2] to
a FAKE bug[1].
2) use 'strategy: min' to avoid dependencies be upgraded
to versions that require net8.0 (e.g. Microsoft.Build.Framework 15.1.0.0
depending on FSharp.Core 8.0.0.0).

[1] fsprojects/FAKE#2619
[2] fsprojects/FAKE#2619 (comment)
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

7 participants