YAML Nuget restore
Asked Answered
S

2

14

Trying to create a build configuration in Azure DevOps, using the new YAML build feature, however I can't seem to get NuGet restore to work when referring to a NuGet.config file (places in the root of my projectfolder)

In my YAML build file I have:

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Parameters.solution)'

    feedsToUse: config

    nugetConfigPath: 'NuGet.config'

In my log I get the following:

2018-09-25T17:25:07.4624712Z ##[section]Starting: NuGet restore
2018-09-25T17:25:07.4631787Z ==============================================================================
2018-09-25T17:25:07.4631904Z Task         : NuGet    
2018-09-25T17:25:07.4632707Z Description  : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds   like Package Management and MyGet. Uses NuGet.exe and works with .NET Framework     apps. For .NET Core and .NET Standard apps, use the .NET Core task.
2018-09-25T17:25:07.4632875Z Version      : 2.0.41
2018-09-25T17:25:07.4632964Z Author       : Microsoft Corporation
2018-09-25T17:25:07.4633086Z Help         : [More Information]    (https://go.microsoft.com/fwlink/?LinkID=613747)
2018-09-25T17:25:07.4633196Z     ==============================================================================
2018-09-25T17:25:08.2066658Z SYSTEMVSSCONNECTION exists true
2018-09-25T17:25:08.2581545Z SYSTEMVSSCONNECTION exists true
2018-09-25T17:25:08.3645811Z [command]C:\Windows\system32\chcp.com 65001
2018-09-25T17:25:08.3743733Z Active code page: 65001
2018-09-25T17:25:08.4044581Z Detected NuGet version 4.7.0.5148 /     4.7.0+9245481f357ae542f92e6bc5e504fc898cfe5fc0
2018-09-25T17:25:08.4061452Z SYSTEMVSSCONNECTION exists true
2018-09-25T17:25:08.4082708Z Saving NuGet.config to a temporary config file.
2018-09-25T17:25:08.4321725Z ##[section]Finishing: NuGet restore

I've tried using

    nugetConfigPath: '$(Build.SourcesDirectory)\\NuGet.config'

instead, with the same result

Any ideas on how to get NuGet restore to work with a NuGet.config file?

Scissor answered 25/9, 2018 at 17:42 Comment(0)
S
14

I've figured it out, the NuGet task needs to be changed to:

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '**\*.sln'

    feedsToUse: config

    nugetConfigPath: 'NuGet.config'

(The only thing which needed changing is restoreSolution.)

Scissor answered 26/9, 2018 at 5:13 Comment(0)
A
0

I also ran into this. I added the nuget.config to the solution(like any other class or interface) and it needed to be added where the .sln file was located.

e.g. If you didn't click the "Place solution and project in same directory" check box on project creation. Move the nuget.config one level up in your project.

Antiquate answered 18/6, 2020 at 3:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.