首页 > 解决方案 > Azure DevOps,使用 website.sln 文件时为“Visual Studio Build”恢复 NuGet 包

问题描述

我似乎无法为我的 DevOps 构建管道找到正确的设置,以使其能够恢复 NuGet 包,以便构建过程能够找到它们。

我遇到的第一个问题是默认设置将还原指向我的 .sln 文件,导致它打印出来:

Nothing to do. None of the projects in this solution specify any packages for NuGet to restore.

这是一个 Visual Studio 2017 网站 .sln 文件,不包含有关 NuGet 的信息,也没有其他答案建议的 .csproj。

我通过将其指向 packages.config 文件解决了这个问题。现在还原过程确实找到了所需的包,但似乎没有将它们放在“Visual Studio Build”构建过程可以找到它们的地方。

Error CS0246: The type or namespace name 'Nest' could not be found (are you missing a using directive or an assembly reference?)

我查看了构建过程部分,但找不到任何有用的东西,因为唯一的参考标记为:

此选项已弃用。若要还原 NuGet 包,请添加 NuGet 工具安装程序

这就是我已经在尝试做的事情。我曾尝试将 NuGet 还原的目标目录移动到bin其他地方,但这并没有什么不同。

恢复文件后,我是否缺少移动文件的步骤?或者我需要在构建时传递一个参数来告诉它包文件在哪里?

标签: nugetazure-devopsnuget-package-restore

解决方案


Azure DevOps,使用 website.sln 时为“Visual Studio Build”还原 NuGet 包?

您应该在构建管道期间使用 NuGet 安装程序任务。

在此处输入图像描述

不推荐使用“还原 NuGet 包”选项:

在此处输入图像描述

此选项已弃用。要还原 NuGet 包,请在构建之前添加 NuGet 安装程序步骤

因此,要解决此问题,请尝试使用NuGet 安装程序任务,转到“包”选项卡,然后添加 NuGet 还原任务。

您可以指定packages.config.sln文件来恢复包。指定packages.config时,还需要提供 Destination 目录,默认值为/packages

在此处输入图像描述


推荐阅读