我有一个 Azure 管道,可以制作 NuGet 包并将其放入粉红色的Artefacts NuGet 提要中,我可以使用 VisualStudio 中的该管道将我的包安装到另一个项目中。
但是,消费项目的 Azure 管道无法还原 nuget 包。我认为这是因为一些安全废话。
如何获取 Azure 管道来还原包?
这是任务
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: 'restore'
feedsToUse: 'select'
vstsFeed: 'Some-DLLs'
这是错误
Build FAILED.
"C:\agent\_work\19\s\neon-identity-samples.sln" (Restore target) (1) ->
(Restore target) ->
C:\Program Files\dotnet\sdk\5.0.104\NuGet.targets(131,5): error : Unable to load the service index for source https://tfs.engineering.company.net/tfs/Software-Collection/_packaging/Some-DLLs/nuget/v3/index.json. [C:\agent\_work\19\s\samples.sln]
C:\Program Files\dotnet\sdk\5.0.104\NuGet.targets(131,5): error : No credentials are available in the security package [C:\agent\_work\19\s\samples.sln]
0 Warning(s)
1 Error(s)
答案 0 :(得分:1)
这似乎是一个已知问题 (1) (2),用户设法通过使用“自定义”命令而不是“恢复”来消除此错误。我无法从我这边重现您的问题,但解决方案如下:
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: 'custom'
custom: 'restore'
arguments: '--force'
feedsToUse: 'select'
vstsFeed: 'Some-DLLs'
此错误也可能是由于存储库中缺乏授权引起的,换句话说,您的 nuget.config 文件似乎没有访问存储库的凭据,因此 dotnet restore 失败,因此您需要确保在项目的 nuget.config 文件中正确设置凭据。
答案 1 :(得分:0)
创建一个 PAT 并将其放入 nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="Some-DLLs" value="https://tfs.engineering.intelligentgaming.net/tfs/neon-collection/_packaging/Some-DLLs/nuget/v3/index.json" />
</packageSources>
<packageSourceCredetials>
<Some-DLLs>
<add key="username" value="DEV\richard.barraclough" />
<add key="password" value="bhyc4751jhozv7akw5rgpoy872ddminwzfio3npkhjbsrg88kfez" /> <!-- A PAT -->
</Some-DLLs>
</packageSourceCredetials>
</configuration>
(我不在乎安全,因为它会阻止事情的进行。)