没有依赖项的 Nuget 包

Nuget package that has no dependents

我正在为 .NET 项目使用 mspec (machine specification) 单元测试框架。

我使用 nuget 获取所有必需的包。

有一个特定的包,它不是代码的一部分。它是 mspec 的 "Console" 应用程序,我曾经从命令行从 VS 外部 运行 我的单元测试。 (It is located here): 当我使用 Nuget 安装它时,Nuget 不会将它添加到测试项目内的正常 "packages.config" 文件中。 它正在将其添加到“.nuget”文件夹中存在的 "packages.config" 文件夹中。

但是当我的同事打开项目并构建时,他的 VS 没有得到那个包。

如何改变它,强制 VS 自动获取包?

Nuget doesn't add it to the normal "packages.config" file inside of the Test project. It is adding it to a "packages.config" folder that exists in ".nuget" folder.

那是因为您使用的是 NuGet 2.7 或更高版本,并且有一个解决方案仍然由旧包还原方法配置"MSBuild-integrated restore"。这将导致构建失败并出现错误,指出您尚未同意恢复包。 Visual Studio 将跳过自动包还原。

How to change that, to force VS to get the package automatically?

要解决此问题,您可以按照以下步骤操作:

  1. 关闭Visual Studio以避免文件潜在的文件锁定和冲突。

  2. 如果使用 TFS:从解决方案的 .nuget 文件夹中删除 nuget.exe 和 nuget.targets,并从解决方案工作区中删除这些文件。一种。保留 nuget.config 和 disableSourceControlIntegration 设置,如 Omitting packages with Team Foundation Version Control.

  3. 中所述
  4. 如果不使用 TFS:从解决方案和解决方案工作区中删除 .nuget 文件夹。

  5. 编辑解决方案中的每个项目文件,删除 元素,并删除对 nuget.targets 文件的所有引用。更详细的信息可以参考Migrating to automatic restore.