最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

azure - Switching from downloading nuget from internet to internal feed - Stack Overflow

programmeradmin2浏览0评论

Today, my current flow is the following :

I have multiple Azure yml pipelines consuming a step template i.e. init-nuget.yml which looks like:

parameters: 
  nugetVersion: '6.x'
steps:
- task: NuGetToolInstaller@0
  displayName: Install NuGet
  inputs:
    versionSpec: 5.8.x
-task: NuGetAuthenticate@1
 displayName: NuGet Authenticate ...

They are closing access to the internet and I need to immediately switch to consuming from my Internal Azure Artifact (private feed). This private feed has nuget as an upstream source.

how do I switch this method to use the internal feed (if it can't find the version to download and install it from upstream source)

I've tried everything, and even though I don't have 5.8.x in the feed it doesn't find it or not using the upstream source to download it. I also tried pushing a version to the internal feed, and I couldn't because it already finds it in the upstream source nuget gallery.

Today, my current flow is the following :

I have multiple Azure yml pipelines consuming a step template i.e. init-nuget.yml which looks like:

parameters: 
  nugetVersion: '6.x'
steps:
- task: NuGetToolInstaller@0
  displayName: Install NuGet
  inputs:
    versionSpec: 5.8.x
-task: NuGetAuthenticate@1
 displayName: NuGet Authenticate ...

They are closing access to the internet and I need to immediately switch to consuming from my Internal Azure Artifact (private feed). This private feed has nuget. as an upstream source.

how do I switch this method to use the internal feed (if it can't find the version to download and install it from upstream source)

I've tried everything, and even though I don't have 5.8.x in the feed it doesn't find it or not using the upstream source to download it. I also tried pushing a version to the internal feed, and I couldn't because it already finds it in the upstream source nuget gallery.

Share Improve this question edited Feb 15 at 13:20 James Z 12.3k10 gold badges27 silver badges47 bronze badges asked Feb 14 at 15:42 JASON HEIDENTHALJASON HEIDENTHAL 1 2
  • Add a nuget.config file to the repo(s) that specifies the package source. – Jonathan Dodds Commented Feb 17 at 2:34
  • Hi @JASONHEIDENTHAL, Welcome to SO. Have you got a chance to check the answer below to explicitly configure nuget restore step to retrieve packages from your Azure Artifacts feed? If it works for you, you may consider this, which may help other community members with similar concerns. Thanks. – Aguy Commented yesterday
Add a comment  | 

1 Answer 1

Reset to default 0

Not sure if you added the private Azure Artifacts feed as the packageSources in your nuget.config file but based on your description and the current YAML pipeline definition, it appeared that you didn't configure this pipeline to restore NuGet package from your Azure Artifacts feed and if no specific feed was defined in your pipeline or the nuget.config file, the pipeline would retrieve the packages from nuget. by default.

Additionally, the version of 5.8.x is the version of the NuGet tool you selected to be installed on pipeline agents, rather than the packages used in your .Net solution/projects.

To explicitly configure your pipeline to restore packages from your private Azure Artifacts feed, you can add a NuGet Restore step like the example below, setting its vstsFeed property to your correct Azure Artifacts feed. When you enable upstream sources for your feed and install a package from an upstream source, an automatic copy of that package is saved to your feed.

parameters:
- name: nugetVersion
  default: '6.x'

steps:
- task: NuGetToolInstaller@0
  displayName: Install NuGet
  inputs:
    # versionSpec: ${{ parameters.nugetVersion }} # '5.8.x' # Download the NuGet tool with the version you input for parameters
    checkLatest: true # Always download the latest NuGet tool

# No need to use the NuGetAuthenticate task if restoring from the feed in your Azure Artifacts.
# - task: NuGetAuthenticate@1
#   displayName: NuGet Authenticate

- task: NuGetCommand@2
  displayName: NuGet Restore
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'select'
    vstsFeed: '$(System.TeamProjectId)/SampleNuGetFeed' # Explicitly configure the task to restore packages from the project-scoped Azure Aritifacts feed
    includeNuGetOrg: false # Exclude NuGet. as packageSources in the temp nuget.config file; automatically caching from upstream NuGet. source into Azure Artifacts feed still works

Make sure the pipeline service account(<ProjectName> Build Service (<YourOrgName>)/Project Collection Build Service (<YourOrgName>)) is assigned at least with the Feed and Upstream Reader (Collaborator) role, ensuring the pipeline with the permissions to automatically cache packages from upstream sources into your feed.

发布评论

评论列表(0)

  1. 暂无评论