Sprydon

Richard Harding's spot on the web

DotNet Core testing local cli tools

The new xml project file format csproj includes the facility to restore a package for use in the build process (see docs here) it replaces the

When building a tool package that a project could use its not immediately obvious how to test the unpublished local version of the tool

Given an entry like

<ItemGroup>
  <DotNetCliToolReference Include="SpecFlow.NetCore" Version="1.0.0-rc8" />
</ItemGroup>

The build process will restore the SpecFlow.NetCore package from Nuget rather than use a copy on the local file system. The discussion on this issue and here on the cli github repo outlines the option I eventually ended up using

Pack the tool package under development specifying a suitable local area eg

dotnet pack -o ../mynugetcache

Then in the consuming project add a Nuget.Config file to add the local area as an addition feed eg

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="test-packages" value="../mynugetcache" />
  </packageSources>
</configuration>

I found that as my consuming projects had already installed the public version I needed to delete from my local cache

%UserProfile%\.nuget\packages

And also delete the lock files in the projects obj folder

Loading