azure-devops - Multiple versions of a package in Azure Artifact
问题描述
I've set up an artifact feed in Azure Devops and pushed some of our private packages to it using "nuget.exe push".
The problem I have is some packages have multiple versions (e.g. 1.1, 1.2, 1.3 etc) and we have a number of projects where some will use 1.1, some will use 1.2 etc.
After uploading versions 1.1, 1.2 and 1.3 to the artifact feed, only 1.3 is available to my projects as it is the latest version. If I click into the uploaded package in the Devops interface I can see the previous versions, but none of the devops projects that use 1.1 or 1.2 will build as they can't find the older versions.
I've read in a few places that a way around it would be to have one artifact feed per project, with the required versions pushed to that feed. The issue I have with that is that I've simplified the scale of my problem as in reality we have around 20 packages, each one could have up to 30 different versions, and I have around 50 projects. To create a feed for each one would be massively time consuming and would involve duplicating a lot of packages when I push them.
If I add any package to a project from nuget, I get to choose which version I want to add but it seems like I can't replicate this when using an artifact feed. Am I doing this incorrectly or is there a better way to achieve what I need?
EDIT:
I'm not using a project-scoped feed, it is listed in Devops as a organisation-scoped feed.
The packages.config file specifically targets a certain version e.g.
<package id="CommonResourceAssembly" version="2.17.60.0" targetFramework="net451" />
and the error log shows that is can't find this version:
##[error].nuget\NuGet.targets(103,9): Error : Unable to find version '2.17.60.0' of package 'CommonResourceAssembly'.
The feed itself shows that version 2.17.61 is the current one, but 2.17.60 is what is needed for this particular project and does appear in the version history:
解决方案
我做错了还是有更好的方法来实现我的需要?
恐怕你做了一些不正确的设置。那是因为 Azure Artifact 支持包的多个版本。这也是您可以在 Devops 界面中看到以前版本的原因。
当我们在 Azure devops 管道中使用 nuget restore 时,nuget restore 任务会根据/中指定的包的版本来恢复包,例如:packages.config
PackageReference
Packages.config:
<packages>
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net46" />
</packages>
PackageReference:
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="8.0.3" />
</ItemGroup>
因此,请检查可能导致此问题的以下可能性:
检查您的 Azure Artifact 是否是项目范围的提要(如果您的 Azure Artifact 提要是之前创建的
11/4/2019
,请转到第二点):packages.config
检查您是否在/中使用通配符PackageReference
:<PackageReference Include="Packagename" Version="1.*" />
使用以下设置检查您的解决方案中是否有 nuget.config:
<configuration> <config> <add key="dependencyversion" value="Highest" /> </config> </configuration>
如果以上对您没有帮助,请与我们分享有关此问题的更多信息,有关构建失败项目的packages.config
/PackageReference
的信息/图像,有关 Azure 工件的信息/图像,包括包版本 1.1、1.2,最新但不重要,错误日志。
希望这可以帮助。
推荐阅读
- apollo-client - Apollo-Client 字段策略:对带参数的字段使用 readField 句柄
- r - 当它们具有不同的精度时,bind_rows() 舍入数据
- php - 如何在 laravel 中使用 SQL 组合不同数据库中的两个不同表
- javascript - 来自获取数据的 Alpine JS 数据绑定组件
- java - 如何读取带有一组标题的 CSV 但写入不同的组?
- grammar - CFG 解析树 - 最右边的推导
- sql - 如果我在选择时使用星号,我的查询会更快。为什么要这样做。我正在使用 Postgres
- excel - 不要复制另一个工作簿中现有多列的行
- cmd - 如何在文件名中包含通配符的 WIndows 中重命名文件
- jquery - jQuery:向内联样式函数添加重要内容