reptiletim
reptiletim

Reputation: 73

dotnet restore doesn't pull same packages as Visual Studio 2017

I've been searching for the answer to this but so far haven't found one that has the same situation I'm having.

I have a DotNet Core 1.1.4 project and when I open the .sln project file in Visual Studio 2017 it pulls down the correct packages as soon as I open it. However for the command line if I run the commmand

dotnet restore --force

it is not pulling down packages. Strangely enough if I pull down packages using

dotnet restore --packages .\packages\

it will pull down several, but it appears to be the wrong packages. For example, in one of the .csproj files in this solution there's a reference to System.Interactive.Async 3.0.3 but the package that downloads is 3.0.0. Even if I run this

dotnet restore .\folder\project.csproj

it will not pull down this package that it later complains is missing when I go to build it.

This behavior is very confusing because as far as I can tell dotnet restore is supposed to do the same job Visual Studio 2017 is doing when it restores packages. The project folders do have a packages.config file but my understanding from prior searches is that dotnet restore ignores those. I've verified this reference is in the .csproj file as well the app.config file (not sure if that matters).

If I delete the contents of the .\packages\ folder and perform the dotnet restore .\folder\project.csproj command nothing appears in the .\packages\ folder even though when I open it in Visual Studio 2017 it populates there.

Why is this behavior different, and what do I need to do to get the dotnet restore command to restore the correct packages to the correct location?

If it helps here's the result of my dotnet --info command:

.NET Command Line Tools (1.1.5)

Product Information:
Version: 1.1.5
Commit SHA-1 hash: 2b517ddd29

Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601 OS Platform: Windows
RID: win7-x64
Base Path: C:\Program Files\dotnet\sdk\1.1.5

Upvotes: 1

Views: 2209

Answers (1)

reptiletim
reptiletim

Reputation: 73

Found the answer to this. I downloaded NuGet.exe from here:

https://learn.microsoft.com/en-us/nuget/install-nuget-client-tools

Using the command

nuget restore

installs the correct packages where dotnet restore did not. I'm not sure why but it did fix my issue.

Upvotes: 2

Related Questions