Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
AArnott opened this issue Sep 29, 2017 · 13 comments · Fixed by NuGet/NuGet.Client#4372
Assignees
Labels

Comments

@AArnott
Copy link
Contributor

AArnott commented Sep 29, 2017

@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
AArnott added a commit to AArnott/VSMefSample that referenced this issue Sep 29, 2017
@mishra14 mishra14 added this to the Backlog milestone Oct 2, 2017
@rrelyea rrelyea added the Priority:2 Issues for the current backlog. label Oct 2, 2017
@rrelyea
Copy link
Contributor

rrelyea commented Oct 2, 2017

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

@mishra14
Copy link
Contributor

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

@AArnott
Copy link
Contributor Author

AArnott commented Nov 30, 2017

@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

@mishra14 mishra14 removed their assignment Aug 13, 2018
@rrelyea rrelyea 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 Dec 1, 2018
@rrelyea
Copy link
Contributor

rrelyea commented 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.

@rrelyea
Copy link
Contributor

rrelyea commented Dec 1, 2018

@nkolev92 - please address...this is likely more important with netcoreapp3 increased usage.
if you can balance to a new member of team, that is fine also.

@rrelyea
Copy link
Contributor

rrelyea commented Dec 1, 2018

workaround is to manually reference C as a top level package reference, I believe.

@clairernovotny
Copy link

Bump?

clairernovotny pushed a commit to NuGetPackageExplorer/NuGetPackageExplorer that referenced this issue Jun 1, 2019
clairernovotny pushed a commit to NuGetPackageExplorer/NuGetPackageExplorer that referenced this issue Jun 1, 2019
@aortiz-msft aortiz-msft added Priority:1 High priority issues that must be resolved in the current sprint. and removed Priority:2 Issues for the current backlog. labels Oct 9, 2020
@nkolev92 nkolev92 added Priority:2 Issues for the current backlog. and removed Priority:1 High priority issues that must be resolved in the current sprint. labels Jul 6, 2021
@KirillOsenkov
Copy link

This is a major adoption blocker for .NET and causing unnecessary friction in the ecosystem. Would be nice to prioritize this please.

@clairernovotny do you know anyone on the NuGet team who could perhaps champion this? ;)

@nkolev92 nkolev92 added Priority:1 High priority issues that must be resolved in the current sprint. and removed Priority:2 Issues for the current backlog. labels Nov 22, 2021
@nkolev92 nkolev92 added this to the Sprint 2021-12 milestone Nov 22, 2021
@nkolev92 nkolev92 added Priority:1.5 and removed Priority:1 High priority issues that must be resolved in the current sprint. labels Nov 22, 2021
@nkolev92 nkolev92 added Category:Quality Week Issues that should be considered for quality week Category:Customer Sprint and removed Priority:1.5 Category:Quality Week Issues that should be considered for quality week labels Dec 2, 2021
@nkolev92
Copy link
Member

Design out at #11460.

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

@nkolev92 nkolev92 added the Category:Quality Week Issues that should be considered for quality week label Jan 3, 2022
@nkolev92
Copy link
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
Labels
Projects
None yet
9 participants