fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

paket dependency manager doesn't work out of the box in VS, but it does if compiles with VS

Open smoothdeveloper opened this issue 2 years ago • 9 comments

When I pull the release of FSharp.DependencyManager.Paket.dll from https://github.com/fsprojects/Paket/releases and drop it next to the location it is required under dotnet fsi (under the dotnet sdk folder, next to the nuget extension), it just works.

However, when I attempt to do so, in order for VS to pick it up, dropping under the commonextensions/microsoft/fsharp folder, VS doesn't pick it up.

Repro steps

  • download FSharp.DependencyManager.Paket.dll from https://github.com/fsprojects/Paket/releases
  • (§) drop it in your VS installation (C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\FSharp for example)
  • open a script with #r "paket: nuget Foo" in it

Expected behavior

Typechecks

Actual behavior

Complains about the extension "paket" not being present.

Known workarounds

  • https://github.com/fsprojects/Paket/
  • open https://github.com/fsprojects/Paket/blob/master/src/FSharp.DependencyManager.Paket/FSharp.DependencyManager.Paket.fsproj in VS
  • compile to your taste
  • !!!!???? (§) (deploy in VS following the above steps, which are a bit voodoo for end users until we do something around #8880)
  • profit

FSharp.DependencyManager.Paket.release.zip

Related information

It always behaved this way, it is not something which broke due to a change, but it should be fixed if possible.

I suspect it impacts any other extensions than the one which Microsoft ships, I don't know why it works out of the box in the dotnet sdk but not in VS.

smoothdeveloper avatar Mar 29 '22 22:03 smoothdeveloper

This is supposed to work. Assuming that the packet package manager is implemented correctly. Which I am sure it is.

KevinRansom avatar Mar 31 '22 17:03 KevinRansom

I will take a look when I get a chance.

KevinRansom avatar Mar 31 '22 17:03 KevinRansom

Thanks @KevinRansom and hit me up if anything.

It would be good to have @KathleenDollard & all think about end user experience (I know the prospect of extensions as powerful as type providers, being like a pandora box, is not the best for restful nights) and some technicals, like some old ideas in #8880.

I was thinking having a "open folder to fsharp VS extension" under the F# Interactive settings, with "use at your own risk" (as it requires admin rights for writing in the folder) and note about putting the same extensions under the dotnet sdk.

Most VS users will need to drop the extensions manually in two folders, or more, so in long run, it makes it tedious for developers and end users (those that write scripts) to manage the extensions from their IDE, and I'd like to asses what Microsoft wants to happen on that end.

Thanks all.

smoothdeveloper avatar Apr 01 '22 22:04 smoothdeveloper

We should have a design document (e.g. tooling RFC) that specifies how the DependencyManager things work. It's hard to tell what the intended design is.

dsyme avatar Apr 04 '22 13:04 dsyme

@dsyme, it does work the same as the Nuget extension (the .dll of an extension should be next to it), this is the spec for now, and --compilertool: is used if you need to store the extension in adhoc location.

Microsoft shipped "#r "nuget:"" but not what was underlying getting it, or the spec of the RFC, yet, it is clear, extensions work like the one that ships and is supported by Microsoft.

I have clarified the RFC: https://github.com/fsharp/fslang-design/pull/659

I am eager the whole thing evolve, to something as great as installing vscode extensions in major IDEs, and ideally, that there is a stable location, and documented behaviour about how the loading of extension takes place, but it will be hard for me to nudge it, and I am preoccupied about my own ability to use the extensions and to engage with community to write more of them.

If this issue is not fixed, no one has much incentive to work on extensions (in F# community, it can take place without need of official documentation being perfect, it works for the compiler for example) IMO.

If there are no extensions (beside paket, justifying it is technically true, it is extensible), I doubt Microsoft is going to pour effort in the user experience to install extensions.

smoothdeveloper avatar Apr 21 '22 08:04 smoothdeveloper

Current status:

image

I am forced to recompile the extension locally with each release/update of VS and there are 3 or 4 locations to put it, to get it to work on all the places it is needed:

  • Common7/IDE or CommonExtensions/.../FSharp
  • FSharp/Tools
  • dotnet sdk

IMO, it makes extension in scripting context unusable.

I assume it is a missing handling for FSharp.Core binding redirect through https://docs.microsoft.com/en-US/dotnet/api/system.appdomain.assemblyresolve?view=net-6.0 that would make it work in VS.

smoothdeveloper avatar Jun 24 '22 09:06 smoothdeveloper

@dsyme, questioning the "impact: low", it is like there is not much interest in seeing the extension mechanism being put into use, or that #r "nuget: " is all that was required. Those are false assertions.

smoothdeveloper avatar Jun 28 '22 20:06 smoothdeveloper

@smoothdeveloper I'll let @KevinRansom decide on the priority and direction here.

It's true I'm now a more skeptical of the long-term viability or wisdom of supporting an extensible model of resolution - especially anything that involves globally installed tools or tools not managed via "dotnet tool" (which wasn't available when we first started this). Also the unexpectedly relatively low activity in the Paket repo in the last year makes me wonder about the scenario now - I mean the tool is maintained and available but the updates to .NET 6 took some time and as a result of the role out of .NET SDK projects it is no longer as influential on the F# community and practice as it was.

That's just my 2c worth. The extension point is part of the overall feature set we have and it makes sense to make it work in all reasonable scenarios. And it's quite possible the extension point could itself be extended and come in handy for other things.

dsyme avatar Jul 06 '22 11:07 dsyme

@dsyme, thanks for sharing your standpoint.

Regarding paket activity, it is in maintenance mode, but I doubt it goes away, and it is widely used, even with dotnet SDK (and PackageReference), it still provide functionality and aspects that aren't doable without it, and are simpler than what Microsoft is designing with nuget.

For example, I just noticed fantomas repository uses it to avoid taking binary dependency on FCS (quite clever, to shorten feedback loop, etc.), I can't myself work much without it in projects involving lots of dependencies, etc.

Also the breadth of contributors that open issues and fix them themselves or get a quick fix by seasoned maintainers is good testimony of durability of the tool.

The paket extension itself is super useful, and I can see other useful extension in the making, that would really bring value to F# scripting, only the deployment story is less than ideal (#8880 has few pointers, and we could discuss).

#r "roslyn: path.to.vb"
#r "msbuild: path/to/file.proj"
#r "cppsharp: path/to/include.hpp"

The paket extension does stuff that nuget can't do (file dependencies, git/github dependencies, etc.).

Proposed action plan:

  1. to get the extension that are already compiled and shipping to work just by dropping it in the folders VS expects it (this issue).
  2. start shipping the nuget extension in another location, which will be a supported location not involving messing with dotnet sdk and VS install folders (https://github.com/dotnet/sdk/issues/26474), and have dotnet fsi and VS and FCS looking for this location (#8880).
  3. maybe loading extension from referenced assemblies in FSI (highlighted in #8880).
  4. adjusting documentation and adding guidelines to write extensions

Extensions could eventually contribute more things to FSI, providing a packaged approach to setup pretty printers, useful for notebooks, etc. But first it is required to make them easy to install.

I don't mind it takes a route that involves dotnet as frontend, but I am concerned that point 1 is still blocking the most to make it useful to end users.

smoothdeveloper avatar Jul 07 '22 12:07 smoothdeveloper

The issue stems from the binary file being "blocked" by the OS. I was able to troubleshot this with debugger and seeing the inner exceptions messages.

Would the fsharp team take a PR that:

  • replaces https://github.com/dotnet/fsharp/blob/1e65a08d67ad787d53e427c182df240660d37ffc/src/Compiler/DependencyManager/DependencyProvider.fs#L506-L525 with non lazy code (this is amortized, and makes debugging this stage easier)
  • displays the messages of all the exception tree rather than just the top one

?

Also, I'd like that either the compilertool parameter given to FSI becomes used by the compiler service so end users could install the assemblies where they want and adjust a single setting for both FSI and the tooling, while currently, they need to deploy the assembly at two spots (one for the fsi binary, one for VS), will the team consider such change?

smoothdeveloper avatar Feb 10 '23 11:02 smoothdeveloper

@baronfel, do you know if an API exists in the various .NET runtimes (the ones for Visual Studio, FsiAnyCPU.exe and dotnet fsi) uses that would allow to check, on Windows, if a .dll file is locked by the OS for security reasons?

I'd like FSI and the tooling to report the specific error and provide guidance to the user when Windows defender / internet browser blocks a downloaded extension.

smoothdeveloper avatar Nov 12 '23 19:11 smoothdeveloper