dotnet / dotnet/project-system

NuGet restore differs between VS and command line

Open
#6,984 3 comments 0 reactions 0 assignees View on GitHub
Feature-NuGet Triage-Investigate
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

**Visual Studio Version**: 16.8.4

**Summary**:

Under certain circumstances, package restore in VS can produce different results from those on the command line.

**Steps to Reproduce**:

1. Create a project:
```xml



netcoreapp3.1;net5.0






```
2. Let VS restore packages.
Version 11.0.2 is restored for both target frameworks.
3. Trigger a command line restore with `msbuild -t:restore`.
`net5.0` is restored using version 11.0.2, while `netcoreapp3.1` is restored with 12.0.3.

The results of the restore can be seen in both the dependencies tree, and in `project.assets.json`.

**Expected Behavior**:

Consistent restore behaviour between VS and command line.

**Actual Behavior**:

Different behaviour.

**User Impact**:

Having conditions defined this way in the project is not common, but if this situtation is encountered it may cause code to compile in one environment and not in another, depending upon how restore was completed.

(Originally reported in [this feedback ticket](https://developercommunity2.visualstudio.com/t/Why-condition-is-ignored-under-multi-tar/1324578).)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.