diff --git a/src/chocolatey.ps1 b/src/chocolatey.ps1 index c858882..17b124c 100644 --- a/src/chocolatey.ps1 +++ b/src/chocolatey.ps1 @@ -1,7 +1,7 @@ param( [string]$command, [string]$packageName='', - [string]$source='https://go.microsoft.com/fwlink/?LinkID=230477', + [string]$source='', [string]$version='', [alias("all")][switch] $allVersions = $false, [alias("ia","installArgs")][string] $installArguments = '', diff --git a/src/functions/Chocolatey-Install.ps1 b/src/functions/Chocolatey-Install.ps1 index 117ec35..7364465 100644 --- a/src/functions/Chocolatey-Install.ps1 +++ b/src/functions/Chocolatey-Install.ps1 @@ -1,7 +1,7 @@ function Chocolatey-Install { param( [string] $packageName, - [string] $source = 'https://go.microsoft.com/fwlink/?LinkID=230477', + [string] $source = '', [string] $version = '', [string] $installerArguments = '' ) diff --git a/src/functions/Chocolatey-InstallIfMissing.ps1 b/src/functions/Chocolatey-InstallIfMissing.ps1 index eb15115..4cc4d3f 100644 --- a/src/functions/Chocolatey-InstallIfMissing.ps1 +++ b/src/functions/Chocolatey-InstallIfMissing.ps1 @@ -1,7 +1,7 @@ function Chocolatey-InstallIfMissing { param( [string] $packageName, - [string] $source = 'https://go.microsoft.com/fwlink/?LinkID=230477', + [string] $source = '', [string] $version = '' ) diff --git a/src/functions/Chocolatey-List.ps1 b/src/functions/Chocolatey-List.ps1 index daa2489..1114886 100644 --- a/src/functions/Chocolatey-List.ps1 +++ b/src/functions/Chocolatey-List.ps1 @@ -1,7 +1,7 @@ function Chocolatey-List { param( [string] $selector='', - [string] $source='https://go.microsoft.com/fwlink/?LinkID=230477' + [string] $source='' ) if ($source -like 'webpi') { @@ -9,10 +9,7 @@ param( & cmd.exe $webpiArgs } else { - $srcArgs = "-Source `"$source`"" - if ($source -like 'https://go.microsoft.com/fwlink/?LinkID=230477') { - $srcArgs = "-Source `"http://chocolatey.org/api/v2/`" -Source `"$source`"" - } + $srcArgs = Get-SourceArgument $source $parameters = "list" if ($selector -ne '') { diff --git a/src/functions/Chocolatey-NuGet.ps1 b/src/functions/Chocolatey-NuGet.ps1 index 13810f7..bc8ab94 100644 --- a/src/functions/Chocolatey-NuGet.ps1 +++ b/src/functions/Chocolatey-NuGet.ps1 @@ -1,7 +1,7 @@ function Chocolatey-NuGet { param( [string] $packageName, - [string] $source = 'https://go.microsoft.com/fwlink/?LinkID=230477' + [string] $source = '' ) if ($packageName -eq 'all') { @@ -9,14 +9,14 @@ param( return } - $srcArgs = "$source" - if ($source -like 'https://go.microsoft.com/fwlink/?LinkID=230477') { - $srcArgs = "http://chocolatey.org/api/v2/ OR $source" + $srcArgs = "" + if ($source -ne '') { + $srcArgs = "(from $source)" } @" $h1 -Chocolatey ($chocVer) is installing $packageName (from $srcArgs) to "$nugetLibPath". By installing you accept the license for the package you are installing (please run chocolatey /? for full license acceptance terms). +Chocolatey ($chocVer) is installing $packageName $srcArgs to "$nugetLibPath". By installing you accept the license for the package you are installing (please run chocolatey /? for full license acceptance terms). $h1 "@ | Write-Host diff --git a/src/functions/Chocolatey-Push.ps1 b/src/functions/Chocolatey-Push.ps1 index f8680ea..02b4979 100644 --- a/src/functions/Chocolatey-Push.ps1 +++ b/src/functions/Chocolatey-Push.ps1 @@ -5,9 +5,6 @@ param( ) $srcArgs = "-source $source" - if ($source -like 'https://go.microsoft.com/fwlink/?LinkID=230477') { - $srcArgs = "-source http://chocolatey.org/" - } $packageArgs = "push $packageName $srcArgs" $logFile = Join-Path $nugetChocolateyPath 'push.log' diff --git a/src/functions/Chocolatey-Update.ps1 b/src/functions/Chocolatey-Update.ps1 index 87c6994..564d326 100644 --- a/src/functions/Chocolatey-Update.ps1 +++ b/src/functions/Chocolatey-Update.ps1 @@ -1,7 +1,7 @@ function Chocolatey-Update { param( [string] $packageName ='', - [string] $source = 'https://go.microsoft.com/fwlink/?LinkID=230477' + [string] $source = '' ) if ($packageName -eq '') {$packageName = 'chocolatey';} diff --git a/src/functions/Chocolatey-Version.ps1 b/src/functions/Chocolatey-Version.ps1 index 8298fd6..18ba858 100644 --- a/src/functions/Chocolatey-Version.ps1 +++ b/src/functions/Chocolatey-Version.ps1 @@ -1,7 +1,7 @@ function Chocolatey-Version { param( [string] $packageName='', - [string] $source='https://go.microsoft.com/fwlink/?LinkID=230477' + [string] $source='' ) if ($packageName -eq '') {$packageName = 'chocolatey';} @@ -12,10 +12,7 @@ param( $packages = $packageFolders -replace "(\.\d{1,})+"|gu } - $srcArgs = "-Source `"$source`"" - if ($source -like 'https://go.microsoft.com/fwlink/?LinkID=230477') { - $srcArgs = "-Source `"http://chocolatey.org/api/v2/`" -Source `"$source`"" - } + $srcArgs = Get-SourceArgument $source foreach ($package in $packages) { $packageArgs = "list ""$package"" $srcArgs" diff --git a/src/functions/Get-SourceArgument.ps1 b/src/functions/Get-SourceArgument.ps1 new file mode 100644 index 0000000..3f6c5d1 --- /dev/null +++ b/src/functions/Get-SourceArgument.ps1 @@ -0,0 +1,26 @@ +function Get-SourceArgument { +param( + [string] $source = '' +) + $srcArgs = "" + if ($source -ne '') { + $srcArgs = "-Source `"$source`"" + } + else + { + $useNugetConfig = Get-ConfigValue 'useNuGetForSources' + + if ($useNugetConfig -eq 'false') { + $sources = Get-ConfigValue 'sources' + + foreach ($sourceEntry in $sources.ChildNodes) { + $srcUri = $sourceEntry.value + $srcArgs = $srcArgs + "-Source `"$srcUri`" " + } + } + } + + Write-Debug "Source args: $srcArgs" + + $srcArgs +} \ No newline at end of file diff --git a/src/functions/Run-NuGet.ps1 b/src/functions/Run-NuGet.ps1 index 4e10677..d142915 100644 --- a/src/functions/Run-NuGet.ps1 +++ b/src/functions/Run-NuGet.ps1 @@ -1,7 +1,7 @@ function Run-NuGet { param( [string] $packageName, - [string] $source = 'https://go.microsoft.com/fwlink/?LinkID=230477', + [string] $source = '', [string] $version = '' ) @" @@ -10,14 +10,7 @@ NuGet $h2 "@ | Write-Debug - $srcArgs = "-Source `"$source`"" - if ($source -like 'https://go.microsoft.com/fwlink/?LinkID=230477') { - $srcArgs = "-Source `"http://chocolatey.org/api/v2/`" -Source `"$source`"" - } - - if ($source -like '') { - $srcArgs = "-Source `"http://chocolatey.org/api/v2/`" -Source `"https://go.microsoft.com/fwlink/?LinkID=230477`"" - } + $srcArgs = Get-SourceArgument $source $packageArgs = "install $packageName -Outputdirectory `"$nugetLibPath`" $srcArgs" if ($version -notlike '') {