简体   繁体   English

NuGet 2.8.6导致对.NET 4.5+的依赖?

[英]NuGet 2.8.6 causing dependency on .NET 4.5+?

Recently started getting errors on build machines using latest nuget.exe (2.8.6) 最近开始使用最新的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'.

Exact same command / source tree restores perfectly using nuget.exe 2.8.5 使用nuget.exe 2.8.5完全恢复完全相同的命令/源代码树

Build machine is Windows 2008 R2, .NET 4.0 (no 4.5 updates allowed on this build image) and VS 2010. Basically, we have a number of build machines that are configured for specific combinations (Windows, .NET, Visual Studio). 构建机器是Windows 2008 R2,.NET 4.0(此构建映像上不允许4.5更新)和VS 2010.基本上,我们有许多为特定组合(Windows,.NET,Visual Studio)配置的构建机器。

It feels like the 2.8.6 build took a dependency on .NET 4.5 that breaks on machines without it. 感觉就像2.8.6版本依赖于.NET 4.5,它在没有它的机器上中断。

I raised this as an issue but, from what I have been told, there are no plans to fix it: https://github.com/NuGet/Home/issues/1611 我提出这是一个问题,但据我所知,没有计划修复它: https//github.com/NuGet/Home/issues/1611

The workaround is to use the NuGet.CommandLine 2.8.5 package which can be found on nuget.org: 解决方法是使用Nuget.CommandLine 2.8.5软件包,该软件包可以在nuget.org上找到:

  1. First download the package by using the command Install-Package NuGet.CommandLine -Version 2.8.5 in the Package Manager Console . 首先使用Install-Package NuGet.CommandLine -Version 2.8.5 包管理器控制台中的Install-Package NuGet.CommandLine -Version 2.8.5命令下载程序包
  2. Then get the executable ( nuget.exe ) from the package's installation folder and use it to replace the NuGet 2.8.6 executable that you are currently using (ie in the .nuget\\ folder). 然后从软件包的安装文件夹中获取可执行文件( nuget.exe ),并使用它来替换当前使用的NuGet 2.8.6可执行文件(即在.nuget\\文件夹中)。
  3. You may want to also check in the new executable into source control. 您可能还想将新的可执行文件签入源代码管理中。

In case you use TeamCity there's a way to fix this issue without changing the source code. 如果您使用TeamCity,有一种方法可以在不更改源代码的情况下解决此问题。

Go to TeamCity → Administration → Integrations → NuGet and use button "Fetch NuGet" to get 2.8.5 or 3.3.0. 转到TeamCity→管理→集成→NuGet,然后使用“获取NuGet”按钮获得2.8.5或3.3.0。

Make it default if you want to use it for all projects or setup NuGet restore step to use this specific version. 如果要将其用于所有项目或设置NuGet还原步骤以使用此特定版本,请将其设置为默认值。

在TeamCity中设置NuGet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM