Does NuGet 2.8.6 cause dependency on .NET 4.5+?

Recently started getting errors on build machines using the latest nuget.exe (2.8.6)

.nuget\nuget restore MySolution.sln Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 

The exact tree of commands / sources is restored using nuget.exe 2.8.5

The machine build is Windows 2008 R2, .NET 4.0 (4.5 updates are not allowed on this build image) and VS 2010. Basically, we have several build machines that are configured for certain combinations (Windows, .NET, Visual Studio) .

Build 2.8.6 seemed to depend on .NET 4.5, which crashed into machines without it.

+5
source share
2 answers

I raised this as a problem, but from what I was told, there are no plans to fix it: https://github.com/NuGet/Home/issues/1611

A workaround is to use the NuGet.CommandLine 2.8.5 package, which can be found on nuget.org:

  • First download the package using the Install-Package NuGet.CommandLine -Version 2.8.5 in the Install-Package NuGet.CommandLine -Version 2.8.5 Console .
  • Then, get the executable file ( nuget.exe ) from the package installation folder and use it to replace the NuGet 2.8.6 executable file that you are currently using (for example, in the .nuget\ folder).
  • You might also want to check out the new executable in the original control.
+2
source

If you use TeamCity, you can fix this problem without changing the source code.

Go to TeamCity β†’ Administration β†’ Integration β†’ NuGet and use the β€œFetch NuGet” button to get 2.8.5 or 3.3.0.

Do this by default if you want to use it for all projects or configure the NuGet recovery step to use this particular version.

NuGet setup in TeamCity

+1
source

All Articles