Skip to content

Parameter_for_build‐msvc20XX‐projects.md

Mr-Luckyowl edited this page Jul 28, 2026 · 1 revision

Parameter Documentation: build-msvc2022-projects.ps1 / build-msvc2026-projects.ps1

The build pipeline scripts utilize a parameterized input block to dynamically enforce specific global .NET SDK environments, bypassing local or corrupted user-level SDK paths.

## 1. Parameter Definition The following parameter block is implemented at the absolute top of both build scripts:

param (
    [ValidateSet("6.0", "7.0", "8.0", "9.0", "10.0")]
    [string]\$TargetDotNetVersion = "9.0"
)

## 2. Technical Mechanics

  • Default Behavior: If executed without explicit arguments, the parameter defaults to "9.0". The script then queries the 64-bit Windows Registry, locates the highest installed patch revision of the .NET 9.0 SDK (e.g., 9.0.316), and force-injects the path variables ($env:DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR and $env:MSBuildSDKsPath).
  • Validation: The [ValidateSet()] attribute restricts inputs strictly to standard LTS/STS releases between 6.0 and 10.0. Any unlisted version triggers a native PowerShell parser exception before the build engine initializes.

## 3. CLI Execution Examples

Execute with Default Configuration (.NET 9.0 Enforcement)

`.\build-msvc2022-projects.ps1`
`.\build-msvc2026-projects.ps1`

Force Target Environment to .NET 8.0 LTS

.\build-msvc2022-projects.ps1 -TargetDotNetVersion "8.0"

Force Target Environment to .NET 10.0

.\build-msvc2026-projects.ps1 -TargetDotNetVersion "10.0"

## 4. Scope and Limitations This parameter applies exclusively to the build automation files. Other files in this repository (profile.ps1, msvc_init.ps1, and detect-pwsh.ps1) run entirely parameterless or rely on interactive menu selections (ReadKey) during runtime.