SAFE-Stack / SAFE-template

dotnet CLI template for SAFE project
MIT License
280 stars 87 forks source link

Having trouble running the new template #533

Closed hede closed 1 year ago

hede commented 1 year ago

Hello, I just installed the 4.1.0 template. dotnet run does not work out of the box.

The client fails with a bunch of "namespace or module not defined" errors:

.\Index.fs(3,6): (3,12) error FSHARP: The namespace or module 'Elmish' is not defined. (code 39)
.\Index.fs(4,6): (4,11) error FSHARP: The namespace or module 'Fable' is not defined. (code 39)
...

The server seems to run. It stands a web server up at localhost:5000, but when I go there it's 404 (last 4 lines of the log).

Please let me know if there is something else you want me to try or to see the output of.

full log:

D:\src\SafeTest>dotnet new SAFE
The template "SAFE-Stack Web App v4.1.0" was created successfully.

D:\src\SafeTest>dotnet tool restore
Tool 'paket' (version '7.0.2') was restored. Available commands: paket
Tool 'fable' (version '3.7.5') was restored. Available commands: fable
Tool 'fantomas-tool' (version '4.7.1') was restored. Available commands: fantomas
Tool 'femto' (version '0.12.0') was restored. Available commands: femto

Restore was successful.

D:\src\SafeTest>dotnet run
run Run
Building project with version: LocalBuild
Shortened DependencyGraph for Target Run:
<== Run
   <== InstallClient
      <== Clean

The running order is:
Group - 1
  - Clean
Group - 2
  - InstallClient
Group - 3
  - Run
Starting target 'Clean'
D:\src\SafeTest\src\Client> "dotnet" fable clean --yes (In: false, Out: false, Err: false)
Fable: F# to JS compiler 3.7.5
Stop Russian aggression against Ukraine!

This will recursively delete all *.fs.js[.map] files in D:\src\SafeTest\src\Client
No files have been deleted. If Fable output is in another directory, pass it as argument.
Finished (Success) 'Clean' in 00:00:00.7408609
Starting target 'InstallClient'
.> "C:\Program Files\nodejs\npm.CMD" install (In: false, Out: false, Err: false)
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid@3.2.1: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.

added 429 packages, and audited 430 packages in 6s

56 packages are looking for funding
  run `npm fund` for details

3 moderate severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
Finished (Success) 'InstallClient' in 00:00:07.6716344
Starting target 'Run'
D:\src\SafeTest\src\Shared> "dotnet" build (In: false, Out: false, Err: false)
MSBuild version 17.4.0-preview-22428-01+14c24b2d3 for .NET
  Determining projects to restore...
  Paket version 7.0.2+a704d681f4688c094e60d2b0795913896f145865
  Restoring D:\src\SafeTest\src\Shared\Shared.fsproj
  Starting restore process.
  Total time taken: 0 milliseconds
  Restored D:\src\SafeTest\src\Shared\Shared.fsproj (in 46 ms).
C:\Program Files\dotnet\sdk\7.0.100-rc.1.22431.12\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Runtim
eIdentifierInference.targets(219,5): message NETSDK1057: You are using a preview version of .NET. See
: https://aka.ms/dotnet-support-policy [D:\src\SafeTest\src\Shared\Shared.fsproj]
  Paket version 7.0.2+a704d681f4688c094e60d2b0795913896f145865
  Restoring D:\src\SafeTest\src\Shared\Shared.fsproj
  Starting restore process.
  Total time taken: 0 milliseconds
  Shared -> D:\src\SafeTest\src\Shared\bin\Debug\net6.0\Shared.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:05.80
