I am trying to create a NuGet package and publish it to an internal feed using an Azure CI/CD pipeline. Below are the details:
-
Organization name:
devStierMate
-
Azure project name:
Common'
-
Feed name:
DemoFeed
For the pipeline
trigger: master
pool: default
steps:
task: DotNetCoreCLI@2
inputs:
command: 'restore'
projects: '**/Base.Domain.csproj'
feedsToUse: 'select'
vstsFeed: '2bcded40-dea3-4063-bae4-ec406ef556d8'
task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: '**/Base.Domain.csproj'
task: NuGetCommand@2
inputs:
command: 'pack'
packagesToPack: '**/Base.Domain.csproj'
versioningScheme: 'off'
task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
vstsFeed: 'b86d8ee2-12bf-409a-a614-679003bfb0fa'
task: NuGetCommand@2
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)//*.nupkg;!$(Build.ArtifactStagingDirectory)//*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'b86d8ee2-12bf-409a-a614-679003bfb0fa'
allowPackageConflicts: true
This gives the error
a következő helyen: VstsNuGetPush.CredentialSelector.TrySelectCredential[TResult](Func2 func, IVssCredentialStorage vssClientCredentialStorage, CredentialPromptType promptType, TResult& result) a következő helyen: VstsNuGetPush.CredentialSelector.Select[TResult](Func2 func) a következő helyen: VstsNuGetPush.Patterns.Helpers.FactoryAdaptorChain2.Get() a következő helyen: System.Lazy1.CreateValue() a következő helyen: System.Lazy1.LazyInitValue() a következő helyen: VstsNuGetPush.VstsNuGetPushCommand.MainCore(ILogger logger) a következő helyen: VstsNuGetPush.VstsNuGetPushCommand.Main() ##[error]Error: An unexpected error occurred while trying to push the package with VstsNuGetPush.exe. Exit code(1) and error(Error: Microsoft.VisualStudio.Services.Common.VssServiceException: User '6e5a7421-080a-4b76-a45e-37d24e6b9ab8' lacks permission to complete this action. You need to have 'ReadPackages'. a következő helyen: Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<HandleResponseAsync>d__53.MoveNext() --- Verem vége nyomkövetés a kivétel előző előfordulási helyétől kezdve --- a következő helyen: System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() a következő helyen: System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) a következő helyen: Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__51.MoveNext() --- Verem vége nyomkövetés a kivétel előző előfordulási helyétől kezdve --- a következő helyen: System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() a következő helyen: System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) a következő helyen: VstsNuGetPush.NuGetServiceIndexHttpClient.<>c__DisplayClass2_0.<<GetServiceIndexAsync>b__0>d.MoveNext() --- Verem vége nyomkövetés a kivétel előző előfordulási helyétől kezdve --- a következő helyen: System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() a következő helyen: VstsNuGetPush.RetryHelper.<RetryOnExceptionHelperAsync>d__01.MoveNext() --- Verem vége nyomkövetés a kivétel előző előfordulási helyétől kezdve --- a következő helyen: System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() a következő helyen: System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) a következő helyen: VstsNuGetPush.NuGetServiceIndexHttpClient.<GetServiceIndexAsync>d__2.MoveNext() --- Verem vége nyomkövetés a kivétel előző előfordulási helyétől kezdve --- a következő helyen: System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() a következő helyen: System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) a következő helyen: VstsNuGetPush.HttpServiceIndexProvider.<Get>b__4_0(VssClientCredentials credentials) a következő helyen: VstsNuGetPush.CredentialSelector.TrySelectCredential[TResult](Func2 func, IVssCredentialStorage vssClientCredentialStorage, CredentialPromptType promptType, TResult& result) a következő helyen: VstsNuGetPush.CredentialSelector.Select[TResult](Func2 func) a következő helyen: VstsNuGetPush.Patterns.Helpers.FactoryAdaptorChain2.Get() a következő helyen: System.Lazy1.CreateValue() a következő helyen: System.Lazy`1.LazyInitValue() a következő helyen: VstsNuGetPush.VstsNuGetPushCommand.MainCore(ILogger logger) a következő helyen: VstsNuGetPush.VstsNuGetPushCommand.Main()) ##[error]Packages failed to publish Finishing: NuGetCommand
Where can I find the user permissions settings?
How do I grant the necessary permissions (e.g., ‘ReadPackages’) to this user to resolve the issue?
0
Error: Microsoft.VisualStudio.Services.Common.VssServiceException: User ‘6e5a7421-080a-4b76-a45e-37d24e6b9ab8’ lacks permission to complete this action. You need to have ‘ReadPackages’.
Based on the error message, the user doesn’t have the permission to access the feed.
In Azure DevOps Build Pipeline, it will use the Build Service Account to Push the nuget package to Azure Feed.
The Build Service account has two levels: Organization level and Project level.
Project Level: Your-project-name Build Service (your-collection-name)
Organization level: Project Collection Build Service (your-collection-name)
You need to grant the Contributor Role to related Build Service account.
For example: navigate to Feed -> Settings -> Permissions
If you are access the Organization feed or the feed from another project, you need to navigate to Project Settings -> Settings and disable the option: Limit job authorization scope to current project for non-release pipelines.
For example:
For Classic Pipeline, you need to navigate to Option tab and check the Build job authorization scope. If you need to access Organization Feed or Feed from another project, you need to set the scope to Project Collection.