从本地源导入包

本地源允许您将文件夹用作 NuGet 包源。

提示

请参阅 BaGet 与本地源对比页面了解升级到 BaGet 的原因。

步骤

确保您已安装 nuget.exe。在 PowerShell 中运行:

$source = "C:\path\to\local\feed"
$destination = "http://localhost:5000/v3/index.json"

如果您已配置 BaGet 要求 API 密钥,请使用 setapikey 命令设置:

& nuget.exe setapikey "MY-API-KEY" -Source $destination

现在运行以下 PowerShell 脚本:

$packages = nuget list -AllVersions -Source $source

$packages | % {
  $id, $version = $_ -Split " "
  $nupkg = $id + "." + $version + ".nupkg"
  $path = [IO.Path]::Combine($source, $id, $version, $nupkg)

  Write-Host "nuget.exe push -Source $destination ""$path"""
  & nuget.exe push -Source $destination $path
}