Skip to content

Commit

Permalink
Remove concept of NuGet package backup path
Browse files Browse the repository at this point in the history
  • Loading branch information
shaynevanasperen committed Feb 19, 2015
1 parent 44008c6 commit a1c80e0
Showing 1 changed file with 24 additions and 49 deletions.
73 changes: 24 additions & 49 deletions PowerTasks/.Tasks/Push.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
$script:buildsPath = (property buildsPath $basePath\builds)
$script:nugetPackageSource = (property nugetPackageSource "")
$script:nugetPackageSourceApiKey = (property nugetPackageSourceApiKey "LoadFromNuGetConfig")
$script:nugetPackageSourceBackupPath = (property nugetPackageSourceBackupPath "")
$script:nugetSymbolsPackageSource = (property nugetSymbolsPackageSource "")
$script:nugetSymbolsPackageSourceApiKey = (property nugetSymbolsPackageSourceApiKey "LoadFromNuGetConfig")

Expand All @@ -11,64 +10,40 @@ task Push {
"No packages were found in $buildsPath. Please build some packages first."
}
else {
"Found the following packages:"
"Pushing the following packages:"
$packages | Select -ExpandProperty Name | Write-Host

if (!$nugetPackageSourceBackupPath) {
$nugetPackageSourceBackupPath = Read-Host "Please enter NuGet package source backup path"
if (!$nugetPackageSource) {
$nugetPackageSource = Read-Host "Please enter NuGet package source"
}
if ($nugetPackageSourceBackupPath) {
$pushedPackages = @(Get-ChildItem $nugetPackageSourceBackupPath\*.nupkg | Select -ExpandProperty Name)
$packageSourceIsHttp = $nugetPackageSource.ToLower().StartsWith("http")
if (!$nugetPackageSourceApiKey -and $packageSourceIsHttp) {
$nugetPackageSourceApiKey = Read-Host "Please enter NuGet package source API key"
}
else {
$pushedPackages = @()
}
$newPackages = @($packages | Where-Object { $pushedPackages -notcontains $_.Name })

if ($newPackages.Count -gt 0) {
"Pushing the following packages:"
$newPackages | Select -ExpandProperty Name | Write-Host

if (!$nugetPackageSource) {
$nugetPackageSource = Read-Host "Please enter NuGet package source"
# NuGet.exe automatically pushes symbols package to http://nuget.gw.symbolsource.org/Public/NuGet when pushing main package to https://www.nuget.org
if (!$nugetPackageSource.StartsWith("https://www.nuget.org") -and @($packages | Where-Object { $_.Name.EndsWith("symbols.nupkg") }).Count -gt 0) {
if (!$nugetSymbolsPackageSource) {
$nugetSymbolsPackageSource = Read-Host "Please enter NuGet symbols package source"
}
$packageSourceIsHttp = $nugetPackageSource.ToLower().StartsWith("http")
if (!$nugetPackageSourceApiKey -and $packageSourceIsHttp) {
$nugetPackageSourceApiKey = Read-Host "Please enter NuGet package source API key"
}

# NuGet.exe automatically pushes symbols package to http://nuget.gw.symbolsource.org/Public/NuGet when pushing main package to https://www.nuget.org
if (!$nugetPackageSource.StartsWith("https://www.nuget.org") -and @($newPackages | Where-Object { $_.Name.EndsWith("symbols.nupkg") }).Count -gt 0) {
if (!$nugetSymbolsPackageSource) {
$nugetSymbolsPackageSource = Read-Host "Please enter NuGet symbols package source"
}
if ($nugetSymbolsPackageSource) { # A symbols package source is optional
$symbolsPackageSourceIsHttp = $nugetSymbolsPackageSource.ToLower().StartsWith("http")
if (!$nugetSymbolsPackageSourceApiKey -and $packageSourceIsHttp) {
$nugetSymbolsPackageSourceApiKey = Read-Host "Please enter NuGet symbols package source API key"
}
}
}
else {
$nugetSymbolsPackageSource = $null
}

foreach($newPackage in $newPackages) {
if ($newPackage.Name.EndsWith("symbols.nupkg") -and $nugetSymbolsPackageSource) {
Push-Package $basePath $newPackage $nugetSymbolsPackageSource $nugetSymbolsPackageSourceApiKey
}
else {
Push-Package $basePath $newPackage $nugetPackageSource $nugetPackageSourceApiKey
}

if ($nugetPackageSourceBackupPath -and $nugetPackageSourceBackupPath -ne $nugetPackageSource) {
"Backing up $($newPackage.Name) to $nugetPackageSourceBackupPath"
Copy-Item $newPackage $nugetPackageSourceBackupPath
if ($nugetSymbolsPackageSource) { # A symbols package source is optional
$symbolsPackageSourceIsHttp = $nugetSymbolsPackageSource.ToLower().StartsWith("http")
if (!$nugetSymbolsPackageSourceApiKey -and $packageSourceIsHttp) {
$nugetSymbolsPackageSourceApiKey = Read-Host "Please enter NuGet symbols package source API key"
}
}
}
else {
"No new packages were found that need to be pushed"
$nugetSymbolsPackageSource = $null
}

foreach($package in $packages) {
if ($package.Name.EndsWith("symbols.nupkg") -and $nugetSymbolsPackageSource) {
Push-Package $basePath $package $nugetSymbolsPackageSource $nugetSymbolsPackageSourceApiKey
}
else {
Push-Package $basePath $package $nugetPackageSource $nugetPackageSourceApiKey
}
}
}
}

0 comments on commit a1c80e0

Please sign in to comment.