Paket: Support DotNetCliToolReference packages

Created on 17 May 2017  Â·  4Comments  Â·  Source: fsprojects/Paket

The new dotnet SDK supports extensibility of CLI commands on a per project basis using the DotNetCliToolReference item. This is very nice because CLI tools can be distributed as normal Nuget packages and there can be different versions of the tool for different project, while the feeling is as if the CLI tool was installed globally in the path.

Unfortunately Paket cannot manage DotNetCliToolReference items. It'll be great if it could do it, because then users could just rely on paket.dependencies for all tools and libraries version management as they're used too. This is specially important in Fable, where we have to sync the versions of a library (Fable.Core) and a CLI tool (dotnet-fable). See discussion in https://github.com/fable-compiler/Fable/pull/919

I don't know the machinery behind DotNetCliToolReference so I'm not sure how this could work with Paket and what would be needed for that. I just noted Nuget creates a folder for each CLI tool in ~/.nuget/packages/.tools containing the dependencies of the tool. I guess this is to load all the necessary assemblies when the tool is invoked.

cc @forki @enricosada @cloudroutine

Most helpful comment

So, dotnet cli mechanism atm is like that.

  • try to find in all packages roots the restored nupkg with a project.assets.json in calculated directory path
  • generate the deps.json, if not exists, from assets file. It contains the assemblies/packages to references) used by dotnet exec
  • dotnet exec it

dunno if there is enough doc, but is not hard to understand what does.

just dotnet -d {clitool}, like dotnet -d fable

Splitted is:

e:\temp\df>dotnet -d fable

Find msbuid and project

Telemetry is: Disabled
projectfactory: MSBUILD_EXE_PATH = C:\dotnetcli\dotnet-1.1.1-sdk-win-x64\sdk\1.0.1\MSBuild.dll
projectfactory: MSBuild project path = e:\temp\df\df.fsproj

The dotnet/cli ProjectToolsCommandResolver try to find a lock file, generated at restore step (just do dotnet msbuild /t:Restore /v:diag instead of the alias dotnet restore)

projecttoolscommandresolver: resolving commandspec from 1 Tool Libraries.
projecttoolscommandresolver: Attempting to resolve command spec from tool dotnet-fable
projecttoolscommandresolver: nuget packages root:
- C:\Users\e.sada\.nuget\packages\
- C:\Users\e.sada\.dotnet\NuGetFallbackFolder
projecttoolscommandresolver: found tool lockfile at : C:\Users\e.sada\.nuget\packages\.tools\dotnet-fable\1.0.0\netcoreapp1.0\project.assets.json

Generate deps json from project.assets.json, if not exists

projecttoolscommandresolver: expect deps.json at: C:\Users\e.sada\.nuget\packages\.tools\dotnet-fable\1.0.0\netcoreapp1.0\dotnet-fable.deps.json
Generating deps.json at: C:\Users\e.sada\.nuget\packages\.tools\dotnet-fable\1.0.0\netcoreapp1.0\dotnet-fable.deps.json

Debug output to create the commandspec (so the class who contains info about dotnet exec parameters )

projecttoolscommandresolver: attempting to create commandspec
packagedcommandspecfactory: attempting to find command dotnet-fable in dotnet-fable
packagedcommandspecfactory: Looking for prefercliruntime file at `C:\Users\e.sada\.nuget\packages\dotnet-fable\1.0.0\lib\netcoreapp1.0\..\..\prefercliruntime`

Normal dotnet execution (like a FDD console app).

Running C:\dotnetcli\dotnet-1.1.1-sdk-win-x64\dotnet.exe exec --depsfile C:\Users\e.sada\.nuget\packages\.tools\dotnet-fable\1.0.0\netcoreapp1.0\dotnet-fable.deps.json --additionalprobingpath C:\Users\e.sada\.nuget\packages C:\Users\e.sada\.nuget\packages\dotnet-fable\1.0.0\lib\netcoreapp1.0\dotnet-fable.dll
Process ID: 16520

So, long story short, the project.assets.json is needed, and is generated like the obj\project.assets.json.

