ionide / Fornax

Scriptable static site generator using type safe F# DSL to define page templates.
MIT License
241 stars 44 forks source link

fornax watch throws InvalidOperationException #94

Closed bytesource closed 3 years ago

bytesource commented 3 years ago

Describe the bug Running fornax watch on a fresh installation resulted in the following error:

$ fornax watch
[17:58:09] 'D:\Documents\Programming\Fsharp\Fornax\_public\index.html' generated in 406ms
[17:58:09] 'D:\Documents\Programming\Fsharp\Fornax\_public\about.html' generated in 259ms
[17:58:09] 'D:\Documents\Programming\Fsharp\Fornax\_public\contact.html' generated in 241ms
[17:58:10] 'D:\Documents\Programming\Fsharp\Fornax\_public\images/avatar.jpg' generated in 37ms
[17:58:10] 'D:\Documents\Programming\Fsharp\Fornax\_public\images/bulma.png' generated in 34ms
[17:58:10] 'D:\Documents\Programming\Fsharp\Fornax\_public\images/favicon.png' generated in 38ms
[17:58:10] 'D:\Documents\Programming\Fsharp\Fornax\_public\js/sampleJsFile.js' generated in 38ms
[17:58:10] 'D:\Documents\Programming\Fsharp\Fornax\_public\posts/post.html' generated in 239ms
[17:58:10] 'D:\Documents\Programming\Fsharp\Fornax\_public\posts/post2.html' generated in 253ms
[17:58:10] 'D:\Documents\Programming\Fsharp\Fornax\_public\style/style.css' generated in 41ms
[17:58:10] Watch mode started. Press any key to exit.
Unhandled exception. System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.
   at System.ConsolePal.ReadKey(Boolean intercept)
   at System.Console.ReadKey()
   at Fornax.main$cont@123(ArgumentParser`1 parser, FSharpList`1 results, Unit unitVar) in D:\Programowanie\Projekty\Ionide\Fornax\src\Fornax\Fornax.fs:line 194
   at Fornax.main(String[] argv) in D:\Programowanie\Projekty\Ionide\Fornax\src\Fornax\Fornax.fs:line 118

To Reproduce Steps to reproduce the behaviour:

  1. fornax new
  2. fornax watch

Expected behaviour Watch mode runs without throwing an exception

Environment (please complete the following information):

I probably did something wrong, but I cannot figure out what. Any suggestions are highly welcome!

Cheers,

Stefan

bytesource commented 3 years ago

Update:

I forgot to mention I was running fornax watch in Git Bash, a terminal that is installed alongside Git on Windows.

After that, I tried the terminal in VS Code, and this time everything worked fine:

$ fornax watch
[19:38:59] 'D:\Documents\Programming\Fsharp\Fornax\_public\index.html' generated in 438ms
[19:38:59] 'D:\Documents\Programming\Fsharp\Fornax\_public\about.html' generated in 278ms
[19:38:59] 'D:\Documents\Programming\Fsharp\Fornax\_public\contact.html' generated in 260ms
[19:38:59] 'D:\Documents\Programming\Fsharp\Fornax\_public\images/avatar.jpg' generated in 67ms
[19:38:59] 'D:\Documents\Programming\Fsharp\Fornax\_public\images/bulma.png' generated in 62ms
[19:39:00] 'D:\Documents\Programming\Fsharp\Fornax\_public\images/favicon.png' generated in 66ms
[19:39:00] 'D:\Documents\Programming\Fsharp\Fornax\_public\js/sampleJsFile.js' generated in 65ms
[19:39:00] 'D:\Documents\Programming\Fsharp\Fornax\_public\posts/post.html' generated in 282ms
[19:39:00] 'D:\Documents\Programming\Fsharp\Fornax\_public\posts/post2.html' generated in 286ms
[19:39:00] 'D:\Documents\Programming\Fsharp\Fornax\_public\style/style.css' generated in 59ms
[19:39:00] Watch mode started. Press any key to exit.
[19:39:00 INF] Smooth! Suave listener started in 46.478ms with binding 127.0.0.1:8080

Feel free to close the issue. However, if you have an idea of why fornax watch threw an exception in Git Bash I'd be curious to know.

Cheers,

Stefan

rdipardo commented 3 years ago

Here's the answer: https://github.com/MicrosoftDocs/azure-docs/issues/30917#issuecomment-492173859

$ winpty dotnet fake build -t TestTemplate
$ winpty dotnet fake build -t TestTemplate
Starting full restore process.
run TestTemplate
Building project with version: LocalBuild
Shortened DependencyGraph for Target TestTemplate:
<== TestTemplate
   <== Publish
      <== Build
         <== Restore
            <== AssemblyInfo
               <== Clean

The running order is:
Group - 1
  - Clean
Group - 2
  - AssemblyInfo
Group - 3
  - Restore
Group - 4
  - Build
Group - 5
  - Publish
Group - 6
  - TestTemplate
Starting target 'Clean'
Finished (Success) 'Clean' in 00:00:00.0180991
Starting target 'AssemblyInfo'
Finished (Success) 'AssemblyInfo' in 00:00:00.0649912
Starting target 'Restore'
Starting task 'DotNet:restore'
C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax> "dotnet.exe"  msbuild /version /nologo (In: false, Out: true, Err: true)
16.10.1.27001
C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax> "dotnet.exe"  restore "" /nodeReuse:False "/bl:C:\Users\Rob\AppData\Local\Temp\tmpFE60.tmp.binlog" (In: false, Out: false, Err: false)
C:\Program Files\dotnet\sdk\5.0.301\MSBuild.dll -nologo -maxcpucount -target:Restore -verbosity:m /bl:C:\Users\Rob\AppData\Local\Temp\tmpFE60.tmp.binlog /nodeReuse:False .\Fornax.sln
  Determining projects to restore...
  Paket version 5.257.0
  Starting restore process.
  Performance:
   - Runtime: 1 second
  Restored C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\test\Fornax.Core.UnitTests\Fornax.Core.UnitTests.fsproj (in 297 ms).
  Restored C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Core\Fornax.Core.fsproj (in 297 ms).
  Restored C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax\Fornax.fsproj (in 668 ms).
