KevM
KevM

Reputation: 2506

Cake script directly referencing a nuget

Is there a better way to use code from a public nuget in a cake script that this?

#tool nuget:?package=dbup-core&version=4.0.0-beta0003
#r "tools/dbup-core.4.0.0-beta0003/lib/netstandard1.3/dbup-core.dll"

This works fine but feels a bit klunky as I need to go find the path for the version of the .Net framework in use. In this case I had to use /lib/netstandard1.3.

I tried using the same preprocessor directive syntax as an #addin or #tool with no luck. It would be nice to have something like this work:

#r nuget:?package=dbup-core&version=4.0.0-beta0003

Upvotes: 1

Views: 285

Answers (1)

Gary Ewan Park
Gary Ewan Park

Reputation: 18981

Both the tool and addin pre-processor directives handle the download of a specified nuget package. The main difference is that the tool pre-processor directive only downloads and extracts the nuget package into the tools folder, it doesn't then reference any dll's that are contained within it.

The addin pre-processor on the other hand does exactly that. It will look for dll's from the extracted nuget package, and reference them automatically, so that they can be used within the Cake Script. There should be no need to additional use the reference pre-processor directive.

Do you have a sample repository which shows a script that isn't working as you expect it to? It could be that the wrong target framework dll is being loaded, based on what version of Cake is being used.

If you can create a sample repository to illustrate the problem, then I am sure that we can help.

Upvotes: 3

Related Questions