dotnet / dotnet/fsharp

DependencyProvider errors are not routed to StdError, but StdOutput

Open
#10,039 5 comments 0 reactions 0 assignees View on GitHub
Area-FSI Bug Impact-Low
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

The `DependencyProvider` has two members, `StdError` and `StdOutput` that capture error or "normal" console output, however, oftentimes, `StdError` is not used. Not sure what causes this.

Same is true for the `ResolvingErrorReport` callback function. This is not called (I replaced the `printfn` with `ITestOutputHelper.WriteLine`, because xUnit will otherwise not write to the console).

Note that the `DependencyProvider.Success` is correctly set to `false` when this situation occurs.

In the following code, `output` is set as `ITestOutputHelper`, see last two lines:

```f#
[]
member __.``Multiple Instances of DependencyProvider should be isolated``() =

let assemblyProbingPaths () = Seq.empty
let nativeProbingRoots () = Seq.empty

use dp1 = new DependencyProvider(NativeResolutionProbe(nativeProbingRoots))
let reportError =
let report errorType code message =
// this never happens!
match errorType with
| ErrorReportType.Error -> output.WriteLine <| sprintf "PackageManagementError %d : %s" code message
| ErrorReportType.Warning -> output.WriteLine <| sprintf "PackageManagementWarning %d : %s" code message
ResolvingErrorReport (report)

let idm1 = dp1.TryFindDependencyManagerByKey(Seq.empty, "", reportError, "nuget")
if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then
let result1 = dp1.Resolve(idm1, ".fsx", [|"FSharp.Data"|], reportError, "net472")

// diagnostics if things go wrong:
if not result1.Success then
result1.StdOut |> Array.iter output.WriteLine // contains data
result1.StdError |> Array.iter output.WriteLine // contains no data
```

On my machine, this test often fails, sometimes succeeds. When it fails (only on NetFX) it shows on `StdOut`:

```
Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets(128,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\Users\Abel\AppData\Local\Temp\nuget\10656--4ff2cddb-2700-4aea-b33c-1ba167b7baad\Project.fsproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets(128,5): error : An error occurred while sending the request. [C:\Users\Abel\AppData\Local\Temp\nuget\10656--4ff2cddb-2700-4aea-b33c-1ba167b7baad\Project.fsproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets(128,5): error : The request was aborted: Could not create SSL/TLS secure channel. [C:\Users\Abel\AppData\Local\Temp\nuget\10656--4ff2cddb-2700-4aea-b33c-1ba167b7baad\Project.fsproj]
```

Related: #10037, #10038.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.