How to clear the nuget cache in a msbuild task?

Viewed 22

I'm trying to set up the following build scenario that must work in both visual studio and azure devops.

  1. Clear the nuget cache
  2. Switch the nuget.config file upo the selected configuration to be built.
  3. Build a specific project in the solution.

I do not know how to successfully achieve the first step.

I have modified my project file, adding the following:

<Target Name ="Clear Nuget Cache" BeforeTargets="PreBuildEvent">
    <Exec Command="nuget locals all -clear"/>
</Target>

I think the command is right but the Exec Task is unable to find the nuget binaries:

8>'nuget' is not recognized as an internal command
8> or external, an executable program or a batch file.
8> error MSB3073: Command "nuget locals all -clear" exited with code 9009.

Is there a msbuild variable to get the nuget directory?

0 Answers
Related