chocolatey-community / simple-server

The Chocolatey Simple Server - https://community.chocolatey.org/packages/chocolatey.server
Apache License 2.0
44 stars 17 forks source link

Pushing with nuget.exe with versions higher than 2.x fails #52

Open darksidemilk opened 5 years ago

darksidemilk commented 5 years ago

Background

I recently discovered I could use the built-in powershell modules powershellget and packagemanagement to push/publish powershell modules and scripts to my chocolatey simple server using publish-module and publish-script. Then those modules and scripts can be used on computers in my enviornment by installing them with install-module and install-script if I add my chocolatey server to a computer with register-psrepository. I even figured out that if I simply add a tools folder and a templated chocolateyinstall.ps1 (that runs install-module on the package) file in any module, I can also install it with choco commands and it will end up where it needs to be. After this discovery I found that there were newer versions of powershellget (1.6.7) and packagemanagement (1.1.7.2). So I went and started updating to the newer versions and all the install commands continued to work. Then I tried to publish something...

The Problem

In the PSGallery version of PowershellGet it attempts to add C:\ProgramData\Microsoft\Windows\Powershell\PowershellGet to the path and downloads nuget.exe to that path and attempts to sync the registered package sources with nuget.exe sources (side note, the adding to path and syncing nuget sources only seems to work when run from powershell core/powershell 6, but the functionality of it works if the steps are done manually). In version 1.6.0 and below it downloads nuget 2.8.x which works correctly. However in the versions after 1.6.0 such as the latest 1.6.7 it attempts to download the latest version of nuget, nuget 4.x. When this gets downloaded and a publish is attempted I get a 500 error that says something to effect of 'server did not indicate success' It looks like this

Publish-PSArtifactUtility : Failed to publish script 'Save-ChocoCommunityPackages': 'Response status code does not
indicate success: 500 (Internal Server Error).
'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.6.7\PSModule.psm1:11192 char:17
+ ...             Publish-PSArtifactUtility @PublishPSArtifactUtility_Param ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : FailedToPublishTheScript,Publish-PSArtifactUtility

I found nothing in the IIS logs or event viewer concerning the error. Was hoping there was so something would say something more. However, since downgrading to psget 1.6.0 and giving it nuget.exe 2.8.x allows it to work, I am lead to believe the issue is that chocolatey.server uses a version of nuget.server that isn't compatible with the newer nuget.exe

The acutal request of this issue

Make it so chocoatey simple server can accept pushes from nuget 4.x specifically when pushed through the publish-module command of powershellget 1.6.7

other notes

ferventcoder commented 5 years ago

Perhaps set this as an enhancement to support 4.x at some point?