Skip to content

Project A referencing package B via AssetTargetFallback, doesn't use that same AssetTargetFallback to pull B's dependency package C #5957

Closed
NuGet/NuGet.Client
#4372

Description

@AArnott

@nkolev92 edit:


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

Activity

  1. added a commit that references this issue on Sep 29, 2017
  2. added this to the Backlog milestone on Oct 2, 2017
  3. added
    Priority:2
    on Oct 2, 2017
  4. rrelyea commented on Oct 2, 2017

    @rrelyea
    Contributor

    Assigned to @mishra14 in backlog as P1. Seems like ATF should work identically to non-ATF restores.
    cc @emgarten

  5. mishra14 commented on Nov 30, 2017

    @mishra14
    Contributor

    @AArnott are you still facing this issue with latest VS preview build?

  6. AArnott commented on Nov 30, 2017

    @AArnott
    ContributorAuthor

    @mishra14 Yes, it still repros with the latest int.preview build:

    dotnet --info
    .NET Command Line Tools (15.5.0-preview-007044)
    
    Product Information:
     Version:            15.5.0-preview-007044
     Commit SHA-1 hash:  278cbf6c44
    
    Runtime Environment:
     OS Name:     Windows
     OS Version:  10.0.16299
     OS Platform: Windows
     RID:         win10-x64
     Base Path:   C:\Program Files\dotnet\sdk\15.5.0-preview-007044\
    
    Microsoft .NET Core Shared Framework Host
    
      Version  : 2.0.3
      Build    : a9190d4a75f4a982ae4b4fa8d1a24526566c69df
    
  7. removed their assignment
    on Aug 13, 2018
  8. changed the title [-]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[/+] on Dec 1, 2018
  9. rrelyea commented on Dec 1, 2018

    @rrelyea
    Contributor

    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.

  10. removed this from the Backlog milestone on Dec 1, 2018
  11. 41 remaining items

  12. added
    Priority:1
    and removed
    Priority:2
    on Nov 22, 2021
  13. added this to the Sprint 2021-12 milestone on Nov 22, 2021
  14. added and removed
    Priority:1
    on Nov 22, 2021
  15. added
    Category:Quality Week
    and removed
    Category:Quality Week
    on Dec 2, 2021
  16. nkolev92 commented on Dec 17, 2021

    @nkolev92
    Member

    Design out at #11460.

    Once that's been reviewed and approved, NuGet/NuGet.Client#4372 is merge quality already.

  17. added
    Category:Quality Week
    on Jan 3, 2022
  18. nkolev92 commented on Jan 31, 2022

    @nkolev92
    Member

    This should land in 6.2/6.0.200/17.2.

    Not inserted yet, but should be in preview 1 of 17.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Category:Quality WeekFunctionality:RestoreStyle:PackageReferenceType:Bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions