蛋糕 NuGetRestore 找不到 nuget.exe

Cake NuGetRestore Could not locate nuget.exe

我创建了简单的 .NET5 控制台应用程序,可以使用“dotnet restore”和“dotnet 运行”成功 运行。应用程序正在使用一个包 Newtonsoft.Json.

我想使用 NuGetRestore() 恢复 NuGet 包,但结果是“无法找到 nuget.exe”。 我在 1.1.0 版和默认配置中使用 Cake .NET 工具。

据我所知,以前我使用 Cake 1.0.0 之前的版本 nuget.exe 被下载到 'tools' 文件夹。

我错过了什么? Cake如何确定nuget.exe是downloaded/provided?

为了将 NuGet 工具下载到 tools 文件夹,您需要在 Cake 构建脚本中包含 NuGet.CommandLine 包。例如

#tool nuget:?package=NuGet.CommandLine&version=5.9.1

相关信息:

Cake 本身从未下载过 nuget.exe。构建脚本中的 example bootstrapper for Cake Runner for .NET Framework does this in certain conditions. Example bootstrapper for Cake .NET Tool does not download nuget.exe and you need to make yourself sure to have it available, either by updating the bootstrapper, using the tool prepocessor directive,或 Cake 之外的任何其他机制。