continuous-integrationazure-devopsdotnet-clidotnet-restoredotnet-test

How to run dotnet test on VSTS with custom NuGet feed?


We have a project with a dependency on a custom NuGet feed (also hosted in VSTS).

I'm trying to put together a new phase to generate code coverage reports, as in this blog post. My new phase looks like this:

Screenshot of the new phase

And is made up of the following steps:

  1. .NET Core Tool Installer - use SDK 2.0.0
  2. dotnet restore with my custom feed selected in the "Use packages from this VSTS/TFS feed" drop-down
  3. dotnet test with the relevant arguments to collect code coverage
  4. A custom step using ReportGenerator
  5. A step to publish the results

The problem is that dotnet test insists on trying to restore the packages itself. As I can't find a way to tell it to use a custom feed, it fails when trying to restore these packages:

D:\a\1\s\MyProject\MyProject.csproj : error NU1101: Unable to find package My.Package. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org

My main build process works fine and is able to restore the package from the custom feed. The difference is that uses the Visual Studio (i.e. not dotnet) versions of the commands:

Screenshot of the main build process

What's the right way to handle this?

Do I need to find some way to tell dotnet test about my custom feed?

Or (given that I'm running restore immediately prior) do I need to persuade it to skip the restore altogether?


Solution

  • In case anyone else has this problem, I'm sorry to say our route to resolution was to merge the two repos, effectively negating the need to use the private Nuget feed.

    We did have a bit of back and forth with a rep from MS, but didn't get to the bottom of it.