Quantcast
Channel: oneget Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 20

Commented Unassigned: Add verification of newly added package source using Add-Packagesource [14]

$
0
0
When using Add-PackageSource, there is no verification of whether the source actually exists. It just adds the source with no questions asked and you won't know until you attempt to find/install a package that the path is not valid.

```
Add-PackageSource -Name Fail -Location http://this.willnotwork.com/keeptrying -Provider Chocolatey
```
Even though this is obviously wrong, it is still added and appears in the list of sources when using Get-Packagesource.

Some sort of checking, be it using Invoke-WebRequest (if url; otherwise Test-Path for folder) or some other approach to verify the validity of the location would help to ensure that the proper package sources are being added to the list of available sources.
Comments: > Can't we just use -Force for that? I'm in favor of verification by default. I would vote for a -Force parameter as long as there is some sort of confirmation prompt if verification of the source fails during the addition of the package source and -Force is not specified. I am also in favor of it verifying by default and being ignored if the -Force parameter is used. Just an example of what I am talking about: ``` Function Add-PackageSource { [cmdletbinding()] Param ( $Name, $Location, $Provider, [switch]$Trusted, [switch]$Force ) If ($PSCmdlet.ShouldProcess("Add-PackageSource","$Location")) { $Verified = (Get-Random -InputObject ($False,$True)) # <Some code to check location is available> If (-Not $Verified) { If ($Force -OR $PSCmdlet.ShouldContinue("Continue adding $($Location)?","Unable to Verify!")) { #Continue adding the source } } } } ``` More info on cmdlets using Confirmation and -Force [here](http://msdn.microsoft.com/en-us/library/bb204629(v=vs.85).aspx) and [here](http://msdn.microsoft.com/en-us/library/dd878238(v=vs.85).aspx#RD05).

Viewing all articles
Browse latest Browse all 20

Trending Articles