PowerShell/PowerShellGetv2

Recent failure in build pipeline with Publish-Module related to prerelease versioning

petrsnd opened this issue · 2 comments

I have been publishing a PowerShell module for many years. Between released versions I publish my module to PowerShellGallery with the '-pre' tag. Upon merging recent code changes, my pipeline began failing. I believe this to be a bug because my module conforms to the guidance provider here:
https://docs.microsoft.com/en-us/powershell/scripting/gallery/concepts/module-prerelease-support?view=powershell-7.2

I also commented on a similar issue in PowerShellGallery repo:
PowerShell/PowerShellGallery#217

Steps to reproduce

Create a new script module. Use the prerelease tagging. Here is a sample from my psd1.

@{
ModuleVersion = '6.13.48351'
PrivateData = @{
    PSData = @{
        Prerelease = '-pre'
    }
}

Expected behavior

Module should publish successfully.

Actual behavior

##[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'.

Environment data

Using windows-latest in Azure Pipelines. Here are some excerpts from the output.

##[warning]windows-latest pipelines will use windows-2022 soon. For more details, see https://github.com/actions/virtual-environments/issues/4856
Pool: [Azure Pipelines](https://dev.azure.com/1id/190431ef-1ebe-42d8-be88-778348564c8c/_settings/agentqueues?poolId=&queueId=525)
Image: windows-latest
Agent: Hosted Agent
Started: Today at 4:12 PM
Duration: 2m 22s

Job preparation parameters
Job live console data:
Finishing: Windows - Build module and Docker image, publish to PowerShell Gallery, and publish to Docker Hub
Starting: Initialize job
Agent name: 'Hosted Agent'
Agent machine name: 'WIN-AC2KPEJO0U3'
Current agent version: '2.200.2'
Operating System
Virtual Environment
Virtual Environment Provisioner
Current image version: '20220223.1'
Agent running as: 'VssAdministrator'
Prepare build directory.
Set build variables.
Download all required tasks.
Downloading task: PowerShell (2.198.0)
Downloading task: Bash (3.198.0)
Downloading task: AzureKeyVault (1.198.0)
Checking job knob settings.
   Knob: AgentToolsDirectory = C:\hostedtoolcache\windows Source: ${AGENT_TOOLSDIRECTORY} 
   Knob: AgentPerflog = C:\agents\perflog Source: ${VSTS_AGENT_PERFLOG} 
Finished checking job knob settings.
Plugin: 'Test Result Parser plugin' is running in background.
Plugin: 'Test File Publisher plugin' is running in background.
Start tracking orphan processes.
Finishing: Initialize job
Starting: Publish PowerShell module to PowerShell Gallery
==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Linux, macOS, or Windows
Version      : 2.198.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\ad51c51b-39be-4c87-a17e-a7d1ced3424e.ps1'"

Name                           Version          Source           Summary                                               
----                           -------          ------           -------                                               
nuget                          2.8.5.208        https://onege.../ NuGet provider for the OneGet meta-package manager    

Name                      : PSGallery
SourceLocation            : https://www.powershellgallery.com/api/v2
Trusted                   : False
Registered                : True
InstallationPolicy        : Untrusted
PackageManagementProvider : NuGet
PublishLocation           : https://www.powershellgallery.com/api/v2/package/
ScriptSourceLocation      : https://www.powershellgallery.com/api/v2/items/psscript
ScriptPublishLocation     : https://www.powershellgallery.com/api/v2/package/
ProviderOptions           : {}

Same issue. Using pre-release versions using documented guidance.

This issue should be resolved and tracked here