导入 NuGet.Server 包
NuGet.Server 是一个轻量级的独立 NuGet 服务器。如果您使用 NuGet.Server,强烈建议您升级到 BaGet。如果您在迁移时需要帮助,欢迎提交 GitHub issue。
提示
请参阅 BaGet 与 NuGet.Server 对比页面了解升级到 BaGet 的原因。
步骤
确保您已安装 nuget.exe。在 PowerShell 中运行:
$source = "<NuGet.Server 包源>"
$destination = "<BaGet 包源>"
如果您已配置 BaGet 要求 API 密钥,请使用 setapikey 命令设置:
& nuget.exe setapikey "MY-API-KEY" -Source $destination
现在运行以下 PowerShell 脚本:
if (!(Test-Path "Web.config")) {
throw "请在 NuGet.Server 的 Web.config 文件所在目录中运行此脚本"
}
(& nuget.exe list -AllVersions -Source $source).Split([Environment]::NewLine) | % {
$id = $_.Split(" ")[0].Trim()
$version = $_.Split(" ")[1].Trim()
$path = [IO.Path]::Combine("Packages", $id, $version, "${id}.${version}.nupkg")
Write-Host "nuget.exe push -Source $destination ""$path"""
& nuget.exe push -Source $destination $path
}