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

[Bug]: Nuget.Client does not work for .NETFramework < 4.7.2 #11335

Open
gabriela-lungu-uip opened this issue Oct 26, 2021 · 1 comment
Open
Labels
Functionality:SDK The NuGet client packages published to nuget.org Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:Bug

Comments

@gabriela-lungu-uip
Copy link

gabriela-lungu-uip commented Oct 26, 2021

NuGet Product Used

MSBuild.exe

Product Version

NuGet.Frameworks package 5.11.0

Worked before?

NuGet.Frameworks package 5.8.0

Impact

I'm unable to use this version

Repro Steps & Context

Repro Steps: .NETFramework4.6.1 Console Application:

    using NuGet.Commands;
    using NuGet.Frameworks;
    using System.Collections.Generic;
    class Program
    {
        static void Main()
        {
            AssetTargetFallbackUtility.GetFallbackFramework(NuGetFramework.AnyFramework,
                new List<NuGetFramework>() { NuGetFramework.AnyFramework },
                new List<NuGetFramework>() { NuGetFramework.AnyFramework });
        }
    }

throws:

System.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'Void NuGet.Frameworks.FallbackFramework..ctor(NuGet.Frameworks.NuGetFramework, System.Collections.Generic.IReadOnlyList`1<NuGet.Frameworks.NuGetFramework>)'.
  Source=NuGet.Commands
  StackTrace:
   at NuGet.Commands.AssetTargetFallbackUtility.GetFallbackFramework(NuGetFramework projectFramework, IEnumerable`1 packageTargetFallback, IEnumerable`1 assetTargetFallback)
   at Nuget5._11Issue.Program.Main() in ...\Program.cs:line 10

Context: I have encountered this problem while using Restore from Nuget.Commands after upgrading to version=5.11.0 from 5.8

Investigation: Nuget.Frameworks 5.11 targets .NETFramework 4.0, .NETFramework 4.7.2 and .NETStandard 2.0. A project that targets .NET461 will use the Nuget.Frameworks for .NETFramework 4.0 because it's the closest version. On .NETFramework 4.0 the reported missing method is indeed missing.
Nuget.Frameworks 5.8 targets also .NETFramework 4.5 which for a NET461 project would be the closest version and on this version the method is not missing.

Verbose Logs

No response

@dominoFire
Copy link
Contributor

Reproduced.

By looking at code, we use IList instead of IReadOnlyList when target framework is net40:

https://github.com/NuGet/NuGet.Client/blob/c14b85a00c03933c708c7d38fefeda9898a21488/src/NuGet.Core/NuGet.Frameworks/FallbackFramework.cs#L35

Would you be able to use a newer target framework ?

@zivkan zivkan added Functionality:SDK The NuGet client packages published to nuget.org Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. and removed Functionality:Restore labels Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:SDK The NuGet client packages published to nuget.org Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:Bug
Projects
None yet
Development

No branches or pull requests

5 participants