Visual Studio VS2017 v15.9.3
Nuget v4.7.1.5393
We are trying to migrate our project to use Nuget PackageReference. When using packages.config Nuget properly determines that the package matches the project's target framework. But when we try to migrate to PackageReference Nuget throws an error that the package does not support the target framework.
Packages.config: package id="xxx.yyy" version="7.7.7" targetFramework="net462"
Errors when attempting to use PackageReference:
NU1202: Package xxx.yyy 7.7.7 is not compatible with net462 (.NETFramework,Version=v4.6.2). Package xxx.yyy 7.7.7 does not support any target frameworks.
NU1202: Package xxx.yyy 7.7.7 is not compatible with net462 (.NETFramework,Version=v4.6.2) / win. Package xxx.yyy 7.7.7 does not support any target frameworks.
NU1202: Package xxx.yyy 7.7.7 is not compatible with net462 (.NETFramework,Version=v4.6.2) / win-x64. Package xxx.yyy 7.7.7 does not support any target frameworks.
NU1202: Package xxx.yyy 7.7.7 is not compatible with net462 (.NETFramework,Version=v4.6.2) / win-x86. Package xxx.yyy 7.7.7 does not support any target frameworks.
Package restore failed. Rolling back package changes for 'ClassLibrary1'.
12/7/2018 Update.
There appears to be multiple issues with how we're creating the package and how Nuget is interpreting it when using packageReference mode.
The first is how we're specifying the target. Nuget in package.config mode is able to determine that target="lib\net462\project1" targets .Net 4.62 framework but when Nuget is in PackageReference mode target must be changed to just target="lib\net462".
The other problem is that in package.config mode nuget was more forgiving when you had multiple architectures (x86,x84,AnyCpu), you could just include all of them in the tags.
Also, don't even think about trying to have projects in a solution where some use packages.config and others use packageReference. For that matter don'try to have to instances of VS running with different settings for the default package management format.
We've found that we've had to delete the obj folders in the solution and restart VS to clear up some of these issues while trying to convert.