Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in PackageTool.ps1 with Powershell 7.4 #240

Closed
camnewnham opened this issue Feb 1, 2024 · 14 comments
Closed

Exception in PackageTool.ps1 with Powershell 7.4 #240

camnewnham opened this issue Feb 1, 2024 · 14 comments

Comments

@camnewnham
Copy link

Github Actions runners have just been updated from Powershell Core to Powershell 7.4.x : actions/runner-images#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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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
Copy link

szujak commented Feb 1, 2024

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
Copy link
Author

camnewnham commented Feb 1, 2024

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
Copy link
Author

@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
Copy link

szujak commented Feb 2, 2024

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
Copy link
Member

@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
Copy link
Member

@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
Copy link
Member

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

@zhuxb711
Copy link

zhuxb711 commented Feb 5, 2024

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

@HowardWolosky
Copy link
Member

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

Likely early this week.

@HowardWolosky
Copy link
Member

This fix has now been published to PowerShellGallery.

/cc: @zhuxb711, @camnewnham, @szujak

@camnewnham
Copy link
Author

Fantastic, we appreciate the quick triage @HowardWolosky :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants