While creating Nuget package through Azure DevOps pipeline and adding the package to the Artifacts, you might get the following or similar errors:
error NU1301: Unable to load the service index for source https://pkgs.dev.azure.com/MyEnterpriseApps/_packaging/SchemaRegistry%40Local/nuget/v3/index.json
This could usually happen when you’re Publishing the package to Nuget in a separate job or Stage from the Build step.
To resolve this, you need to do a nuget package restore before publishing the package to Nuget:
steps: - task: DotNetCoreCLI@2 displayName: Nuget package restore inputs: command: restore projects: '$(workingDirectory)/**/$(projectName)*.csproj' feedsToUse: 'config' nugetConfigPath: $(workingDirectory)/nuget.config - task: DotNetCoreCLI@2 displayName: Create Nuget Package inputs: command: pack versioningScheme: byBuildNumber arguments: '--configuration $(buildConfiguration)' packagesToPack: '$(workingDirectory)/**/$(projectName).csproj' packDestination: '$(Build.ArtifactStagingDirectory)' - task: NuGetAuthenticate@0 displayName: 'NuGet Authenticate' - task: NuGetCommand@2 displayName: 'NuGet push' inputs: command: push publishVstsFeed: 'MyFramework' allowPackageConflicts: true
The variables in the above template can be passed from a Pipeline that is triggered by a change to a branch or run manually.