DotNetCoreCLI 还原与 NuGetCommand 还原

DotNetCoreCLI restore vs NuGetCommand restore

我试图了解 Azure 构建管道中两个 nuget 恢复命令之间的区别:

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    projects: '$(solution)'
    feedsToUse: 'select'

我试图理解,但在 Microsoft 页面上我看到的是两者都可以使用 - 我真的找不到任何说明差异的内容。 (feedsToUse: 'select'这个说法我也不是很懂)

还有,作为第二个问题,后者和

有什么区别
- task: DotNetCoreCLI@2
  inputs:
    command: restore
    projects: '**/*.csproj'

鉴于解决方案包含所有 csproj(并且仅包含 csproj)?

Nuget任务用于安装和更新NuGet包依赖,或者打包发布NuGet包。使用 NuGet.exe 并使用 .NET Framework 应用程序。 对于 .NET Core 和 .NET Standard 应用,使用 .NET Core 任务

dotnet restore 内部使用与 .NET Core SDK 打包在一起的 NuGet.exe 版本。 dotnet restore 只能恢复 .NET Core 项目 .csproj 文件中指定的包。如果您的解决方案中还有 Microsoft .NET Framework 项目或使用 package.json 指定依赖项,则还必须使用 NuGet 任务来恢复这些依赖项。

在 .NET Core SDK 2.0 版及更新版本中,当 运行 其他命令(例如 dotnet build 时,包会自动恢复。但是,如果您使用经过身份验证的提要,您可能仍需要使用 .NET Core 任务来恢复包。

关于feedsToUse: 'select',当使用上游源缓存在Azure Artifacts中的包时,您应该使用feedsToUse: 'select',并指定vstsFeed: xxxx。检查以下语法(如果要从外部自定义提要恢复包,请使用 feedsToUse: 'config',并指定 nugetConfigPathexternalFeedCredentials):

#feedsToUse: # Options: select, config
#vstsFeed: # Required when feedsToUse == Select
#nugetConfigPath: # Required when feedsToUse == Config
#externalFeedCredentials: # Optional

当您不需要缓存在 Azure Artifacts 中或来自外部自定义源的包时,请使用以下语法(您应该指定要在 projects 中使用的 csproj 文件的路径,不是解决方案的路径):

- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: restore
    projects: '**/*.csproj'

有用的链接: