Given the following file packages.config:
<packages>
<package id="package.a" version="X.Y.Z" />
<package id="package.b" version="A.B.C" />
</packages>
I used to run the following command:
nuget.exe restore .\packages.config -PackagesDirectory .\Dependencies
That downloads the specified packages into the Dependencies folder without having a csproj file.
I am looking for a way to do the same with the dotnet cli (because I need it to run on non-windows environment), but I can't find how.
I tried several things without success:
dotnet restore --config-file .\packages.config --packages dependencies
dotnet restore .\packages.config --packages dependencies
dotnet nuget restore .\packages.config -PackagesDirectory .\dependencies\
The closest I can get was by replacing my old packages.config with a project file with PackageReference (I named it dependencies.config):
<?xml version="1.0"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="package.a" Version="x.y.z" />
</ItemGroup>
</Project>`
And running the following command:
dotnet restore .\dependencies.config --packages .\dependencies\
But doing so, I have to specify a TargetFramework property and the command automatically download some other packages (microsoft.netcore.platforms and netstandard.library). I can live with that but I would like to know if I was missing something.