Failed to run Get-S3Object: Method not found

Marcio's Avatar

Marcio

04 Mar, 2021 03:09 AM

Hello,

I am using Build Worker Image VS2019 but i cannot run Get-S3Object. It fails with the following message:
Get-S3Object : Method not found: 'Void Amazon.S3.Model.ListObjectsRequest.set_ExpectedBucketOwner(System.String)'.
At line:1 char:14
+ $exporteds = Get-S3Object -BucketName 'pdf2xl-vcpkg-exports' `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Get-S3Object], MissingMethodException
    + FullyQualifiedErrorId : System.MissingMethodException,Amazon.PowerShell.Cmdlets.S3.GetS3ObjectCmdlet

It is weird if I log in the machine and try to run manually, it succeeds.

I have already tried to Update-Module AWSPowerShell but the error persists.

All other S3 commands seems to succeed

  1. Support Staff 1 Posted by Feodor Fitsner on 04 Mar, 2021 03:23 AM

    Feodor Fitsner's Avatar

    The issue is that - ps: commands are running in the context of Build Agent .NET application which is referencing some AWS SDK assemblies.

    To fix this annoying issue you should wrap a call into another PowerShell, for example:

    - cmd: powershell -command Get-S3Object ...
    
  2. 2 Posted by Marcio on 04 Mar, 2021 07:48 PM

    Marcio's Avatar

    Thanks, that helped me.
    In the end, I managed to call the command with:

    $exports = powershell.exe -Command '(Get-S3Object -BucketName my-bucket-name).Key'
    $exports = $exports.split()
    
    Is there some other way to retrieve data without parsing it? I am throwing out object data and parsing the string by doing that way.
  3. Support Staff 3 Posted by Feodor Fitsner on 04 Mar, 2021 09:19 PM

    Feodor Fitsner's Avatar

    Well, good questions. Parsing is probably the easiest unless you put all the logic into a single build.ps1 and run it.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • appveyor_s3_failure.png 15.7 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac