PowerShell / PowerShellGallery

228 stars 65 forks source link

Publish-Module failing for 4 part version with a trailing .0 #217

Closed boblodgett closed 2 years ago

boblodgett commented 2 years ago

Starting today we are getting the following publish error:

Failed to publish module 'AWSPowerShell': 'nuget.exe failed to push Response status code does not indicate success: 400 (The package is invalid. The error encountered was:'Nuspec version 4.1.31 and PowerShell module manifest 4.1.31.0 version are mismatched'. Correct the error and try again.).

The versions are the same and we have always uploaded the 4 part versions with the trailing .0. The command runs, uploads to PowerShell Gallery where the nuspec appears to be created and then fails on a version check.

The module installs and is usable locally. Did version checking change? Is this an accurate error message?

UPDATE:

We changed our code to strip the .0 on a 4 part version to 3 parts and modules are publishing. However, this is a breaking change in behavior. I imagine any customers that are publishing 4 part versions with a trailing .0 are no longer able to publish.

floh96 commented 2 years ago

cc @alerickson

petrsnd commented 2 years ago

I have been publishing a PowerShell module for several years now. My method for publishing "-pre" tagged prerelease modules between released versions has worked until just recently when my pipeline began failing. Publish-Module is failing to publish if I have a prerelease tag with this mismatch message.

I believe a bug has been introduced, because my module definition conforms to the guidance here: https://docs.microsoft.com/en-us/powershell/scripting/gallery/concepts/module-prerelease-support?view=powershell-7.2

Error message:

##[error]Publish-PSArtifactUtility : Failed to publish module 'safeguard-ps': 'nuget.exe failed to push Response status code 
does not indicate success: 400 (The package is invalid. The error encountered was:'Nuspec version 6.13.48351-pre and 
PowerShell module manifest 6.13.48351 version are mismatched'. Correct the error and try again.).
'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:10990 char:17
+ ...             Publish-PSArtifactUtility @PublishPSArtifactUtility_Param ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : FailedToPublishTheModule,Publish-PSArtifactUtility
##[error]PowerShell exited with code '1'.

My .psd1 file contains the following:

@{
ModuleVersion = '6.13.48351'
PrivateData = @{
    PSData = @{
        Prerelease = '-pre'
    }
}
SydneyhSmith commented 2 years ago

Thank you both for posting this issue and for calling attention to this! Also apologies for the delay in response-- appreciate the patience!

@petrsnd if you update your script to Prerelease = 'pre' (ie take out the "-") it should publish okay, I will update the docs to make sure this is more clear....this has actually always been the intention but it looks like we had a longstanding bug which allowed the - and was inadvertently fixed when making updates to our publishing...apologies for all the confusion and time this stole trying to debug this issue!

@boblodgett you are correct on the current work around for this-- we are working on a bug fix for this. Apologies for the trouble this caused!

BethanyZhou commented 2 years ago

Hi @SydneyhSmith , Azure PowerShell team met this issue as well. Error message is as below:

NuGet Version: 4.7.1.5393 Pushing Az.Storage.4.3.1-preview.nupkg to 'https://www.poshtestgallery.com/api/v2/package/'... PUT https://www.poshtestgallery.com/api/v2/package/ BadRequest https://www.poshtestgallery.com/api/v2/package/ 6624ms Response status code does not indicate success: 400 (The package is invalid. The error encountered was:'Nuspec version 4.3.1-preview cast as 4.3.1.0 and PowerShell module manifest 4.3.1 version are mismatched'. Correct the error and try again.).

Please let me know when this bug is fixed.

boblodgett commented 2 years ago

@SydneyhSmith It looks like today the PowerShell Gallery team has tried a fix but it broke normal 3 digit version publishing?

We are now getting this error from using normal 3 digit versions:

196 | Failed to publish module 'AWSPowerShell': 'nuget.exe failed to push Response status code does not indicate success: 400 (The package is invalid. The error encountered was:'Nuspec version 4.1.39 cast as 4.1.39.0 and PowerShell module manifest 4.1.39 version are mismatched'. Correct the error and try again.). 197 | '. 198 | Fatal error publishing C:\codebuild\tmp\output\src214205391\src\PRIVATE-aws-tools-for-powershell-staging\Deployment\AWSPowerShell 199 | Write-Error: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:10990 200 | Line | 201 | 10990 | . Publish-PSArtifactUtility @PublishPSArtifactUtility_Param . 202 | | ~~~~~~~~~~~~~ 203 | | Failed to publish module 'AWSPowerShell': 'nuget.exe failed to push Response status code does not 204 | | indicate success: 400 (The package is invalid. The error encountered was:'Nuspec version 4.1.39 cast 205 | | as 4.1.39.0 and PowerShell module manifest 4.1.39 version are mismatched'. Correct the error and try

peombwa commented 2 years ago

Hi @SydneyhSmith, Microsoft Graph PowerShell SDK team is also encountering this error when publishing to https://www.powershellgallery.com/api/v2/package/.

2022-03-09T00:24:23.7154908Z Response status code does not indicate success: 400 (The package is invalid. The error encountered was:'Nuspec version 1.9.3 cast as 1.9.3.0 and PowerShell module manifest 1.9.3 version are mismatched'. Correct the error and try again.).
2022-03-09T00:24:23.7156166Z System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (The package is invalid. The error encountered was:'Nuspec version 1.9.3 cast as 1.9.3.0 and PowerShell module manifest 1.9.3 version are mismatched'. Correct the error and try again.).
SydneyhSmith commented 2 years ago

Apologies for all of the issues-- we are working to resolve this bug ASAP

jformacek commented 2 years ago

Having same problem with 3 digit version of module. Did not find workaround so far. Thanks for fixing ASAP.

anamnavi commented 2 years ago

This bug with versioning is now fixed. Thanks for everyone's patience on this and sorry for any inconvenience it caused! 3 digit and 4 digit versions both work, and prerelease versions when you specify the prelease value shouldn't contain "-" in the string (as per @SydneyhSmith comment above). We are updating the docs asap too. Please let us know if any issue is still faced wrt to this. Thanks :)