简体   繁体   中英

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.

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

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