我有一个私人 nuget feed,用于为我的应用程序托管一些包,我正在使用 Azure Pipelines 进行构建,并且我注意到
PackageSourceMappings
存在恢复问题,我相信我已相应地遵循了指导。
我已经安装了该工具并使用
packagesourcemapper generate nuget.config --remove-unused-sources
生成了源地图
按照文档中的指导,我已经通过清除本地 nuget 缓存、重新启动 VS 并运行干净恢复来验证这是否可以在本地工作。
当我在构建代理上运行恢复时:
- task: NuGetToolInstaller@1
displayName: Use latest NuGet
inputs:
checkLatest: true
- task: UseDotNet@2
displayName: 'Use global.json SDK'
inputs:
packageType: 'sdk'
useGlobalJson: true
- task: DotNetCoreCLI@2
displayName: dotnet restore
inputs:
command: 'restore'
projects: ${{ parameters.solution }}
feedsToUse: 'config'
nugetConfigPath: 'NuGet.config'
恢复将失败,列出的所有失败的软件包都来自我的私人源:
/Users/runner/work/1/s/tests/MyApp.UnitTests/MyApp.UnitTests.csproj : error NU1100: Unable to resolve 'Acme.MyPackage (>= X.X.X-pre)' for 'net8.0'. PackageSourceMapping is enabled, the following source(s) were not considered: /Users/runner/hostedtoolcache/dotnet/library-packs, feed-MyApp, nuget.org. [/Users/runner/work/1/s/MyApp.sln]
我的私人提要列在我的Nuget.config
:
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Acme" value="https://pkgs.dev.azure.com/Acme/MyApp/_packaging/MyFeed/nuget/v3/index.json" />
</packageSources>
我的源图如下所示:
<packageSourceMapping>
<clear />
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
<packageSource key="Acme">
<package pattern="Acme.*" />
</packageSource>
</packageSourceMapping>
<disabledPackageSources>
<clear />
</disabledPackageSources>
阅读文档我看不出出了什么问题,我不明白为什么当我有这张地图时 nuget 完全忽略我的私人提要。我尝试了相同的配置,但所有包都明确命名(使用
PackageSourceMapper
生成)
令我困惑的是,这个操作显然知道我的私有源,因为它列出了它,为什么它会忽略我的私有包?
https://github.com/NuGet/Home/issues/11406<-- this probably the reason
DotNetCoreCLI@2 任务最终需要在源映射配置中添加 feed- 前缀。