microsoft / StoreBroker

A PowerShell module that leverages the Windows Store Submission API to allow easy automation of application submissions to the Windows Store. The master branch is stable and the v2 branch is under active development.
Other
97 stars 40 forks source link

Exception in PackageTool.ps1 with Powershell 7.4 #240

Closed camnewnham closed 7 months ago

camnewnham commented 7 months ago

Github Actions runners have just been updated from Powershell Core to Powershell 7.4.x : https://github.com/actions/runner-images/issues/9115

This is causing an exception in PackageTool.ps1:

Write-Error: C:\Users\runneradmin\Documents\PowerShell\Modules\StoreBroker\1.21.0\StoreBroker\PackageTool.ps1:3760
Line |
3760 |          Write-Log -Exception $_ -Level Error
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | 2024-02-01 00:48:28 : runneradmin : DeepCopy-Object:
     | C:\Users\runneradmin\Documents\PowerShell\Modules\StoreBroker\1.21.0\StoreBroker\PackageTool.ps1:2660 Line |
     | 2660 |      $requestBody = DeepCopy-Object -Object $SubmissionRequestBody      |                    
     | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      | Exception calling "Serialize" with "2" argument(s): "Type
     | 'System.Management.Automation.PSObject' in Assembly      | 'System.Management.Automation, Version=7.4.1.500,
     | Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not      | marked as serializable."
HowardWolosky commented 7 months ago

The source of the problem is explained well here: microsoft/PowerShellForGitHub#413, and an appropriate fix that could be used in this project can be seen in microsoft/PowerShellForGitHub#415

camnewnham commented 7 months ago

Thanks @HowardWolosky, Is there anything I can do to work around this as a user or do I need to wait for an update from the maintainers? (I can see your list amongst the commits a few years ago!)

HowardWolosky commented 7 months ago

Fixed by #241 for StoreBroker v1 and #242 for StoreBroker v2.

Not sure if I'll be able to put out an updated nuget package or get an update out to PowerShellGallery in the near future, but if you have your Action pull from this repo directly and then import the module, you should be unblocked.

szujak commented 7 months ago

Hello @HowardWolosky, do you have any estimation when this fix can be published in PowerShellGallery? It seems to me that pulling directly from github repo and building it inside of github action is not the best long term solution.

camnewnham commented 7 months ago

Thanks @HowardWolosky For anyone coming across this I added this to the start of my StoreBroker CI...

git clone https://github.com/microsoft/StoreBroker.git
Import-Module .\StoreBroker\StoreBroker\StoreBroker.psd1 -Verbose
camnewnham commented 7 months ago

@HowardWolosky I'm still getting an exception with PackageTool:

Write-Error: D:\a\..\..\StoreBroker\StoreBroker\PackageTool.ps1:3760
Line |
3760 |          Write-Log -Exception $_ -Level Error
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | 2024-02-02 00:26:10 : runneradmin : Remove-DeprecatedProperties:
     | D:\a\xr.unity\xr.unity\StoreBroker\StoreBroker\PackageTool.ps1:2828 Line | 2828 |  … questBody =
     | Remove-DeprecatedProperties -SubmissionRequestBody $submi …      |               
     | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      | You cannot call a method on a null-valued
     | expression.
Error: Process completed with exit code 1.

Or have I done the import/update wrong?

szujak commented 7 months ago

Thanks @camnewnham importing was successfull, but I also got another issue

Write-Error: C:\x\.github\windows\StoreBroker\StoreBroker\PackageTool.ps1:3760
Line |
3760 |          Write-Log -Exception $_ -Level Error
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | 2024-02-02 07:01:44 : runneradmin : Convert-ListingToObject:
     | C:\x\.github\windows\StoreBroker\StoreBroker\PackageTool.ps1:1390 Line | 1390 |         
     | Convert-ListingToObject -PDPRootPath $PDPRootPath -LanguageEx …      |         
     | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      | Cannot bind argument to parameter
     | 'NamespaceUri' because it is an empty string.
Error: Process completed with exit code 1.
HowardWolosky commented 7 months ago

@szujak - The problem you're seeing is unrelated to this problem. Go ahead and file a different issue, and try to provide additional lines from your StoreBroker.log file leading up to that error. The root issue it points to is that the .xml file that your using for your PDP files is missing a namespace attribute. In the new issue that you open, you can cover how you created those PDP files and possibly even share a sample one.

HowardWolosky commented 7 months ago

@camnewnham - Nothing wrong on your end. I did a bad merge. Parameter for DeepCopy-Object in this project is Object, but the new code is referencing InputObject. Will get that fixed.

HowardWolosky commented 7 months ago

@camnewnham The problem you were seeing should now be fixed as of #246.

zhuxb711 commented 7 months ago

@HowardWolosky When will be a new release in the PSGallery?

HowardWolosky commented 7 months ago

@HowardWolosky When will be a new release in the PSGallery?

Likely early this week.

HowardWolosky commented 7 months ago

This fix has now been published to PowerShellGallery.

/cc: @zhuxb711, @camnewnham, @szujak

camnewnham commented 7 months ago

Fantastic, we appreciate the quick triage @HowardWolosky :)