Open up the .csproj file for the .Net Framework project that is hosting the .Net standard library and add this line within the first <PropertyGroup>
like this to change the restore style:
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
Check out this article by Scott Hanselman about the cause of the issue and the fix.
From the article:
The "full" Framework projects are using the older .csproj format and by default, they use package.config to manage dependencies. The newer projects can reference Packages as first-class references. So we need to tell ALL projects in this solution to manage and restore their packages as "PackageReferences."
EDIT:
This fix worked perfectly for me on a new project. When I apply it to the csproj before I restore packages in that new project, nuget gets the correct references.
When applying this to an existing project, it doesn't work. The libraries that are referenced inside the .net standard class library are not pulled by nuget and therefore, it would still throw the same error.
To fix it try this:
- Open the csproj. You will notice your library looking like that
<Reference Include="yournetstandardlibrary, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\yournetstandardlibrary\lib\netstandard2.0\.dll</HintPath>
</Reference>
- Delete that reference
- Add this reference instead
<ItemGroup>
<PackageReference Include="yournetstandardlibrary">
<Version>1.0.1</Version>
</PackageReference>
</ItemGroup>