dotnet / dotnet/fsharp

FSI #r Supports NuGet interactive.

Open
#16,057 2 comments 0 reactions 0 assignees View on GitHub
Area-FSI Feature Request
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

**Is your feature request related to a problem? Please describe.**

When trying to restore a package from a private Azure DevOps Azure Artifacts feed in `dotnet fsi` on MacOS, feed authentication using the [artifacts-credprovider](https://github.com/microsoft/artifacts-credprovider) fails. I believe it fails because `fsi` does not allow NuGet to be run in interactive mode. If the user was able to propagate an interactive flag to MS build/NuGet and display the output, the azure credprovider would be able to provide credentials in `fsi`.

**Describe the solution you'd like**

A desirable solution would allow the user to pass the interactive flag from the `fsi` restore command to MS build/NuGet and allow NuGet/MS build to write the necessary output to the `fsi` console window.
 
A command flag such as:
`fsi > #r -interactive ...`

or the nuget env variable [`FORCE_NUGET_EXE_INTERACTIVE` ](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-environment-variables).

**Describe alternatives you've considered**

A work around I have found at the moment is to fill the local cred provider cache with a `dotnet restore -interactive` command prior to the `fsi` command. But it would be nice to not have to do this extra step before hand.

**Additional context**

When the artifacts-credprovider is invoked by NuGet during a restore, the cred provider tries various authentication methods available on the device to get the credentials. Sometimes the only available authentication methods require interaction such as a pop-up login window or [device code flow](https://learn.microsoft.com/en-us/entra/msal/dotnet/acquiring-tokens/desktop-mobile/device-code-flow). The NuGet, Dotnet and MS build CLIs allow to pass the interactive flag to enable the interactive mode.

I have also tried using the nuget env variable [`FORCE_NUGET_EXE_INTERACTIVE` ](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-environment-variables), however this does not seem to work either. I suspect it fails because fsi takes over the console and does not allow NuGet to write the [device code flow](https://learn.microsoft.com/en-us/entra/msal/dotnet/acquiring-tokens/desktop-mobile/device-code-flow) output.

Repro steps:
1. On a MacOs, install the latest dotnet version, and install the latest [artifacts-credprovider](https://github.com/microsoft/artifacts-credprovider#automatic-bash-script).
1. invoke `dotnet fsi`
1. Run `#i "nuget:` (see https://learn.microsoft.com/en-us/azure/devops/artifacts/get-started-nuget?view=azure-devops&tabs=windows).
1. Run: `#r "nuget:Newtonsoft.json`

You should get this error message:

`warning : The plugin credential provider could not acquire credentials. Authentication may require manual action. Consider re-running the command with --interactive for 'dotnet', /p:NuGetInteractive="true" for MSBuild or removing the -NonInteractive switch for 'NuGet' [/Users/omcnoe/.packagemanagement/nuget/Projects/--SNIP--/Project.fsproj]`

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.