[英]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.我正在尝试将 Nuget 包从 Telerik 的 Nuget 存储库拉入 Azure 构建管道,但是,我所做的所有管道配置尝试似乎都不起作用。 I either receive an error stating my nuget.config is not formatted correctly or a 401 error when connecting to the repository.我要么收到一条错误,指出我的 nuget.config 格式不正确,要么在连接到存储库时收到 401 错误。
The below configuration section is from my build definition.下面的配置部分来自我的构建定义。 I've tried using NuGetCommand as well as NuGetRestore:我试过使用 NuGetCommand 和 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:这是我的 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 . NuGet.Protocol.Core.Types.FatalProtocolException:无法加载源https://nuget.telerik.com/v3/index.json的服务索引。 ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized). ---> System.Net.Http.HttpRequestException:响应状态代码不表示成功:401(未授权)。
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. ##[错误]nuget 命令失败,退出代码 (1) 和错误(NuGet.Configuration.NuGetConfigurationException:NuGet.Config 无效 XML。路径:'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.我的构建任务基于 NuGetCommandv2 和 NuGetRestore v1 文档以及我在 Telerik 网站上找到的内容。
When we want to use private nuget packages like Telerik we need to specify credentials in Nuget.config_当我们想使用像Telerik这样的私有 nuget 包时,我们需要在Nuget.config_中指定凭证
NOTE:笔记:
In order to add a reference to this NuGet package to your project, firstly need to add Telerik credentials into Visual Studio .为了将对此 NuGet package 的引用添加到您的项目中,首先需要将Telerik凭据添加到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在这里,我找到了 Lance McCarthy 的参考文献github
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.