Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Regression in nuget restore for sfproj from sdk31 -> sdk60

See original GitHub issue

Doing a trial run of building our repo on dotnetsdk 6.0 preview 3, and getting restore failures in a few projects. Self contained repro attached. Note that we’re currently on latest LTS sdk: 3.1.409.

It appears that dotnet restore is not processing TargetFramework correctly in 6.0 inside an old-style project (e.g. sfproj), when that sfproj has been converted to use PackageReference instead of packages.config.

This is a regression from previous (LTS) version.

Minimal repro

  1. git clone
  2. cd repro-dotnetsdk6
  3. setup.cmd
  4. repro.cmd


restore succeeds on both dotnetsdk31 and dotnetsdk60


restore fails on just dotnetsdk60. Error message as follows:

Determining projects to restore… C:\repos\aaronla-ms\bug-repros\repro-dotnetsdk6\repro-dotnetsdk6.csproj : error NU1202: Package Bond.Core.CSharp 9.0.3 is not compatible with net40 (.NETFramework,Version=v4.0). Package Bond.Core.CSharp 9.0.3 supports: C:\repos\aaronla-ms\bug-repros\repro-dotnetsdk6\repro-dotnetsdk6.csproj : error NU1202: - net45 (.NETFramework,Version=v4.5) C:\repos\aaronla-ms\bug-repros\repro-dotnetsdk6\repro-dotnetsdk6.csproj : error NU1202: - net46 (.NETFramework,Version=v4.6) C:\repos\aaronla-ms\bug-repros\repro-dotnetsdk6\repro-dotnetsdk6.csproj : error NU1202: - netstandard1.0 (.NETStandard,Version=v1.0) C:\repos\aaronla-ms\bug-repros\repro-dotnetsdk6\repro-dotnetsdk6.csproj : error NU1202: - netstandard1.3 (.NETStandard,Version=v1.3) C:\repos\aaronla-ms\bug-repros\repro-dotnetsdk6\repro-dotnetsdk6.csproj : error NU1202: - netstandard1.6 (.NETStandard,Version=v1.6)

It appears that nuget.targets is incorrectly determining the project to be net40, when the project does have TargetFramework=net462 set.


[git: main] aaronla@aaronla-r:repro-dotnetsdk6$ packages\dotnetsdk31\dotnet.exe --version 3.1.409

[git: main] aaronla@aaronla-r:repro-dotnetsdk6$ packages\dotnetsdk60\dotnet.exe --version 6.0.100-preview.3.21202.5

[git: main] aaronla@aaronla-r:repro-dotnetsdk6$ ver

Microsoft Windows [Version 10.0.19043.985]

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

nkolev92commented, May 17, 2021

NuGet/NuGet.Client#3548 looks related, which is a change in NuGet 5.8.

Beat me by 43s 😄 You are on spot, that’s where the change happened.

nkolev92commented, May 18, 2021

Discussed offline:

TargetFrameworkMoniker is what NuGet reads.

All these props have default values, so it’s possible that in some situations even setting 1 property such as TargetFrameworkVersion is sufficient to make everything work.

TargetFramework is not a property that NuGet parses, but the SDK can translate it into a valid TFM if the project is SDK based.

I’m not familiar with particular documentation around this topic.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SFPROJ won't build in DevOps
I have some sfproj files that build locally but fail to build in Azure DevOps. ... I see that Nuget Restore restores the...
Read more >
Azure DevOps build pipeline for Service Fabric Guest .Net ...
I have a custom Powershell script in my service fabric repositories for this. It does a separate nuget restore for .sfproj.
Read more >
The Package target gets executed when the MSBuild command above (which is what your ... NET Regression in nuget restore for sfproj from...
Read more >
Regression in nuget restore for sfproj from sdk31 -> sdk60 #17671 - GitHub WitrynaCrmSdk. Deployment Prefix Reserved .NET Framework 4.6.2 .
Read more >
NuGet Package Restore
NuGet Package Restore restores all of a project's dependencies that are listed in either a project file or a packages.config file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found