Jason
Jason

Reputation: 11

Telerik Nuget package restore in Azure build pipeline fails

I'm attempting to pull Nuget packages from Telerik's Nuget repository into an Azure build pipeline, however, none of the pipeline configuration attempts I've made seem to work. I either receive an error stating my nuget.config is not formatted correctly or a 401 error when connecting to the repository.

The below configuration section is from my build definition. I've tried using NuGetCommand as well as NuGetRestore:

- task: NuGetToolInstaller@1
  inputs:
    versionSpec: '5.0.2'
- task: NuGetAuthenticate@1
  inputs:
    nuGetServiceConnections: 'Telerik_v3'
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'config'
    nugetConfigPath: './XXXXXXX/nuget.config' 
#'$(System.DefaultWorkingDirectory)/XXXXXXX/NuGet.config'
    externalFeedCredentials: 'Telerik_v3'
# - task: NuGetRestore@1
#   inputs:
#     solution: '**/*.sln'
#     selectOrConfig: 'config'
#     nugetConfigPath: './XXXXXXX/nuget.config'

Here is my nuget.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <add key="NuGet" value="https://api.nuget.org/v3/index.json" protocolVersion="3"/>
        <add key="Telerik_NuGet" value="https://nuget.telerik.com/v3/index.json" protocolVersion="3" />
    </packageSources>
</configuration>

Here is the error I receive:

NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source https://nuget.telerik.com/v3/index.json. ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).

Tweaking the configuration slightly I get this error:

[error]The nuget command failed with exit code(1) and error(NuGet.Configuration.NuGetConfigurationException: NuGet.Config is not valid XML. Path: 'D:\a\1\Nuget\tempNuGet_966.config'. ---> System.Xml.XmlException: An error occurred while parsing EntityName. Line 10, position 46.

I based my build tasks on the NuGetCommandv2 and NuGetRestore v1 documentation as well as what I found on Telerik's site.

Upvotes: 1

Views: 1127

Answers (2)

Rohit
Rohit

Reputation: 106

Since telerik is an external feed, Firstly you need to add a service connection in azure devops(go to Project settings --> service connection(under Pipelines section)).

After adding the service reference you need to copy your NuGet config file("\AppData\Roaming\NuGet") and add to your project base directory (Assuming you are using telerik nuget feed in your local system and credentials are updated in Nuget.config file).Then under your restore job provide the path of nuget package as shown in below image. enter image description here

Upvotes: 0

Swarna Anipindi
Swarna Anipindi

Reputation: 954

When we want to use private nuget packages like Telerik we need to specify credentials in Nuget.config_

  • Connection name
  • Feed URL
  • Username
  • Password

NOTE:
In order to add a reference to this NuGet package to your project, firstly need to add Telerik credentials into Visual Studio.

example:

dotnet nuget update source "Telerik" --source "https://nuget.telerik.com/v3/index.json" --configfile "nuget.config" --username '*************' --password '***********' --store-password-in-clear-text

Here I found one reference github by Lance McCarthy

Upvotes: 0

Related Questions