Search code examples
c#nuget.net-standard

Wrong net-standard library version is restored by nuget/used by build


I have a solution where projects reference netcoreapp2.1, netstandard 2.0, net472, as targetframeworks.

Some have

    <TargetFrameworks>netstandard2.0;net472</TargetFrameworks>

others have

    <TargetFrameworks>netstandard2.0</TargetFrameworks>

others have

    <TargetFrameworks>netcoreapp2.1</TargetFrameworks>

After I deleted the Nugetfallback folder because of unrelated problems, suddenly my build fails with hundreds of errors about netstandard library classes no longer being found, e.g.

C:\Windows\system32\config\systemprofile\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref\System.Net.WebSockets.dll' could not be found.

what my build does basically boils down to:

nuget.exe locals all -clear
nuget.exe restore {MY_SOLUTION}
msbuild /restore {MY_SOLUTION}

Looking into the nuget/packages folder, I can see that the netstandard library exists after nuget restore, but in the ...\netstandard.library\2.0.0\ folder, and not in the ...\netstandard.library\2.0.3\

I've tried

  • deleting the nuget cache manually
  • using an explicit packagereference to the netstandardlibrary 2.0.3 in my csproj files,

but this hasn't helped.

The Solution Explorer in Visual Studio shows me that in the solution there are only dependencies to netstandard 2.0.3, none to 2.0.0

all the relevant packages.config files show

<package id="NETStandard.Library" version="2.0.3" targetFramework="net462" />

Why is the wrong version of the netstandard.library retrieved by nuget (2.0.0 instead of 2.0.3). Where in my solution could I configure/change this? Could this be because of other libraries where I have the wrong version as dependency?

Thanks!


Solution

  • Reinstalling nuget, and installing a newer version of the dotnet SDK helped. No idea what caused it.