@@ -185,12 +185,12 @@ type internal DocContent
185185
186186 if name.StartsWith( '.' ) then
187187 printfn " skipping file %s " inputFileFullPath
188- elif not ( name.StartsWith( " _template" , StringComparison.Ordinal ) ) then
189- let isFsx = inputFileFullPath.EndsWith( " .fsx" , true , CultureInfo.InvariantCulture )
188+ elif not ( name.StartsWith " _template" ) then
189+ let isFsx = inputFileFullPath.EndsWith( " .fsx" , StringComparison.OrdinalIgnoreCase )
190190
191- let isMd = inputFileFullPath.EndsWith( " .md" , true , CultureInfo.InvariantCulture )
191+ let isMd = inputFileFullPath.EndsWith( " .md" , StringComparison.OrdinalIgnoreCase )
192192
193- let isPynb = inputFileFullPath.EndsWith( " .ipynb" , true , CultureInfo.InvariantCulture )
193+ let isPynb = inputFileFullPath.EndsWith( " .ipynb" , StringComparison.OrdinalIgnoreCase )
194194
195195 // A _template.tex or _template.pynb is needed to generate those files
196196 match outputKind, template with
@@ -351,19 +351,58 @@ type internal DocContent
351351 printfn " preparing %s --> %s " inputFileFullPath outputFileRelativeToRoot
352352
353353 let evaluateNotebook ipynbFile =
354+ let args =
355+ $" repl --run {ipynbFile} --default-kernel fsharp --exit-after-run --output-path {ipynbFile}"
356+
354357 let psi =
355358 ProcessStartInfo(
356359 fileName = " dotnet" ,
357- arguments =
358- $" repl --run {ipynbFile} --default-kernel fsharp --exit-after-run --output-path {ipynbFile}" ,
360+ arguments = args,
359361 UseShellExecute = false ,
360362 CreateNoWindow = true
361363 )
362364
363- let p = Process.Start( psi)
364- p.WaitForExit()
365+ try
366+ let p = Process.Start( psi)
367+ p.WaitForExit()
368+ with _ ->
369+ let msg =
370+ $" Failed to evaluate notebook {ipynbFile} using dotnet-repl\n "
371+ + $""" try running "{args}" at the command line and inspect the error"""
372+
373+ failwith msg
374+
375+ let checkDotnetReplInstall () =
376+ let failmsg =
377+ " 'dotnet-repl' is not installed. Please install it using 'dotnet tool install dotnet-repl'"
378+
379+ try
380+ let psi =
381+ ProcessStartInfo(
382+ fileName = " dotnet" ,
383+ arguments = " tool list --local" ,
384+ UseShellExecute = false ,
385+ CreateNoWindow = true ,
386+ RedirectStandardOutput = true
387+ )
388+
389+ let p = Process.Start( psi)
390+ let ol = p.StandardOutput.ReadToEnd()
391+ p.WaitForExit()
392+ psi.Arguments <- " tool list --global"
393+ p.Start() |> ignore
394+ let og = p.StandardOutput.ReadToEnd()
395+ let output = $" {ol}\n {og}"
396+
397+ if not ( output.Contains( " dotnet-repl" )) then
398+ failwith failmsg
399+
400+ p.WaitForExit()
401+ with _ ->
402+ failwith failmsg
365403
366404 if evaluate then
405+ checkDotnetReplInstall ()
367406 printfn $" evaluating {inputFileFullPath} with dotnet-repl"
368407 evaluateNotebook inputFileFullPath
369408
0 commit comments