Skip to content

Build bug in build.psm1 line 843: bad environment variable check #26727

@mwherman2000

Description

@mwherman2000

Prerequisites

Steps to reproduce

I'm a newbie ...clean laptop. The build steps...

Import-Module ./build.psm1
Start-PSBuild -Clean -PSModuleRestore -UseNuGetOrg

failed at line 843 in build.psm1. Replacing line 843 (the commented statement) with the following fixed it:

    #$runtimePattern += $environment.OSArchitecture.ToString()
    if ($PSVersionTable.PSVersion.Major -ge 7) {
        $arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString()
    } else {
        $arch = if ([Environment]::Is64BitOperatingSystem) { 'X64' } else { 'X86' }
    }
    $runtimePattern += $arch

Expected behavior

Expect Start-PSBuild -Clean -PSModuleRestore -UseNuGetOrg to complete cleanly.

Actual behavior

$runtimePattern += $environment.OSArchitecture.ToString() failed.

$environment.OSArchitecture on my laptop was returning a null

Error details

The property 'OSArchitecture' cannot be found on this object. Verify that the property exists. At C:\tdw\repos\PowerShell\build.psm1:843 char:5 + $runtimePattern += $environment.OSArchitecture.ToString() + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException + FullyQualifiedErrorId : PropertyNotFoundStrict VERBOSE: runtime pattern check: win7-x64 -match ^win.*- VERBOSE: Generating experimental feature list VERBOSE: Build experimental feature list by running 'Get-ExperimentalFeature'

Environment data

PS C:\TDW\repos\PowerShell> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.26200
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS C:\TDW\repos\PowerShell>

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions