You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Referencing packages in F# Interactive doesn't work when connected to a feed requiring authentication #11392
[severity:It's more difficult to complete my work]
According to the official documentation, it should be possible to reference NuGet packages from an F# script file:
#r "nuget: Newtonsoft.Json"
open Newtonsoft.Json
let data = {| Name = "Don Syme"; Occupation = "F# Creator" |}
JsonConvert.SerializeObject(data)
When I try to do this, however, it doesn't work. The editor is full of red squiggly lines, the error list contains five errors, and when I send the code to F# Interactive (Alt + Enter), it prints this error message:
Reactors.fsx(1,1): error FS3217: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets(131,5): 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 [C:\Users\mark\AppData\Local\Temp\nuget\20272--3928d5e7-1194-4146-a20d-a5f0dd5e8910\Project.fsproj]
It's not clear how to proceed from here.
Original Comments
Feedback Bot on 3/28/2021, 11:37 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Based on a hint by Kevin Ransom in the original issue report, I tried to turn off the other NuGet feeds I've configured in Visual Studio. That seems to make the error go away.
That was really not obvious to me, but can be used as a workaround.
This is related to #10609 which is tracking the ability to specify credentials in a script for an authenticated feed.
But the core issue here is that when you specify one of the sources that requires authentication, a NuGet error is generated since you're not authenticated for scripting. That could arguably be a bug.
changed the title [-]Referencing packages in F# Interactive doesn't work[/-][+]Referencing packages in F# Interactive doesn't work when connected to a feed requiring authentication[/+]on Apr 9, 2021
I don't know if this is related, but today, I'm trying this:
#r @"nuget: FSharpPlus"
open FSharpPlus
let maybeXs: Option<List<int>> = Some [1]
Even with all other NuGet sources removed, when I send this to F# Interactive, I get this:
~vsAC87.fsx(1,1): error FS3216: Package manager key 'nuget' was not registered in [C:\Users\mark\AppData\Local\assembly\dl3\OGA45T4X.NBA\NVCC20B1.RWG\f7d9b153\c20c92ba_7358d701; c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\commonextensions\microsoft\fsharp\Tools\], []. Currently registered:
~vsAC87.fsx(1,1): error FS3217: Processing of a script fragment has stopped because an exception has been raised
Even so, the mere presence of a NuGet feed that requires authentication is enough to completely break this functionality.
This is really bad, I had to add a custom nuget.config to keep a private GitHub Nuget source out of touch of .fsx scripts. Disabling them didn't work, but that'd have a wider impact to an entire repository anyways, so I'll stick with my workaround for a while.
If we want authenticated sources to be ignored just as a quick mitigation, what can we do?
executeTool (getDotnetHostPath())"nuget list source --format short" scriptDirectory timeout
🤷
The resulting, ephemeral .fsproj has to say "this and that RestoreAdditionalProjectSources might fail (due to missing configs) but that alone shouldn't fail the entire build." I don't know if such a property is exposed to us/fsi.
For me, unticking the authenticated package source in Visual Studio fixed the Ionide F#: Run script and FSI: Send File options, but not the highlighted errors in the editor. Adding a nuget.config file in the script folder to remove the authenticated source resolved the remaining issues.
In my case, I am already authenticated with the NuGet source.
Other commands like dotnet build in projects that use this source don't require re-authenticating.
Why can dotnet fsi not re-use this already setup authentication for the source?
Activity
ploeh commentedon Apr 8, 2021
Based on a hint by Kevin Ransom in the original issue report, I tried to turn off the other NuGet feeds I've configured in Visual Studio. That seems to make the error go away.
That was really not obvious to me, but can be used as a workaround.
cartermp commentedon Apr 9, 2021
This is related to #10609 which is tracking the ability to specify credentials in a script for an authenticated feed.
But the core issue here is that when you specify one of the sources that requires authentication, a NuGet error is generated since you're not authenticated for scripting. That could arguably be a bug.
[-]Referencing packages in F# Interactive doesn't work[/-][+]Referencing packages in F# Interactive doesn't work when connected to a feed requiring authentication[/+]ploeh commentedon Apr 9, 2021
To be clear, I didn't need a NuGet package from the authenticated feed that I had configured; I just wanted a normal NuGet package off of nuget.org.
Even so, the mere presence of a NuGet feed that requires authentication is enough to completely break this functionality.
ploeh commentedon Jul 22, 2021
I don't know if this is related, but today, I'm trying this:
Even with all other NuGet sources removed, when I send this to F# Interactive, I get this:
Happypig375 commentedon Jul 23, 2021
@ploeh You're hitting #11622 which is fixed in VS16.11.
nodakai commentedon Oct 29, 2021
This is really bad, I had to add a custom
nuget.configto keep a private GitHub Nuget source out of touch of.fsxscripts. Disabling them didn't work, but that'd have a wider impact to an entire repository anyways, so I'll stick with my workaround for a while.If we want authenticated sources to be ignored just as a quick mitigation, what can we do?
fsharp/src/fsharp/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Utilities.fs
Line 152 in eb1337f
🤷
The resulting, ephemeral
.fsprojhas to say "this and thatRestoreAdditionalProjectSourcesmight fail (due to missing configs) but that alone shouldn't fail the entire build." I don't know if such a property is exposed to us/fsi.cadull commentedon Jul 31, 2023
For me, unticking the authenticated package source in Visual Studio fixed the Ionide F#: Run script and FSI: Send File options, but not the highlighted errors in the editor. Adding a
nuget.configfile in the script folder to remove the authenticated source resolved the remaining issues.omcnoe commentedon Dec 15, 2023
In my case, I am already authenticated with the NuGet source.
Other commands like
dotnet buildin projects that use this source don't require re-authenticating.Why can
dotnet fsinot re-use this already setup authentication for the source?