The question delves into the distinction between two NuGet restore commands within an Azure build pipeline:
task: NuGetCommand@2 inputs: restoreSolution: '$(solution)’
This task is utilized for installing and updating NuGet package dependencies, or packaging and publishing NuGet packages. It employs NuGet.exe and functions with .NET Framework applications.
task: DotNetCoreCLI@2 inputs: command: 'restore' projects: '$(solution)' feedsToUse: 'select'
This task utilizes dotnet restore, which internally uses a version of NuGet.exe packaged with the .NET Core SDK. dotnet restore solely restores packages specified in the .NET Core project’s .csproj files.
The difference lies in the scope of dependency resolution:
Regarding feedsToUse: ‘select’, it indicates selecting packages cached in Azure Artifacts with upstream sources. This is essential for restoring packages from an external custom feed. Conversely, when such packages aren’t required, the path to the .csproj file(s) should be specified directly in the projects parameter, as shown in the latter example:
- task: DotNetCoreCLI@2 displayName: 'dotnet restore' inputs: command: restore projects: '**/*.csproj'
This specifies that all .csproj files within the repository should be considered for package restoration.
For further details and syntax, relevant links from Microsoft documentation are provided.