If paket doesnt generate it (because is done, correct ihmo, by restore task), should provide a DotnetCliTool item, probably doing the same as PackageReference in paket target file

All 4 comments

So, dotnet cli mechanism atm is like that.

  • try to find in all packages roots the restored nupkg with a project.assets.json in calculated directory path
  • generate the deps.json, if not exists, from assets file. It contains the assemblies/packages to references) used by dotnet exec
  • dotnet exec it

dunno if there is enough doc, but is not hard to understand what does.

just dotnet -d {clitool}, like dotnet -d fable

Splitted is:

e:\temp\df>dotnet -d fable

Find msbuid and project

Telemetry is: Disabled
projectfactory: MSBUILD_EXE_PATH = C:\dotnetcli\dotnet-1.1.1-sdk-win-x64\sdk\1.0.1\MSBuild.dll
projectfactory: MSBuild project path = e:\temp\df\df.fsproj

The dotnet/cli ProjectToolsCommandResolver try to find a lock file, generated at restore step (just do dotnet msbuild /t:Restore /v:diag instead of the alias dotnet restore)

projecttoolscommandresolver: resolving commandspec from 1 Tool Libraries.
projecttoolscommandresolver: Attempting to resolve command spec from tool dotnet-fable
projecttoolscommandresolver: nuget packages root:
- C:\Users\e.sada\.nuget\packages\
- C:\Users\e.sada\.dotnet\NuGetFallbackFolder
projecttoolscommandresolver: found tool lockfile at : C:\Users\e.sada\.nuget\packages\.tools\dotnet-fable\1.0.0\netcoreapp1.0\project.assets.json

Generate deps json from project.assets.json, if not exists

projecttoolscommandresolver: expect deps.json at: C:\Users\e.sada\.nuget\packages\.tools\dotnet-fable\1.0.0\netcoreapp1.0\dotnet-fable.deps.json
Generating deps.json at: C:\Users\e.sada\.nuget\packages\.tools\dotnet-fable\1.0.0\netcoreapp1.0\dotnet-fable.deps.json

Debug output to create the commandspec (so the class who contains info about dotnet exec parameters )

projecttoolscommandresolver: attempting to create commandspec
packagedcommandspecfactory: attempting to find command dotnet-fable in dotnet-fable
packagedcommandspecfactory: Looking for prefercliruntime file at `C:\Users\e.sada\.nuget\packages\dotnet-fable\1.0.0\lib\netcoreapp1.0\..\..\prefercliruntime`

Normal dotnet execution (like a FDD console app).

Running C:\dotnetcli\dotnet-1.1.1-sdk-win-x64\dotnet.exe exec --depsfile C:\Users\e.sada\.nuget\packages\.tools\dotnet-fable\1.0.0\netcoreapp1.0\dotnet-fable.deps.json --additionalprobingpath C:\Users\e.sada\.nuget\packages C:\Users\e.sada\.nuget\packages\dotnet-fable\1.0.0\lib\netcoreapp1.0\dotnet-fable.dll
Process ID: 16520

So, long story short, the project.assets.json is needed, and is generated like the obj\project.assets.json.

If paket doesnt generate it (because is done, correct ihmo, by restore task), should provide a DotnetCliTool item, probably doing the same as PackageReference in paket target file

From the description we should probably support this natively in paket but not on a project-level but on a solution/paket.dependencies level. Can we please wait for FAKE 5 and see how that works out? Because currently I'm not sure whether this should be part of FAKE, paket or maybe both?

It should be part of Paket since we want to support that for everyone

2017-05-17 18:20 GMT+02:00 Matthias Dittrich notifications@github.com:

From the description we should probably support this natively in paket but
not on a project-level but on a solution/paket.dependencies level. Can we
please wait for FAKE 5 and see how that works out? Because currently I'm
not sure whether this should be part of FAKE, paket or maybe both?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/fsprojects/Paket/issues/2343#issuecomment-302143151,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADgNPbA9udj8pZ6mZu_OqcJmS53cWwiks5r6x5MgaJpZM4Nd60B
.

I think this has been implemented (kind of), rest is https://github.com/fsprojects/Paket/issues/2497

Was this page helpful?
0 / 5 - 0 ratings