我正在使用 Azure Dev Ops 来处理我的 ASP.NET Core Web 应用程序。我正在设置管道,但出现错误。这些错误来自包恢复问题,因为我的应用程序使用 KendoUI 库,我必须为所需的私有(private) NuGet 包创建服务连接。完成此操作后,构建仍然失败,我想知道出了什么问题?
错误消息
[error]The nuget command failed with exit code(1) and error(NU1102: Unable to find package Telerik.UI.for.AspNet.Core with version (>=
2019.2.619) - Found 1 version(s) in NuGetOrg [ Nearest version: 2016.3.914 ] Errors in d:\a\1\s\MyCompany\MyProject.UI.csproj NU1102: Unable to find package Telerik.UI.for.AspNet.Core with version (>= 2019.2.619) - Found 1 version(s) in NuGetOrg [ Nearest version: 2016.3.914 ])
[error]Packages failed to restore
我与 Telerik 支持人员交谈,他们说上面的代码是因为身份验证失败,导致系统寻找导致此兼容性问题的旧版本。我被要求检查我的身份验证,但此错误仍然存在。
我按照 Telerik 提供的有关如何实现此目标的文档进行操作,您可以在此处找到:https://www.telerik.com/blogs/azure-devops-and-telerik-nuget-packages
好的,首先,我的项目的根目录中有一个 nuget.config
文件。文件内容为:
nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<packageSources>
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
<add key="Telerik" value="https://nuget.telerik.com/nuget" />
</packageSources>
<packageSourceCredentials>
<Telerik>
<add key="Username" value="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="107d75507d69726563797e7563633e737f7d" rel="noreferrer noopener nofollow">[email protected]</a>" />
<add key="ClearTextPassword" value="MyFunkYPassword19!" />
</Telerik>
</packageSourceCredentials>
</configuration>
在 Azure Dev Ops 中,我按照其文档中描述的方式创建了一个服务连接,其名称用户名和密码如上面的代码
在我的管道中,我添加了 Nuget 包,该包设置为使用上面的服务连接进行恢复。
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'config'
nugetConfigPath: 'MyProject/nuget.config'
externalFeedCredentials: 'Telerik NuGet'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
上述管道步骤的设置如下:
有人知道发生了什么事吗?我的设置不正确吗?
最佳答案
我无意中让它工作了。导致问题的是步骤的顺序。构建的输出表明,无论我做什么,管道都会查看 tempNuget.config 文件,而不是我指定的文件。由于工作中有两个 NuGet 步骤,我将 Telerik 上移了一级,这确保了系统使用正确的 nuget.config 文件,而不是查看它正在创建的临时文件。
以下是导致其开始工作的更改步骤,请注意 Telerik 步骤已上移一步。
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'config'
nugetConfigPath: 'MyProject/nuget.config'
externalFeedCredentials: 'Telerik NuGet'
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
关于azure - 为什么我的 Azure Devops Pipeline 无法还原包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58270244/