Skip to content

Conversation

johlju
Copy link
Contributor

@johlju johlju commented Feb 22, 2025

This will fix issue #135.

In Windows PowerShell this will not work:

@{
    Version       = if (($V = $BuildInfo.SemVer.Split("+")[0].Split("-", 2)[0])) {
                        [version]$V
                    }
    Prerelease    = $BuildInfo.SemVer.Split("+")[0].Split("-", 2)[1]
    BuildMetadata = $BuildInfo.SemVer.Split("+", 2)[1]
}

but this will:

@{
    Prerelease    = $BuildInfo.SemVer.Split("+")[0].Split("-", 2)[1]
    BuildMetadata = $BuildInfo.SemVer.Split("+", 2)[1]
    Version       = if (($V = $BuildInfo.SemVer.Split("+")[0].Split("-", 2)[0])) {
                        [version]$V
                    }
}

By moving the Version property at the end there is no parse error.

This error does not occur on PowerShell 7.x. It handles if-blocks in hashtables better apparently.

@dan-hughes
Copy link

@Jaykul, any chance you can get this merged? Anything testing with PS5 is failing currently.

@Jaykul
Copy link
Member

Jaykul commented Apr 12, 2025

Holy cow, I thought we already merged this ...

@Jaykul Jaykul merged commit b4d5aaf into PoshCode:main Apr 12, 2025
4 checks passed
@johlju johlju deleted the fix/issue-135 branch April 13, 2025 08:40
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

Successfully merging this pull request may close these issues.

3 participants