Nuget task is used to install and update NuGet package dependencies, or package and publish NuGet packages. Uses NuGet.exe
and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task.
dotnet restore
internally uses a version of NuGet.exe
that is packaged with the .NET Core SDK. dotnet restore
can only restore packages specified in the .NET Core project .csproj
files. If you also have a Microsoft .NET Framework project in your solution or use package.json
to specify your dependencies, you must also use the NuGet task to restore those dependencies.
In .NET Core SDK version 2.0 and newer, packages are restored automatically when running other commands such as dotnet build
. However, you might still need to use the .NET Core task to restore packages if you use an authenticated feed.
Regarding feedsToUse: 'select'
, when the packages cached in Azure Artifacts with upstream sources, you should use feedsToUse: 'select'
, and specify vstsFeed: xxxx
. Check the following syntax (If you want to restore packages from an external custom feed, use feedsToUse: 'config'
, and specify nugetConfigPath
and externalFeedCredentials
):
#feedsToUse: # Options: select, config
#vstsFeed: # Required when feedsToUse == Select
#nugetConfigPath: # Required when feedsToUse == Config
#externalFeedCredentials: # Optional
When you don't need packages cached in Azure Artifacts, or from an external custom feed, use the following syntax (You should specify the path to the csproj file(s) to use in projects
, not the path to the solution):
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: '**/*.csproj'
Useful links: