I was having similar issue trying to publish a Nuget Artifact in Azure Devops and had to add the same restore task. The code below worked for me when running before the "nuget pack" task. You can hardcode parameter values to suit you but they are passed in from parent in below example.
parameters:
- name: projectName
type: string
- name: projectFolder
type: string
- name: configuration
type: string
default: release
jobs:
- job: ArtifactsPublish
pool: #Default
vmImage: $(linuxImageName)
steps:
- task: NuGetAuthenticate@0
displayName: 'NuGet Authenticate'
- task: DotNetCoreCLI@2
displayName: 'Nuget Restore'
inputs:
command: 'restore'
projects: '${{ parameters.projectFolder }}/*.csproj'
feedsToUse: 'select'
vstsFeed: '<FEED_GUID>'
- task: DotNetCoreCLI@2
displayName: 'NuGet pack'
inputs:
command: pack
#nobuild: true
versioningScheme: byPrereleaseNumber
packagesToPack: '**/${{ parameters.projectName }}.csproj'
#packagesToPack: '**/${{ parameters.projectName }}.nuspec'
configuration: '${{ parameters.configuration }}'
buildProperties: 'Description=${{ parameters.projectName }}'
#buildProperties: 'folder=$(Pipeline.Workspace)/${{ parameters.projectName }}'
#packDestination: '$(Pipeline.Workspace)/${{ parameters.projectName }}'
packDirectory: '$(Build.ArtifactStagingDirectory)'
- task: NuGetCommand@2
displayName: 'NuGet push'
inputs:
command: push
#packagesToPush: '$(Pipeline.Workspace)/${{ parameters.projectName }}/**/*.nupkg;!$(Pipeline.Workspace)/${{ parameters.projectName }}/**/*.symbols.nupkg'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
publishVstsFeed: '<FEED_GUID>'
This may not be the best solution but also something you can try if you are using Azure Pipelines is to click on the "Settings" hyperlink on the Edit UI and it should allow you to select a feed from your project granted correct permissions are in place.
<FEED_GUID> is a placeholder for the GUID of our private Nuget feed.
Using Azure DevOps UI:

I hope this helps. Good luck!