forked from chocolatey-archive/chocolatey
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Chocolatey-InstallAll.ps1
40 lines (35 loc) · 1.39 KB
/
Chocolatey-InstallAll.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function Chocolatey-InstallAll {
param(
[string] $source = ''
)
Write-Debug "Running 'Chocolatey-InstallAll' with source:`'$source`'";
if ($source -eq '' -or $source -eq 'https://go.microsoft.com/fwlink/?LinkID=230477' -or $source -eq 'https://chocolatey.org/api/v2/') {
write-host 'Source must be specified and cannot be nuget.org/chocolatey.org'
return
}
if ($source.StartsWith('http')) {
$webClient = New-Object System.Net.WebClient
$defaultCreds = [System.Net.CredentialCache]::DefaultCredentials
if ($defaultCreds -ne $null) {
$webClient.Credentials = $defaultCreds
}
if (!$source.EndsWith('/')) { $source = $source + '/' }
$feedUrl = $source + 'Packages/'
write-host "Installing all packages from $feedUrl"
$feed = [xml]$webClient.DownloadString($feedUrl)
$entries = $feed | select -ExpandProperty feed | select -ExpandProperty entry
foreach ($entry in $entries) {
if ($entry.properties.id -ne $null) {
$pkgId = $entry.properties.id
$pkgVersion = $entry.properties.version
Chocolatey-Nuget "$pkgId" -version $pkgVersion -source $source
}
}
} else {
$files = get-childitem $source -include *.nupkg -recurse
foreach ($file in $files) {
$packageName = $file.Name -replace "(\.\d{1,})+.nupkg"
Chocolatey-Nuget $packageName -source $source
}
}
}