devops/bash_scripts/azure/feed_download_nuget.ps1

50 lines
1.9 KiB
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# === НАСТРОЙКИ ===
$NuGetExePath = ".\nuget.exe" # Путь к nuget.exe
$PackageSourceName = "azure-microservices-core" # Ключ из nuget.config (source key)
$DownloadDir = "C:\Temp\nupkg_need" # Куда сохранять .nupkg
# ===============
# Проверка nuget.exe
if (-not (Test-Path $NuGetExePath)) {
Write-Error "Файл nuget.exe не найден: $NuGetExePath"
exit 1
}
# Создаём папку
if (-not (Test-Path $DownloadDir)) {
New-Item -ItemType Directory -Path $DownloadDir | Out-Null
}
Write-Host "Получаем список пакетов из источника: $PackageSourceName ..."
# Получаем все пакеты и версии через nuget list
$packages = & $NuGetExePath list -AllVersions -Source $PackageSourceName 2>$null
if ($LASTEXITCODE -ne 0 -or $null -eq $packages) {
Write-Error "Не удалось получить список пакетов из источника '$PackageSourceName'"
Write-Error "Убедитесь, что имя источника правильное и он есть в nuget.config"
exit 1
}
Write-Host "Найдено пакетов: $($packages.Count)`n"
foreach ($line in $packages) {
$parts = $line.Trim() -split '\s+', 2
if ($parts.Count -lt 2) { continue }
$id = $parts[0]
$version = $parts[1]
Write-Host "Скачиваю $id ($version) ..."
# Используем nuget install, чтобы скачать .nupkg (без зависимостей, если повезёт)
& $NuGetExePath install $id -Version $version -Source $PackageSourceName -OutputDirectory $DownloadDir -NonInteractive
if ($LASTEXITCODE -eq 0) {
Write-Host "Успешно" -ForegroundColor Green
} else {
Write-Warning "Ошибка при скачивании $id ($version)"
}
}
Write-Host "`nГотово. Пакеты сохранены в: $DownloadDir"