Reputation: 1489
Most of the tools I use, are dotnet tools that are referenced from csproj file and automagically fetched by nuget. A few tools are old-school Framework tools, which should be copied into the tools directory before use. For the latter I have a GetTools Target.
My problem is declaring the Tool:
[LocalExecutable("./tools/MyFrameworkTool.exe")]
readonly Tool FrameworkTool;
This throws the following assertion:
Assertion failed: File.Exists(C:\Jenkins\workspace\Job\./tools/MyFrameworkTool.exe)
And the FrameworkTool is null.
How can I make a 'late' declaration of the tool, when it has been fetched by the GetTools Target?
Upvotes: 2
Views: 645
Reputation: 1489
For other developers in the same situation, I post the answer here.
Matthias suggestion to use ToolResolver was the key.
The initial (Restore) Target can copy the tool to the ./tools/MyCustomTool directory.
With the ToolResolver static class, one can declare it in the Target, where it is referenced:
Tool MyCustomTool = ToolResolver.GetLocalTool("./tools/MyCustomTool/MyCustomTool.exe");
MyCustomTool is now available to use inside this Target.
Upvotes: 4