majkinetor / au

Chocolatey Automatic Package Updater Module
GNU General Public License v2.0
227 stars 71 forks source link

Error on execution after running update.ps1, fixed by moving to powershell 5.1 #126

Closed tcase closed 6 years ago

tcase commented 6 years ago

Got this error message:

PowerShell Executable: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
[14:23:01][Step 2/6] Working directory: C:\BuildAgent\work\ef416d04e4069f12
[14:23:01][Step 2/6] PowerShell arguments: [-NonInteractive, -ExecutionPolicy, ByPass, -File, C:\BuildAgent\temp\buildTmp\powershell7967846516531932699.ps1]
[14:23:03][Step 2/6] Build parameters:
[14:23:03][Step 2/6]   Install              True
[14:23:03][Step 2/6]   NoChocoPackage       True
[14:23:03][Step 2/6] 
[14:23:03][Step 2/6] ==| Building AU 2018.2.28.222303
[14:23:03][Step 2/6] 
[14:23:03][Step 2/6] Removing older builds
[14:23:03][Step 2/6] Creating module manifest
[14:23:03][Step 2/6] ForEach-Object : At C:\BuildAgent\temp\buildTmp\au\_build\2018.2.28.222303\AU\P
[14:23:03][Step 2/6] rivate\AUPackage.ps1:56 char:17
[14:23:03][Step 2/6] +         $res = [ordered] @{}
[14:23:03][Step 2/6] +                 ~~~~~~~
[14:23:03][Step 2/6] Unable to find type [ordered].
[14:23:03][Step 2/6] At C:\BuildAgent\temp\buildTmp\au\_build\2018.2.28.222303\AU\Private\AUPackage.
[14:23:03][Step 2/6] ps1:68 char:48
[14:23:03][Step 2/6] +         if (!$this.Streams) { $this.Streams = [ordered] @{} }
[14:23:03][Step 2/6] +                                                ~~~~~~~
[14:23:03][Step 2/6] Unable to find type [ordered].
[14:23:03][Step 2/6] At C:\BuildAgent\temp\buildTmp\au\_build\2018.2.28.222303\AU\Private\AUPackage.
[14:23:03][Step 2/6] ps1:71 char:22
[14:23:03][Step 2/6] +         $versions = [ordered] @{}
[14:23:03][Step 2/6] +                      ~~~~~~~
[14:23:03][Step 2/6] Unable to find type [ordered].
[14:23:03][Step 2/6] At C:\BuildAgent\temp\buildTmp\au\_build\2018.2.28.222303\AU\Private\AUPackage.
[14:23:03][Step 2/6] ps1:101 char:30
[14:23:03][Step 2/6] +             $this.Streams = [ordered] @{}
[14:23:03][Step 2/6] +                              ~~~~~~~
[14:23:03][Step 2/6] Unable to find type [ordered].At 
[14:23:03][Step 2/6] C:\BuildAgent\temp\buildTmp\au\_build\2018.2.28.222303\AU\AU.psm1:5 char:36
[14:23:03][Step 2/6] +     ls $PSScriptRoot\$path\*.ps1 | % { . $_ }
[14:23:03][Step 2/6] +                                    ~~~~~~~~~~
[14:23:03][Step 2/6]     + CategoryInfo          : ParserError: (:) [ForEach-Object], ParseExceptio 
[14:23:03][Step 2/6]    n
[14:23:03][Step 2/6]     + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.ForEa 
[14:23:03][Step 2/6]    chObjectCommand
[14:23:03][Step 2/6]  

After upgrading from 5.0 to 5.1 no more issues, just need to update documentation to reflect that

majkinetor commented 6 years ago

Ordered exists from 3.

ghost commented 6 years ago

@majkinetor, i also faced same issue, solved it by upgrading powershell to version 5.1 (Server 2012 R2)

tcase commented 6 years ago

maybe there is some other dependency that is solved by the install of Windows Management Framework 5.1

tcase commented 6 years ago

I'm going to fix the title here to something less presumptuous

Thilas commented 6 years ago

[ordered] has indeed been existing since PowerShell 3.0 but can only be used to declare an OrderedDictionary, not to cast a hashtable. And I don't know why, but PS 5.0 considers AU does some casts here... Fixing this by replacing [ordered] by [System.Collections.Specialized.OrderedDictionary] to make AU work even on PowerShell 5.0.

Thilas commented 6 years ago

Fixed.