Repository navigation
Closed
NuGet/NuGet.Client
#4372Labels
Category:Quality WeekIssues that should be considered for quality weekFunctionality:RestoreStyle:PackageReferenceType:Bug
Milestone
Description
@nkolev92 edit:
- Design - AssetTargetFallback is respected with dependency resolution #11460
- Implementation - conditional on design approval - Consider AssetTargetFallback when selecting transitive project/package dependencies NuGet.Client#4372
When I added netcoreapp2.0 as a target for my console application, it failed at runtime because it couldn't find an assembly that was a transitive dependency of one of my package references. When I add the package reference explicitly, it works fine. I inspected the VSMefSample.deps.json file and found that there is no mention of the transitive dependency until I add it as a direct dependency.
It would seem then, that dotnet restore (or equivalent in VS) is not fully restoring transitive dependencies when it tries to see through net45 packages to adapt them to work on netcoreapp2.0.
Repro
git clone https://github.com/AArnott/VSMefSample
cd VSMefSample
git checkout ce6bef7cc49d0c0c15b2da322ef2a78b86e6d178
cd VSMefSample
dotnet restore
dotnet run -f netcoreapp2.0
Expected
dotnet run -f netcoreapp2.0
C:\Users\andarno\source\repos\VSMefSample\VSMefSample\VSMefSample.csproj : warning NU1701: Package 'Microsoft.VisualStudio.Composition 15.3.38' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
C:\Users\andarno\source\repos\VSMefSample\VSMefSample\VSMefSample.csproj : warning NU1701: Package 'Microsoft.VisualStudio.Composition 15.3.38' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
Tree
Apple (IsJuicy: True)
Apple (IsJuicy: False)
Pear (IsDelicious: True)
Actual
dotnet run -f netcoreapp2.0
C:\Users\andarno\source\repos\VSMefSample\VSMefSample\VSMefSample.csproj : warning NU1701: Package 'Microsoft.VisualStudio.Composition 15.3.38' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
C:\Users\andarno\source\repos\VSMefSample\VSMefSample\VSMefSample.csproj : warning NU1701: Package 'Microsoft.VisualStudio.Composition 15.3.38' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.Validation, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
at VSMefSample.Program.Main(String[] args)
Version info
dotnet --info
.NET Command Line Tools (2.0.2-vspre-006949)
Product Information:
Version: 2.0.2-vspre-006949
Commit SHA-1 hash: 23fc6ec23d
Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.0.2-vspre-006949\
Microsoft .NET Core Shared Framework Host
Version : 2.0.0
Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d
Reacted by Ran Sagy, Joseph Musser, Claire Novotny, Pavel Anikhouski, Terrence Jones, Ivan Bianko and Sandy Armstrong
Metadata
Metadata
Assignees
Labels
Category:Quality WeekIssues that should be considered for quality weekFunctionality:RestoreStyle:PackageReferenceType:Bug
Activity
Workaround NuGet/Home#5957
rrelyea commentedon Oct 2, 2017
Assigned to @mishra14 in backlog as P1. Seems like ATF should work identically to non-ATF restores.
cc @emgarten
mishra14 commentedon Nov 30, 2017
@AArnott are you still facing this issue with latest VS preview build?
AArnott commentedon Nov 30, 2017
@mishra14 Yes, it still repros with the latest int.preview build:
[-]netcoreapp2.0 project's ProjectName.deps.json is missing transitive dependency, resulting in runtime failure[/-][+]Project A referencing package B via AssetTargetFallback, doesn't use that same AssetTargetFallback to pull B's dependency package C[/+]rrelyea commentedon Dec 1, 2018
retitled: Project A referencing package B via AssetTargetFallback, doesn't use that same AssetTargetFallback to pull B's dependency package C
@AArnott likely had a scenario where A called an API in B and B called an API in C so he ran into a runtime issue.
When I tried creating the same situation...and had A call B and C, it was a compile time error.
41 remaining items
nkolev92 commentedon Dec 17, 2021
Design out at #11460.
Once that's been reviewed and approved, NuGet/NuGet.Client#4372 is merge quality already.
nkolev92 commentedon Jan 31, 2022
This should land in 6.2/6.0.200/17.2.
Not inserted yet, but should be in preview 1 of 17.2