使用自定义源和官方源进行 dotnet 恢复

tak*_*shi 8 .net-core

我有自定义 Nuget 存储库 (\\build\NugetFeed),而且我正在使用 nuget.org 来恢复我的包。

为了恢复包,我使用这个命令

dotnet restore --source \\build\NugetFeed --source https://api.nuget.org/v3/index.json --verbosity n
Run Code Online (Sandbox Code Playgroud)

但是在我的构建服务器上,我收到以下错误

C:\Program Files\dotnet\sdk\2.2.107\NuGet.targets(114,5): error : The local source 'D:\BuildAgent\_work\5\s\https:\api.nuget.org\v3\index.json' doesn't exist. [D:\BuildAgent\_work\5\s\MyCode.sln]
Run Code Online (Sandbox Code Playgroud)

并且没有恢复来自官方 Nuget 的软件包。是否还有其他使用 dotnet restore 的配置选项?

jgo*_*day 11

似乎是 dotnet cli restore 命令错误。

如果您首先指定本地原点,它会失败,否则会起作用。

# Fails
dotnet restore --source /tmp/Nuget --source https://api.nuget.org/v3/index.json
Run Code Online (Sandbox Code Playgroud)
#Works
dotnet restore --source https://api.nuget.org/v3/index.json --source /tmp/Nuget
Run Code Online (Sandbox Code Playgroud)

无论如何,您始终可以使用自定义 Nuget.config

# Fails
dotnet restore --source /tmp/Nuget --source https://api.nuget.org/v3/index.json
Run Code Online (Sandbox Code Playgroud)

甚至将其添加到项目本身

#Works
dotnet restore --source https://api.nuget.org/v3/index.json --source /tmp/Nuget
Run Code Online (Sandbox Code Playgroud)

这个问题似乎是相关的

  • 如此棒的“dotnet Restore”错误 (3认同)