Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
* Fix parser recovery, name resolution, and code completion for unfinished enum patterns ([PR #19708](https://github.com/dotnet/fsharp/pull/19708))
* Parser: fix unexpected diagnostics in debug builds, improve error messages ([PR #19730](https://github.com/dotnet/fsharp/pull/19730))
* Fix signature conformance: overloaded member with unit parameter `M(())` now matches sig `member M: unit -> unit`. ([Issue #19596](https://github.com/dotnet/fsharp/issues/19596), [PR #19615](https://github.com/dotnet/fsharp/pull/19615))
* Fix `--quiet` not suppressing NuGet restore output on stdout in F# Interactive ([Issue #18086](https://github.com/dotnet/fsharp/issues/18086))

### Added

Expand Down
9 changes: 8 additions & 1 deletion src/Compiler/Interactive/fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2819,8 +2819,15 @@ type internal FsiDynamicCompiler

if result.Success then

// Issue #18086: under --quiet (tcConfigB.noFeedback), NuGet/MSBuild
// restore chatter and warnings must not pollute stdout. Route what
// would have gone to stdout to stderr instead so the information is
// still discoverable for users who redirect stderr.
let stdOutSink: System.IO.TextWriter =
if tcConfigB.noFeedback then Console.Error else Console.Out

for line in result.StdOut do
Console.Out.WriteLine(line)
stdOutSink.WriteLine(line)

for line in result.StdError do
Console.Error.WriteLine(line)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,47 @@ module FsiCliTests =
let result = runFsiProcess [option]
Assert.NotEqual(0, result.ExitCode)
Assert.Contains(expectedError, result.StdErr)

// ============================================================================
// Issue #18086: --quiet must suppress NuGet restore stdout chatter
// ============================================================================

let private writeTempScript (content: string) : string =
let path = System.IO.Path.Combine(System.IO.Path.GetTempPath(), $"fsi_quiet_{System.Guid.NewGuid():N}.fsx")
System.IO.File.WriteAllText(path, content)
path

let private runFsiScript (extraArgs: string list) (scriptBody: string) =
let scriptPath = writeTempScript scriptBody
try
let result = runFsiProcess (extraArgs @ [scriptPath])
result
finally
try System.IO.File.Delete(scriptPath) with _ -> ()

[<Fact>]
let ``FSI quiet mode suppresses NuGet restore output from stdout`` () =
let script = """
#r "nuget: Newtonsoft.Json, 13.0.3"
printfn "RESULT_MARKER_18086"
"""
let result = runFsiScript ["--quiet"] script
Assert.Contains("RESULT_MARKER_18086", result.StdOut)
Assert.DoesNotContain("Determining projects to restore", result.StdOut)
Assert.DoesNotContain("Restored ", result.StdOut)
Assert.DoesNotContain("NU1", result.StdOut)

[<Fact>]
let ``FSI default (non-quiet) mode still evaluates script and prints user output`` () =
let script = """
#r "nuget: Newtonsoft.Json, 13.0.3"
printfn "RESULT_MARKER_18086_DEFAULT"
"""
let result = runFsiScript [] script
Assert.Contains("RESULT_MARKER_18086_DEFAULT", result.StdOut)

[<Fact>]
let ``FSI quiet mode still prints user printfn output to stdout`` () =
let script = """printfn "hello from quiet script" """
let result = runFsiScript ["--quiet"] script
Assert.Contains("hello from quiet script", result.StdOut)
Loading