TheRoadrunner
TheRoadrunner

Reputation: 1489

How to install dotnet tool with nuke

I am new to Nuke, trying to transition from Cake to Nuke. In Cake I have the option to install (locally) tools with:

#module nuget:?package=Cake.DotNetTool.Module&version=0.3.0

and

#tool dotnet:?package=my.package.id&version=1.0.1

I have tried this in Nuke:

[PackageExecutable(
    packageId: "my.package.id",
    packageExecutable: "mypakagedtool.exe",
    Version = "1.0.1")]
readonly Tool MyPackagedTool;

but that returns a:

Assertion failed: Could not find package 'my.package.id' (1.0.1) using:
 - Project assets file 
 - NuGet packages config

I guess this is not for dotnet tools, but for nuget tools?

Upvotes: 7

Views: 1627

Answers (2)

Aage
Aage

Reputation: 6252

Within Nuke Build you can do the following (this example is for OctopusTools):

nuke :addpackage OctopusTools

This results in the this <ItemGroup/> element being added to the .csproj of the Build (Nuke) project:

<ItemGroup>
    <PackageDownload Include="OctopusTools" Version="[9.0.0]" />
</ItemGroup>

Upvotes: 3

TheRoadrunner
TheRoadrunner

Reputation: 1489

The way I made it work, was to include this in the build.csproj:

  <ItemGroup>
    <PackageDownload Include="MyPackageId" Version="[1.0.1]" />
  </ItemGroup>

and in Build.cs:

[PackageExecutable("MyPackageId", "MyTool.dll")] readonly Tool MyTool;

then the tool can be invoked with:

MyTool("arguments");

...and of course nuget.config should be setup to give access to the package repository.

Upvotes: 5

Related Questions