Pat*_*ick 2 nuget nuget-package-restore azure-devops
我的解决方案使用来自官方 NuGet 服务器和私有 NuGet 服务器的包。我正在尝试配置我的构建管道以从两个位置恢复包,但不断收到 NuGet 恢复构建错误,看起来它正在尝试从公共 NuGet 服务器恢复我的私有包,并且因此失败,这是可以理解的。
我有点不知所措,不知道我还应该做什么。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>
Run Code Online (Sandbox Code Playgroud)
我的 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)'
Run Code Online (Sandbox Code Playgroud)
我在构建的 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
Run Code Online (Sandbox Code Playgroud)
您的 YML 文件不正确,您必须添加feedsToUse: config
- task: NuGetCommand@2
displayName: 'Nuget Restore'
inputs:
restoreSolution: '$(solution)'
feedsToUse: config
nugetConfigPath: nuget.config
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4733 次 |
| 最近记录: |