Git Product home page Git Product logo

chocolatier's People

Contributors

ethanbergstrom avatar kendr1ck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kendr1ck sassdawe

chocolatier's Issues

Add-PackageSource does not work

This command does not do the expected

Add-PackageSource -Name Test1 -Location 'https://dscdo01:8080/AutomatedLab/_packaging/Software1/nuget/v2' -Trusted $true
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\Chocolatier\1.0.4\src\private\MiscHelpers.ps1:11 char:5
+     if($options.ContainsKey($script:additionalArguments)) {
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\Chocolatier\1.0.4\src\private\MiscHelpers.ps1:28 char:6
+     if ($options.ContainsKey('Force')) {
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
Nothing to change. Config already set.
New-PackageSource : The term 'New-PackageSource' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the 
path is correct and try again.
At C:\Program Files\WindowsPowerShell\Modules\Chocolatier\1.0.4\src\public\Add-PackageSource.ps1:30 char:2
+     New-PackageSource @packageSource
+     ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (New-PackageSource:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

The package source is created however:

PS C:\> Get-PackageSource

Name                             ProviderName     IsTrusted  Location                                                                                                                                        
----                             ------------     ---------  --------                                                                                                                                        
PSGallery                        PowerShellGet    False      https://www.powershellgallery.com/api/v2                                                                                                        
PowerShell                       PowerShellGet    True       https://dscdo01.contoso.com:8080/AutomatedLab/_packaging/PowerShell/nuget/v2                                                                    
Test1                            Chocolatier      True       https://chocolatey.org/api/v2/        

Find-Package needs some error handling

Find-Package did not work. As one can't specify the source, it is unclear where the cmdlet goes to.

PS C:\> Find-Package -Name putty
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\Chocolatier\1.0.4\src\private\Find-ChocoPackage.ps1:18 char:2
+     Confirm-VersionParameters -Name $Name -MinimumVersion $MinimumVer ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\Chocolatier\1.0.4\src\private\MiscHelpers.ps1:11 char:5
+     if($options.ContainsKey($script:additionalArguments)) {
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\Chocolatier\1.0.4\src\private\MiscHelpers.ps1:28 char:6
+     if ($options.ContainsKey('Force')) {
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\Chocolatier\1.0.4\src\private\Find-ChocoPackage.ps1:67 char:12
+ ...   } elseif ($minimumVersion -or $maximumVersion -or $options.Contains ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\Chocolatier\1.0.4\src\private\MiscHelpers.ps1:11 char:5
+     if($options.ContainsKey($script:additionalArguments)) {
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\Chocolatier\1.0.4\src\private\MiscHelpers.ps1:28 char:6
+     if ($options.ContainsKey('Force')) {
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
New-SoftwareIdentity : The term 'New-SoftwareIdentity' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, 
verify that the path is correct and try again.
At C:\Program Files\WindowsPowerShell\Modules\Chocolatier\1.0.4\src\private\ConvertTo-SoftwareIdentity.ps1:42 char:6
+                     New-SoftwareIdentity @swid
+                     ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (New-SoftwareIdentity:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Unable to register package source

Hello @ethanbergstrom,

I saw that there was a new version 1.2.0 of Chocolatier. I don't know if anyone has tested adding their own repository via "register-packagesource" commands, but I get an error in the 'name' parameter (see below)

PS C:\Windows\system32> Register-PackageSource -name TEST -location https://myrepo/nuget -provider Chocolatier -Trusted

WARNING: MSG:UnableToDownload «https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409» «»
WARNING: Unable to download the list of available providers. Check your internet connection.
Register-PackageSource : Cannot bind argument to parameter 'name' because it is an empty string.
At line:1 char:1

  • Register-PackageSource -name TEST -location https://myrepo ...
  •   + CategoryInfo          : InvalidData: (Microsoft.Power...erPackageSource:RegisterPackageSource) [Register-PackageSource], Exception
      + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,New-PackageSource,Microsoft.PowerShell.PackageManagement.Cmdlets.RegisterPackageSour 
     ce
    
    

Can you confirm. Do you have that the same problem?
Is this a mistake on the side of the new provider Chocolatier 1.2.0 ?

This problem does not occur in a e.g. 1.0.4 Chocolatier version.

Originally posted by @Gregoorio in jianyunt/ChocolateyGet#15 (comment)

Save-Package not implemented?

I hope I use all the cmdlets correctly now. I am trying to save packages from the public Chocolatey feed and re-publish them in an internal one hosted on Azure DevOps Server. The following script works fine with the NuGet provider but throws an error when switching to the Chocolatier provider:

if (([Net.ServicePointManager]::SecurityProtocol -band 'Tls12') -ne 'Tls12')
{
    [Net.ServicePointManager]::SecurityProtocol += [Net.SecurityProtocolType]::Tls12
}

if (-not (Find-PackageProvider Chocolatier -ErrorAction SilentlyContinue))
{
    Install-PackageProvider -Name Chocolatier
}
Import-PackageProvider -Name Chocolatier

$packageList = 'putty', 'winrar', 'notepadplusplus', 'microsoft-edge', 'vscode'
$tempFolder = mkdir C:\ChocoTemp -Force
$internalFeedUri = 'https://dscdo01:8080/AutomatedLab/_packaging/Software/nuget/v2'
$internalFeedApiKey = '[email protected]:Somepass1'
$publicFeedUri = 'https://chocolatey.org/api/v2/'

if (-not (Get-PackageSource -Name Software -ErrorAction SilentlyContinue))
{
    Register-PackageSource -Name Software -ProviderName Chocolatier -Location $internalFeedUri -Trusted
}
if (-not (Get-PackageSource -Name Choco -ErrorAction SilentlyContinue))
{
    Register-PackageSource -Name Choco -ProviderName Chocolatier -Location $publicFeedUri
}

foreach ($name in $packageList)
{
    if (-not ($p = Find-Package -Name $name -Source Choco))
    {
        Write-Error "Package '$name' could not be found at the source '$publicFeedUri'"
        continue
    }
    $p | Save-Package -Path $tempFolder
}

dir -Path $tempFolder | ForEach-Object {

    choco push $_.FullName -s $internalFeedUri --api-key $internalFeedApiKey

}

#Get-PackageSource -ProviderName Chocolatier | Unregister-PackageSource
WARNING: 'Chocolatier': Save-Package is not supported because Choco does not support downloading packages. «-f» «Chocolatier»
Save-Package : Unable to save the package ''.
At C:\Users\Install\Desktop\Chocolatier Loop 1.ps1:34 char:10
+     $p | Save-Package -Path $tempFolder
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power...ets.SavePackage:SavePackage) [Save-Package], Exception
    + FullyQualifiedErrorId : ProviderFailToDownloadFile,Microsoft.PowerShell.PackageManagement.Cmdlets.SavePackage

The warning can't be right as the 'Choco' package source does support downloading packages when using the NuGet provider.

Any tips for package provider not working

Trying the first few commands in the readme just generates errors:

PS C:\Windows\System32> Find-PackageProvider Chocolatier -verbose
VERBOSE: Acquiring providers for assembly: C:\program files\powershell\7\Modules\PackageManagement\coreclr\netstandard2.0\Microsoft.PackageManagement.ArchiverProviders.dll
VERBOSE: Acquiring providers for assembly: C:\program files\powershell\7\Modules\PackageManagement\coreclr\netstandard2.0\Microsoft.PackageManagement.CoreProviders.dll
VERBOSE: Acquiring providers for assembly: C:\program files\powershell\7\Modules\PackageManagement\coreclr\netstandard2.0\Microsoft.PackageManagement.MetaProvider.PowerShell.dll
VERBOSE: Acquiring providers for assembly: C:\program files\powershell\7\Modules\PackageManagement\coreclr\netstandard2.0\Microsoft.PackageManagement.NuGetProvider.dll
VERBOSE: Using the provider 'Bootstrap' for searching packages.
VERBOSE: Finding the package 'Bootstrap::FindPackage' 'Chocolatier','','','''.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Chocolatier'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'Chocolatier'.
Find-PackageProvider: No match was found for the specified search criteria and package name 'Chocolatier'. Try Get-PackageSource to see all available registered package sources.

And trying to install:

PS C:\Windows\System32> Install-PackageProvider Chocolatier -verbose
VERBOSE: Using the provider 'Bootstrap' for searching packages.
VERBOSE: Finding the package 'Bootstrap::FindPackage' 'Chocolatier','','','''.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Chocolatier'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'Chocolatier'.
Install-PackageProvider: No match was found for the specified search criteria for the provider 'Chocolatier'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags.

Several links suggested an issue with TLS, or with not trusting the package sources, so I set TLS1.2 and trusted both sources:

PS C:\Windows\System32> [Net.ServicePointManager]::SecurityProtocol
Tls12
PS C:\Windows\System32> Get-PackageSource

Name                             ProviderName     IsTrusted  Location
----                             ------------     ---------  --------
nuget.org                        NuGet            True       https://api.nuget.org/v3/index.json
PSGallery                        PowerShellGet    True       https://www.powershellgallery.com/api/v2

This is using the latest version of PowerShell, on a Windows 10 machine:

PS C:\Windows\System32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

I did download the package manually, and checked it has the needed tags.

Also note that the verbose seems to indicate the package is found, just throws an error at the end (and if I pass -AllVersions it has the line VERBOSE: Total package yield:'4' for the specified package 'Chocolatier'. but still then gives the error.

And, Find-Package Chocolatier does actually find the package (just Find-PackageProvider does not).

Choco does not install automatically with -force flag

PS C:\Users\WDAGUtilityAccount> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -force; install-packageprovider chocolatier -force; install-package firefox -providername chocolatier -force

Name                           Version          Source           Summary
----                           -------          ------           -------
PackageManagement              1.4.6            PSGallery        PackageManagement (a.k.a. OneGet) is a new way to d...
Chocolatier                    1.0.1            PSGallery        Package Management (OneGet) provider that facilitat...

Choco.exe is required to continue
Chocolatier is built on Choco.exe. Do you want Chocolatier to install Choco.exe from
'https://chocolatey.org/install.ps1' now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
Firefox                        v72.0.2          chocolatey

Using the -force flag with Chocolatier should also install Chocolatey (if not already installed) without prompting the user.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.