winbench / bench

Portable Software Environment for Windows
https://winbench.org
MIT License
20 stars 3 forks source link

Compatibility with PowerShell 2 under a fresh Windows 7 #29

Closed mastersign closed 8 years ago

mastersign commented 8 years ago

One hinderance is the use of the -in operator, which was introduced with PS3

mastersign commented 8 years ago

Another hinderance is the use of Invoke-WebRequest wich was introduced with PS3

mastersign commented 8 years ago

The last hinderance is the different behavior of foreach in PS2

mastersign commented 8 years ago

Replaced operator -in with -contains in 9213a0d06304073fe50a003d47bf396538ed1618 and 2e928d047f864d78278b760e9d4711edb0a5e97f

mastersign commented 8 years ago

Rewrote download from Invoke-WebRequest to direct use of System.Net.WebClient in 058981ffca74bd429cab701373014157d2735422

mastersign commented 8 years ago

Before PowerShell 3, the for-each loop goes through one iteration, if the collection is $null. Since PowerShell 3, no iteration is executed, if the collection is $null. To avoid wrapping the for-each block in another code block, the following check is introduced in almost all for-each loops.

foreach ($e in $elements)
{
    if (!$e) { continue }  # check if the iterated element is $null, 0 or empty
    ...
}

Sanitized foreach loops in 12417d49c26bcadc9d6c051e775f29d3bf2e81fc

mastersign commented 8 years ago

Error during Setup: Did not find an overload with 3 arguments for Combine.

mastersign commented 8 years ago

The .NET Framework 2.0 under a fresh Windows 7 does not support System.IO.Path.Combine() with more than two arguments.

mastersign commented 8 years ago

Resolved by b22a220fe1edd891fb11faadd0a3bfea4619e5b7