FAKE icon indicating copy to clipboard operation
FAKE copied to clipboard

hello from FAKE! Example script returns Error FS0039: The namespace or module 'Fake' is not defined

Open LawrenceSpear opened this issue 1 year ago • 2 comments

Description

Using the example hello from FAKE! script returns the module 'Fake' is not defined

Repro steps

Just follow the steps described in the FAKE documentation: https://fake.build/guide/getting-started.html

Expected behavior

Expected it to print "hello from FAKE!"

Actual behavior

Script is not valid: C:\Projects\test\build.fsx (5,5)-(5,9): Error FS0039: The namespace or module 'Fake' is not defined. C:\Projects\test\build.fsx (8,0)-(8,6): Error FS0039: The value, namespace, type or module 'Target' is not defined. C:\Projects\test\build.fsx (13,0)-(13,6): Error FS0039: The value, namespace, type or module 'Target' is not defined.

Related information

dotnet --info .NET SDK: Version: 8.0.400 Commit: 36fe6dda56 Workload version: 8.0.400-manifests.251308be MSBuild version: 17.11.3+0c8610977

Runtime Environment: OS Name: Windows OS Version: 10.0.22631 OS Platform: Windows RID: win-x64 Base Path: c:\program files\dotnet\sdk\8.0.400\

.NET workloads installed: Configured to use loose manifests when installing new manifests. [aspire] Installation Source: VS 17.11.35312.102 Manifest Version: 8.1.0/8.0.100 Manifest Path: c:\program files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.1.0\WorkloadManifest.json Install Type: FileBased

Host: Version: 8.0.8 Architecture: x64 Commit: 08338fcaa5

.NET SDKs installed: 3.1.426 [c:\program files\dotnet\sdk] 5.0.104 [c:\program files\dotnet\sdk] 6.0.425 [c:\program files\dotnet\sdk] 8.0.400 [c:\program files\dotnet\sdk]

fake --version FAKE 6 - F# Make (6.1.2.0) (running on .NETCoreApp,Version=v6.0) (this line is written to standard error, see https://github.com/fsharp/FAKE/issues/2066) FakePath: C:\Users*****.dotnet\tools.store\fake-cli\6.1.2\fake-cli\6.1.2\tools\net6.0\any\Fake.Runtime.dll Paket.Core: 8.1.0

I've tried setting the FAKE_SDK_RESOLVER_CUSTOM_DOTNET_VERSION to 6.0 and 8.0 with the same results

LawrenceSpear avatar Sep 25 '24 21:09 LawrenceSpear

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

github-actions[bot] avatar Sep 25 '24 21:09 github-actions[bot]

I think you're trying to use the fake dotnet tool, which honestly I didn't have much luck with (i'm a newbie to FAKE, so I might be missing something obvious).

Instead, I started running my build.fsx file using the following command: dotnet fsi build.fsx -t Hello

My build.fsx has the following contents:

#r "nuget: Fake.Core.Target"
open Fake.Core 

let fsiArguments = 
    System.Environment.GetCommandLineArgs()
    |> Array.skip 2
    |> Array.toList

Context.FakeExecutionContext.Create false __SOURCE_FILE__ fsiArguments
|> Context.RuntimeContext.Fake
|> Context.setExecutionContext


Target.create "Hello" (fun _ -> 
    Trace.log "--- Hello from Fake! --- "
)

Target.runOrDefault "Hello"

Compared to the first example on the website, this feels clearer to me:

  • It doesn't generate a .fake folder in my project directory full of packet and other intimidating files.
  • The only requirement seems to be having dotnet sdk installed.

I know this question was from awhile ago so I'm sure you've resolved it by now, but maybe for newer devs this might help.

I'd also love to know if there is any huge downside to running Fake this way?

nicholas-peterson avatar Nov 13 '24 18:11 nicholas-peterson