gpt4 book ai didi

nuget - 无法让 Pipeline 将自定义 NuGet 服务器与 Azure DevOps 构建一起使用

转载 作者:行者123 更新时间:2023-12-05 08:22:58 29 4
gpt4 key购买 nike

我的解决方案使用来自官方 NuGet 服务器和私有(private) NuGet 服务器的包。我正在尝试配置我的构建管道以从两个位置恢复包,但不断出现 NuGet 恢复构建错误,看起来它正在尝试从公共(public) NuGet 服务器恢复我的私有(private)包,因此失败是可以理解的。

我不知道我还应该做什么。似乎 Azure DevOps 中没有可以为 NuGet 还原步骤进行的设置,因为看起来现在所有这些都在 YAML 文件中配置。任何关于我可能做错了什么或我还可以尝试什么的建议都将不胜感激。

我的解决方案中的 NuGet.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />
<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
<add key="Private" value="http://privatenuget.net:8080/nuget" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>

Pipelines 使用的我的 YAML 文件:

# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4

pool:
vmImage: 'VS2017-Win2016'

variables:
solution: 'MyProject.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@0

- task: NuGetCommand@2
inputs:
nugetConfigPath: 'MyProject\NuGet.config'
restoreSolution: '$(solution)'

- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'

- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'

我在构建的 NuGetCommand 步骤上遇到的错误:

The nuget command failed with exit code(1) and error(Errors in packages.config projects
NU1000: Unable to find version '1.1.5' of package 'MyPackage'.
https://api.nuget.org/v3/index.json: Package 'MyPackage' is not found on source 'https://api.nuget.org/v3/index.json'.)
Packages failed to restore

最佳答案

您的 YML 文件不正确,您必须添加 feedsToUse: config

- task: NuGetCommand@2
displayName: 'Nuget Restore'
inputs:
restoreSolution: '$(solution)'
feedsToUse: config
nugetConfigPath: nuget.config

关于nuget - 无法让 Pipeline 将自定义 NuGet 服务器与 Azure DevOps 构建一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53052678/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com