Skip to content

get-dotnetup.ps1: intermittent 'OSArchitecture' PropertyNotFoundException under strict mode #54683

@nagilson

Description

@nagilson

Summary

The get-dotnetup.ps1 script (downloaded from https://aka.ms/dotnetup/get-dotnetup.ps1) occasionally fails with:

The property 'OSArchitecture' cannot be found on this object. Verify that the property exists.

Error category: PropertyNotFoundStrict,get-dotnetup.ps1

Repro

Run .\eng\common\darc-init.ps1 or any path that triggers �ng/configure-toolset.ps1 → Install-DotnetupFromAkaMs. The failure is intermittent.

Stack trace from user report

`
D:\repos\sdk\scripts\get-dotnetup.ps1 : The property 'OSArchitecture' cannot be found on this object. Verify that the property exists.
At D:\repos\sdk\eng\configure-toolset.ps1:58 char:9

  •     & (Join-Path $RepoRoot 'scripts\get-dotnetup.ps1') -InstallDi ...
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [get-dotnetup.ps1], PropertyNotFoundException
    • FullyQualifiedErrorId : PropertyNotFoundStrict,get-dotnetup.ps1
      `

Root cause hypothesis

The downloaded get-dotnetup.ps1 script likely uses Set-StrictMode and accesses [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture without a try/catch guard. On Windows PowerShell 5.1 with older .NET Framework versions (pre-4.7.1), or in rare cases where the assembly isn't fully loaded, the property doesn't exist on the resolved type, triggering a PropertyNotFoundException.

Suggested fix

Wrap the OSArchitecture access in the get-dotnetup.ps1 script with a try/catch fallback, similar to what the SDK repo already does in �ng/sdk-tools.ps1:

powershell function Get-NativeMachineArchitecture { try { return ConvertTo-RidArchitecture ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) } catch { # Fallback for environments where RuntimeInformation is unavailable return "x64" } }

Environment

  • Windows PowerShell 5.1
  • Intermittent — rare but blocks SDK bootstrap when it occurs

Metadata

Metadata

Labels

dotnetupWork items around the proposed `dotnetup` bootstrapper/toolchain management tool and library

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions