Azure-devops-docs: Missing information on setting this up in a YAML Pipeline, and using dotnet restore

Created on 5 Apr 2019  Â·  10Comments  Â·  Source: MicrosoftDocs/azure-devops-docs

I haven't been having success getting my Azure Devops feed working in a YAML pipeline for a project that uses modern PackageRef in the .csproj (no packages.config, no project.json), so restore is via MSBuild and/or dotnet restore. All attempts I've made fail to authenticate or load the feed index.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 devops-cictech devopprod

Most helpful comment

Never mind

- task: DotNetCoreCLI@2
  displayName: dotnet restore
  inputs:
    command: restore
    projects: '**/*.csproj'
    feedsToUse: 'select'
    vstsFeed: '/<vsts-feed-guid>'
    includeNuGetOrg: true

Want me to open a PR?

All 10 comments

Any movement on this? Or at least a work around?

Never mind

- task: DotNetCoreCLI@2
  displayName: dotnet restore
  inputs:
    command: restore
    projects: '**/*.csproj'
    feedsToUse: 'select'
    vstsFeed: '/<vsts-feed-guid>'
    includeNuGetOrg: true

Want me to open a PR?

Come on Microsoft. Can someone respond here.

Hi people, Azure Artifacts PM here. We're making some changes here that will help everyone out this quarter. To explain briefly, we're looking to create auth tasks that get you set up and then move out of your way and let you run custom commands like you would in a command line environment.

With that said, I'd like to get everyone fixed here. You have to set feedsToUse / selectOrConfig set to '_select_' and provide feeds, or set to '_config_' and point to the NuGet configuration. If you create a successful build step in the visual designer and convert it to YAML, it should be correct for you.

For anyone who needs to get a DevOps Artifacts NuGet Feed into their build...

We achieved this by adding the "vstsFeed" property to "NuGetCommand@X > inputs" and setting the value to our feed's GUID. To get this GUID, we did the following (hopefully there's an easier way, but I don't know of one):

  1. Create a new Pipeline that used the "classic editor" (little link at the bottom of the "Where is your code?" page)
  2. Continue with the creation of your Pipeline (Select a repo, branch, template, etc.)
  3. Select the "NuGet restore" task
  4. Select your DevOps Artifacts NuGet Feed from the "Feeds and authentication > Feeds to use > Use packages from this Azure Artifacts/TFS feed" dropdown
  5. Click "View YAML"
  6. Copy and paste the vstsFeed: '1234abcd-1234-12ab-ab12-1234abcd1234' line into the same "NuGetCommand@X > inputs" section in your azure-pipelines.yaml file

Here is what our azure-pipelines.yml file looked like after adding the feed:

# Xamarin.Android
# Build a Xamarin.Android project.
# Add steps that test, sign, and distribute an app, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/xamarin

trigger:
- develop

pool:
  vmImage: 'windows-latest'

variables:
  buildConfiguration: 'Release'
  outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '**/*.sln'
    vstsFeed: '1234abcd-1234-12ab-ab12-1234abcd1234'

- task: XamarinAndroid@1
  inputs:
    projectFile: '**/*droid*.csproj'
    outputDirectory: '$(outputDirectory)'
    configuration: '$(buildConfiguration)'
    jdkVersionOption: 1.8
    msbuildVersionOption: '16.0'

I hope this helps!

I was looking for how to add a public myget feed to a devops build. I don't need a private feed, don't need credentials. I failed to find how to do this. The simplest way ended up being to commit a nuget.config file to my solution root. I found my user file (on windows) at %appdata%\nuget

Be interesting to know if there is a yaml only way of doing this without pointing to a nuget.config

@jasoncoding, From what I can see in the task the capability isn't there within the NuGet task. You need to select either, an Azure artifacts feed or NuGet.org, or use the NuGet config file as you are currently doing. You can also reach out ot the Developer Community to ask for clarifiaction or make a feature request. @elbatk if there is anything I'm misrepresenting. feel free to correct me.

This is all right, nuget.config is the way to go, unless you want to specify the feed when you make the nuget/dotnet restore call.

@Paul-Dempsey Thank you for your feedback. The new version will go live shortly.

This is all right, nuget.config is the way to go, unless you want to specify the feed when you make the nuget/dotnet restore call.

Yeah, I think we're gonna switch from YAML to using the nuget.config. It seems way more convenient than adding the feed to our NuGet sources (locally) and adding the GUID to each pipeline.

Was this page helpful?
0 / 5 - 0 ratings