server: D:\src\SafeTest\src\Server> dotnet watch run
client: D:\src\SafeTest\src\Client> dotnet fable watch -o output -s --run npm run start
D:\src\SafeTest\src\Server> "dotnet" watch run (In: false, Out: true, Err: true)
D:\src\SafeTest\src\Client> "dotnet" fable watch -o output -s --run npm run start (In: false, Out: true, Err: true)
client: Fable: F# to JS compiler 3.7.5
client: Stop Russian aggression against Ukraine!
client: Parsing Client.fsproj...
client: .> cmd /C dotnet restore Client.fsproj
client:   Determining projects to restore...
client:   Paket version 7.0.2+a704d681f4688c094e60d2b0795913896f145865
client:   Restoring D:\src\SafeTest\src\Shared\Shared.fsproj
client:   Starting restore process.
client:   Total time taken: 0 milliseconds
client:   Restored D:\src\SafeTest\src\Client\Client.fsproj (in 96 ms).
client:   1 of 2 projects are up-to-date for restore.
server: dotnet watch 🚀 Started
client: Project and references (3 source files) parsed in 3067ms
client: Started Fable compilation...
client: Fable compilation finished in 2046ms
client: .\Index.fs(3,6): (3,12) error FSHARP: The namespace or module 'Elmish' is not defined. (code 39)
client: .\Index.fs(4,6): (4,11) error FSHARP: The namespace or module 'Fable' is not defined. (code 39)
client: .\Index.fs(16,5): (16,13) error FSHARP: The value, namespace, type or module 'Remoting' is not defined. (code 39)
client: .\Index.fs(17,8): (17,16) error FSHARP: The value, namespace, type or module 'Remoting' is not defined. (code 39)
client: .\Index.fs(18,8): (18,16) error FSHARP: The value, namespace, type or module 'Remoting' is not defined. (code 39)
client: .\Index.fs(20,23): (20,26) error FSHARP: The type 'Cmd' is not defined. (code 39)
client: .\Index.fs(23,15): (23,18) error FSHARP: The value, namespace, type or module 'Cmd' is not defined. (code 39)
client: .\Index.fs(27,48): (27,51) error FSHARP: The type 'Cmd' is not defined. (code 39)
client: .\Index.fs(29,55): (29,58) error FSHARP: The value, namespace, type or module 'Cmd' is not defined. (code 39)
client: .\Index.fs(30,55): (30,58) error FSHARP: The value, namespace, type or module 'Cmd' is not defined. (code 39)
client: .\Index.fs(34,19): (34,22) error FSHARP: The value, namespace, type or module 'Cmd' is not defined. (code 39)
client: .\Index.fs(37,72): (37,75) error FSHARP: The value, namespace, type or module 'Cmd' is not defined. (code 39)
client: .\Index.fs(39,6): (39,11) error FSHARP: The namespace or module 'Feliz' is not defined. (code 39)
client: .\Index.fs(40,6): (40,11) error FSHARP: The namespace or module 'Feliz' is not defined. (code 39)
client: .\Index.fs(43,5): (43,10) error FSHARP: The value, namespace, type or module 'Bulma' is not defined. (code 39)
client: .\Index.fs(57,5): (57,10) error FSHARP: The value, namespace, type or module 'Bulma' is not defined. (code 39)
client: .\Index.fs(90,5): (90,10) error FSHARP: The value, namespace, type or module 'Bulma' is not defined. (code 39)
client: .\App.fs(3,6): (3,12) error FSHARP: The namespace or module 'Elmish' is not defined. (code 39)
client: .\App.fs(4,6): (4,12) error FSHARP: The namespace or module 'Elmish' is not defined. (code 39)
client: .\App.fs(7,6): (7,12) error FSHARP: The namespace or module 'Elmish' is not defined. (code 39)
client: .\App.fs(8,6): (8,12) error FSHARP: The namespace or module 'Elmish' is not defined. (code 39)
client: .\App.fs(11,1): (11,8) error FSHARP: The value, namespace, type or module 'Program' is not defined. (code 39)
client: .\App.fs(13,4): (13,11) error FSHARP: The value, namespace, type or module 'Program' is not defined. (code 39)
client: Watching ..
client: .\App.fs(15,4): (15,11) error FSHARP: The value, namespace, type or module 'Program' is not defined. (code 39)
client: .\App.fs(17,4): (17,11) error FSHARP: The value, namespace, type or module 'Program' is not defined. (code 39)
client: .\App.fs(19,4): (19,11) error FSHARP: The value, namespace, type or module 'Program' is not defined. (code 39)
server: info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[63]
server:       User profile is available. Using 'C:\Users\ref\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
server: info: Microsoft.Hosting.Lifetime[14]
server:       Now listening on: http://localhost:5000
server: info: Microsoft.Hosting.Lifetime[0]
server:       Application started. Press Ctrl+C to shut down.
server: info: Microsoft.Hosting.Lifetime[0]
server:       Hosting environment: Development
server: info: Microsoft.Hosting.Lifetime[0]
server:       Content root path: D:\src\SafeTest\src\Server
server: info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
server:       Request starting HTTP/1.1 GET http://localhost:5000/ - -
server: info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
server:       Request finished HTTP/1.1 GET http://localhost:5000/ - - - 404 0 - 200.8099ms
theimowski commented 1 year ago

Hi, First thing I spotted was usage of a preview version of .net 7:

C:\Program Files\dotnet\sdk\7.0.100-rc.1.22431.12

Do you have 6.0 installed as well? global.json should actually yell when found a version mismatch

Also, can you see if dotnet run -- Bundle works for you?

hede commented 1 year ago

Hello, Thank you for pointing that out. .net 7 preview was the problem apparently.

I had v.6.0.401 installed as well, and having checked the global.json, I just assumed it would be using .net 6. Needless to say, it wasn't actually using .net 6 😳 (I guess I shouldn't have assumed so self-convincingly!)

Changing the sdk version from 6.0 to 6.0.0 in global.json makes it actually pick and use .net 6.

I'll send a PR.

P.S. dotnet run -- Bundle doesn't work either (when using .net 7 preview) and of course works fine with .net 6