Azure DevOps publish Nuget to hosted feed

后端 未结 6 1258
野趣味
野趣味 2020-12-30 11:07

I have a question using the hosted (free) AzureDevops pipelines. I have a small .NET Core project which I want to create an Azure Devops pipeline where the following is done

相关标签:
6条回答
  • 2020-12-30 11:27

    For project-scoped feeds use publishVsTsFeed: '<yourProjectName>/<yourFeedName>'

    In the first example of @sascha the task should look like:

    - task: NuGetCommand@2
      displayName: 'NuGet push'
      inputs:
        command: 'push'
        packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
        nuGetFeedType: 'internal'
        publishVstsFeed: 'NugetProjects/nugetprojectstestfeed'
        allowPackageConflicts: true
    

    The package is copied to the feed only if the version number is higher as the package in the feed. Otherwise nuget push will report a conflict, but will pass anyway because of allowPackageConflicts: true (in contrast to DotNetCoreCLI@2 push)!

    0 讨论(0)
  • 2020-12-30 11:30

    I created a new Azure Artifacts feed a few days ago and ran headlong into this while attempting to create a .NET Core/Standard NuGet build pipeline similar to this example. The rest of my CI pipeline ran perfectly, but the NuGet Push task failed every time with exactly the same error in the Azure Pipelines log, despite all my attempts to find a workaround:

    The feed with ID '{my_feed_name}' doesn't exist.

    Since the feed did most certainly exist, I dug a bit more and discovered other similar reports of a bug in Azure Pipelines. Apparently, Microsoft recently changed the default scope level for new feeds to Project instead of Organization, which broke several Azure Pipeline tasks. Older feeds don't seem to be affected by this issue. See this forum post:

    New feeds are now by default project-scoped and a required fix for the pipeline tasks failed to get deployed. We are pushing out a hotfix to update to the newest pipeline task versions and it should be out by the end of the day.

    Hopefully, Microsoft will resolve this issue soon.

    0 讨论(0)
  • 2020-12-30 11:31

    I have found the trouble with this at moment, after 1 hour of checks. I can see that by default, when you create a Feed over Artifacts on your AzureDevOps project, it's only have permission for Project collection Build Service but not for your project Build Services.

    Let's check the image below and compare with your Feed Settings.

    Going toFeed Settings/Permission through Gear Button on right side of artifacts page

    this is the code for my task

    - task: NuGetCommand@2
      displayName: 'nuget push'
      inputs:
        command: 'push'
        feedsToUse: 'select'
        packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
        nuGetFeedType: 'internal'
        vstsFeed: kreaCore/kreaCore
        publishVstsFeed: kreaCore/kreaCore
        versioningScheme: 'off'
        allowPackageConflicts: true
    
    

    And the expected result is

    This is a useful tutorial for replicate my test.

    Cheers!!

    0 讨论(0)
  • 2020-12-30 11:35

    You have missed setting some required arguments in your NuGetCommand@2 task.

    Try this:

    - task: NuGetCommand@2
      displayName: 'NuGet push'
      inputs:
        command: push
        feedsToUse: select
        vstsFeed: nugetprojectstestfeed
        nuGetFeedType: internal
        publishVstsFeed: nugetprojectstestfeed
        allowPackageConflicts: true
    

    If we look into the documentation of NuGet task, for 'push' command certain arguments are required.

    0 讨论(0)
  • 2020-12-30 11:42

    As per the answer from @mwimwi, including the project name in the feed path worked for me:

    - task: DotNetCoreCLI@2
      displayName: Push
      inputs:
        command: push
        packagesToPush: ...
        feedPublish: <project-name>/<feed-name>
    
    0 讨论(0)
  • 2020-12-30 11:48

    I have done two changes like below,

    1. In the FeedSetting Permissions, selected "Allow project-scoped builds"

    2. The YML file updated for NuGetCommand like below,

        task: NuGetCommand@2
          displayName: 'Publish NuGet package'
          inputs:
            command: push
            feedsToUse: 'select'
            packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
            nuGetFeedType: 'internal'
            publishVstsFeed: 'Space Game - web - Dependencies/Tailspin.SpaceGame.Web.Models'
            allowPackageConflicts: true
    

    And the issue is resolved now...

    Thank you guys...

    ~KC

    0 讨论(0)
提交回复
热议问题