gpt4 book ai didi

azure-devops - PackageReference 版本控制通配符 csproj

转载 作者:行者123 更新时间:2023-12-03 17:03:45 25 4
gpt4 key购买 nike

我的 NetStandard 项目中有以下内容

<ItemGroup>
<PackageReference Include="MyReference" Version="1.0.*" />
</ItemGroup>

当我将其更改为使用通配符(而不是 1.0.1)时,我在依赖项切换上得到一个感叹号,然后是 NuGet 切换,当然还有包本身。

当我 checkin 时,CI 构建在另一端也失败了,给了我

Unable to find package MyReference. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org



使用没有通配符的实际版本(1.0.1)时,上述所有问题都消失了,但我想确保 .NET Core 恢复任务始终恢复到最新的包,我希望一个简单的通配符就可以做到.

注意 - 我正在使用我自己的私有(private) NuGet 存储库(包管理扩展)

请指教。

为什么在 CI 构建过程中使用通配符会失败,表明它找不到包?

因此,假设我已将 project1 部署到我自己的 NuGet 存储库。 Project2 对 Project1 具有依赖关系,该依赖关系已作为 NuGet 包添加到 Project2。 Project1 包驻留在我自己的存储库中,没有问题也没有错误。

当我使用通配符并在本地构建时,它可以工作并恢复最新版本。当我 checkin 代码更改时(在 .csproj 中保留通配符)- CI 构建失败并显示上述错误消息。

最佳答案

根据 the official doc

When using the PackageReference format, NuGet also supports using a wildcard notation, *, for Major, Minor, Patch, and pre-release suffix parts of the number. Wildcards are not supported with the packages.config format.



对于你的问题

Always specify a version or version range for package dependencies in project files, packages.config files, and .nuspec files. Without a version or version range, NuGet 2.8.x and earlier chooses the latest available package version when resolving a dependency, whereas NuGet 3.x and later chooses the lowest package version. Specifying a version or version range avoids this uncertainty.

关于azure-devops - PackageReference 版本控制通配符 csproj,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52323525/

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