Finished (Success) 'DotNet:restore' in 00:00:07.3544701
Finished (Success) 'Restore' in 00:00:07.3624601
Starting target 'Build'
Starting task 'DotNet:build'
C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax> "dotnet.exe"  build "" --configuration Release /nodeReuse:False "/bl:C:\Users\Rob\AppData\Local\Temp\tmp1AB3.tmp.binlog" (In: false, Out: false, Err: false
)
Microsoft (R) Build Engine version 16.10.1+2fd48ab73 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\dotnet\sdk\5.0.301\MSBuild.dll -consoleloggerparameters:Summary -maxcpucount -property:Configuration=Release -restore -verbosity:m /bl:C:\Users\Rob\AppData\Local\Temp\tmp1AB3.tmp.binlog /nodeRe
use:False .\Fornax.sln
  Determining projects to restore...
  All projects are up-to-date for restore.
  Fornax.Core -> C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Core\bin\Release\netstandard2.0\Fornax.Core.dll
  Fornax.Core.UnitTests -> C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\test\Fornax.Core.UnitTests\bin\Release\net5.0\Fornax.Core.UnitTests.dll
  Fornax -> C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax\bin\Release\net5.0\Fornax.dll

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

Time Elapsed 00:00:16.32
Finished (Success) 'DotNet:build' in 00:00:17.4707228
Finished (Success) 'Build' in 00:00:17.4736510
Starting target 'Publish'
Starting task 'DotNet:publish': src/Fornax
C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax> "dotnet.exe"  publish src/Fornax --configuration Release --output "C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\temp" /nodeReuse:False "/bl:C:\Use
rs\Rob\AppData\Local\Temp\tmp5ED1.tmp.binlog" (In: false, Out: false, Err: false)
Microsoft (R) Build Engine version 16.10.1+2fd48ab73 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\dotnet\sdk\5.0.301\MSBuild.dll -maxcpucount -property:Configuration=Release -property:PublishDir=C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\temp -restore -target:Publish -verbosity:m
 /bl:C:\Users\Rob\AppData\Local\Temp\tmp5ED1.tmp.binlog /nodeReuse:False src/Fornax\Fornax.fsproj
  Determining projects to restore...
  All projects are up-to-date for restore.
  Fornax.Core -> C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Core\bin\Release\netstandard2.0\Fornax.Core.dll
  Fornax -> C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax\bin\Release\net5.0\Fornax.dll
  Fornax -> C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\temp\
Finished (Success) 'DotNet:publish' in 00:00:03.6979853
Finished (Success) 'Publish' in 00:00:03.7015990
Starting target 'TestTemplate'
templateDir: C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src/Fornax.Template/
C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src/Fornax.Template/> "dotnet" "C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\temp\Fornax.dll" watch (In: false, Out: false, Err: false)
[20:27:44] multiple files generated in 499ms
[20:27:44] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\about.html' generated in 312ms
[20:27:44] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\contact.html' generated in 323ms
[20:27:45] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\images/avatar.jpg' generated in 93ms
[20:27:45] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\images/bulma.png' generated in 0ms
[20:27:45] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\images/favicon.png' generated in 0ms
[20:27:45] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\js/sampleJsFile.js' generated in 0ms
[20:27:45] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\posts/post.html' generated in 346ms
[20:27:45] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\posts/post2.html' generated in 1ms
[20:27:45] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\posts/post3.html' generated in 3ms
[20:27:45] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\posts/post4.html' generated in 1ms
[20:27:45] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\posts/post5.html' generated in 0ms
[20:27:45] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\posts/post6.html' generated in 0ms
[20:27:45] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\style/style.css' generated in 1ms
[20:27:45] 'C:\Users\Rob\source\repos\workspace\git\dotnet\Fornax\src\Fornax.Template\_public\posts/subdir/post3.html' generated in 1ms
Generation time: 00:00:08.1293748
[20:27:45] Watch mode started. Press any key to exit.
[20:27:45 INF] Smooth! Suave listener started in 88.1ms with binding 127.0.0.1:8080
qExiting...
Finished (Success) 'TestTemplate' in 00:07:13.9909398

---------------------------------------------------------------------
Build Time Report
---------------------------------------------------------------------
Target         Duration
------         --------
Clean          00:00:00.0055282
AssemblyInfo   00:00:00.0638374
Restore        00:00:07.3614451
Build          00:00:17.4726691
Publish        00:00:03.6997230
TestTemplate   00:07:13.9896768
Total:         00:07:42.8770401
Status:        Ok
---------------------------------------------------------------------
Performance:
 - Cli parsing: 332 milliseconds
 - Packages: 1 second
   - Creating Runtime Graph: 169 milliseconds
   - Retrieve Assembly List: 1 second
 - Script compiling: 6 seconds
 - Script analyzing: 450 milliseconds
 - Script running: 7 minutes, 43 seconds
 - Script cleanup: 25 milliseconds
 - Runtime: 7 minutes, 52 seconds
bytesource commented 3 years ago

@rdipardo This is perfect. Thank you so much!