Regression in nuget restore for sfproj from sdk31 -> sdk60
See original GitHub issueDoing 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
- git clone https://github.com/aaronla-ms/bug-repros.git
- cd repro-dotnetsdk6
- setup.cmd
- repro.cmd
expected
restore succeeds on both dotnetsdk31 and dotnetsdk60
actual
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.
versions
[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:
- Created 2 years ago
- Comments:12 (7 by maintainers)
Top GitHub Comments
Beat me by 43s 😄 You are on spot, that’s where the change happened.
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.