简体   繁体   中英

Deploy nuget package to internal Azure Artifact feed

I am trying to setup an Azure Artifact feed to deploy nuget packages my team creates. I have the feed created and connected to my upstream feed. 在此处输入图像描述

In my.yaml file, I have it referencing the upstream feed to restore from and push to with the trigger happening on my main branch(I have also tried setting the referenced feed to be my non-upstream feed, but I get the same result I mention below).

trigger:

- main    

pool:
  vmImage: ubuntu-latest

variables:
  buildConfiguration: 'Release'

steps:
- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    feedsToUse: 'select'
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'select'
    vstsFeed: '{InternalUpstreamFeedArtifact}'
- task: NuGetCommand@2
  inputs:
    command: 'pack'
    packagesToPack: '*.csproj'
    versioningScheme: 'off'
- task: NuGetCommand@2
  inputs:
    command: 'push'
    packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
    nuGetFeedType: 'internal'
    publishVstsFeed: '{ InternalUpstreamFeedArtifact }'

When I check the feed after I run my pipeline, it never goes into either feed. I also don't get any errors during the run process. I'm not sure if providing the project's folder structure will help, but I'm including it anyway in case that may be the reason why.

Path: \Service\Service\bin\Debug 在此处输入图像描述 在此处输入图像描述 在此处输入图像描述 在此处输入图像描述 在此处输入图像描述

Finally, here's what my nuget.config file looks like.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
       <packageSources>
             <clear />
             <add key="TestFeed" value=https://pkgs.dev.azure.com/Company/Project/_packaging/TestFeed/nuget/v3/index.json />
       </packageSources>
</configuration>

Can anyone explain what I'm doing wrong and point me in the right direction to fix it? Thanks in advance for any & all help.

I was able to figure out the problem. Since I've essentially created a microservice, the problem was that my yaml file didn't actually know where the nuget package lives. So rather than running this command, I simply explicitly set the path for the package to push

- task: NuGetCommand@2
  inputs:
    command: 'push'
    packagesToPush: 'Service/bin/Debug/*.nupkg;'
    nuGetFeedType: 'internal'
    publishVstsFeed: '{ InternalUpstreamFeedArtifact }'

It was an issue with my directory pathing and having multiple projects, only one of which contained an actual package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM