Skip to content

Expose the NT_TARGET_VERSION in the build samples script & workflow update#1397

Open
5an7y-Microsoft wants to merge 7 commits into
microsoft:mainfrom
5an7y-Microsoft:main
Open

Expose the NT_TARGET_VERSION in the build samples script & workflow update#1397
5an7y-Microsoft wants to merge 7 commits into
microsoft:mainfrom
5an7y-Microsoft:main

Conversation

@5an7y-Microsoft

@5an7y-Microsoft 5an7y-Microsoft commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Driver samples in this repo are Universal / Windows‑Driver‑platform drivers (Windows 10+), so the Target OS Version can't be lowered to build "downlevel". The axis that is meaningful is _NT_TARGET_VERSION — the version of the WDK libraries a driver links against. This PR exposes that axis, lets it be exercised across the build matrix, records the samples that can't link against older libraries, and makes both the version list and the CI matrix auto‑discovered (no hand‑maintained version list anywhere).

What changed

  • Build-Samples.ps1 — new -NtTargetVersion parameter (also WDS_NtTargetVersion). Accepts 10.0.<build> or the short <build> tag; defaults to the latest. Valid values, and their NTDDI codes, are resolved at build time (no hard‑coded list). Also emits an easy‑to‑scan GitHub job summary ($GITHUB_STEP_SUMMARY).
  • Get-NtTargetVersions.ps1 (new) — auto‑discovers the valid _NT_TARGET_VERSION values by parsing the active WDK's DriverGeneral.xml rule (from the restored NuGet package or the installed WDK). A new WDK version is picked up automatically.
  • exclusions.csv — new optional MinNtTargetVersion / MaxNtTargetVersion columns (inclusive range; blank = unbounded) plus per‑sample exclusions for the samples that only fail when linking against older library sets (see table below). Old/short CSVs without these columns keep working (missing column = "all versions").
  • CI (ci.yml, ci-pr.yml) — a discover job emits the newest‑N versions as JSON; the build matrix consumes it via fromJSON, so each version × configuration × platform runs on its own parallel runner with no version list maintained in YAML. The report job (Join-CsvReports.ps1) writes a consolidated, version‑aware summary to the run page. Build-ChangedSamples.ps1 treats the discovery script as a full‑build trigger.
  • Building-Locally.md — documents the new parameter, auto‑discovery, and the exclusions format.

exclusions.csv — what's excluded and why

Each row below only applies when linking against an older library set (i.e. _NT_TARGET_VERSION at or below the listed threshold); on the latest version these samples build normally. Reasons are recorded verbatim in the Reason column of exclusions.csv.

Sample Scope Excluded when Why (compiler error)
audio\sysvad all configs/platforms _NT_TARGET_VERSION10.0.22000 KSJACK_DESCRIPTION3 undeclared — the audio jack descriptor v3 struct was added in 22H2 (10.0.22621).
network\netadaptercx\netvadapter all configs/platforms 10.0.22621 Requests an NDIS/DDI version newer than the linked library (C1189 "wrong NDIS or DDI version").
network\wlan\wificx all configs/platforms 10.0.22621 Requests an NDIS/DDI version newer than the linked library (C1189 "wrong NDIS or DDI version").
powerlimit\plclient all configs/platforms 10.0.22621 POWER_LIMIT_ATTRIBUTES not declared in the older library (C2061).
powerlimit\plpolicy all configs/platforms 10.0.22621 POWER_LIMIT_ATTRIBUTES not declared in the older library (C2061).
storage\class\classpnp Debug only (both platforms) 10.0.22621 STOR_ADDRESS_TYPE_NVME undeclared in the older library (C2065).
storage\miniports\storahci Debug only (both platforms) 10.0.22621 STOR_ADDRESS_TYPE_NVME undeclared in the older library (C2065).
storage\msdsm Debug, x64 only 10.0.22621 STOR_ADDRESS_TYPE_NVME undeclared in the older library (C2065).

Note: usb\usbview is intentionally not excluded. It fails for a host‑tooling reason (missing .NET Framework 4.7.2 / 4.8.1 targeting packs) on every version, not because of _NT_TARGET_VERSION.

Testing

image

5an7y and others added 7 commits June 22, 2026 12:38
Add a validated -TargetVersion parameter (also settable via the
WDS_TargetVersion environment variable) so samples can be built for older
target OS versions. Valid values come from the WDK DriverGeneral.xml rule
and default to the latest, Windows10:
  Windows10 (Windows 10 or higher), WindowsV6.3 (Windows 8.1),
  Windows8 (Windows 8), Windows7 (Windows 7).

The value is threaded through Build-SingleSample into the msbuild
invocation (replacing the hard-coded TargetVersion=Windows10) and across
the parallel runspace, and is surfaced in the build plan, final summary,
and HTML report title. Document the new parameter in the script help and
Building-Locally.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add an optional TargetVersions column to exclusions.csv so an exclusion can
be limited to specific target OS versions (e.g. exclude ARM only when
building Windows8). The column holds a ';'-separated list of -like patterns
matched against -TargetVersion; blank or '*' means all versions, so every
existing row stays applicable to all targets.

Import-SampleExclusions now takes -TargetVersion and filters rows by it at
load time (alongside the existing MinBuild/MaxBuild range); a missing column
is treated as '*' for backward compatibility. Document the new column and an
example in Building-Locally.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Expose the WDK '_NT_TARGET_VERSION' property (the OS version of the libraries
the driver links against) as -NtTargetVersion / WDS_NtTargetVersion. Unlike
-TargetVersion (Target OS Version), this does not change the platform model, so
Universal/Windows Driver samples keep building on Windows 10 while linking
against an older library set.

The parameter accepts the Windows build number (e.g. 10.0.22000), maps it to the
NTDDI code from the WDK DriverGeneral.xml rule, and passes -p:_NT_TARGET_VERSION
to msbuild (threaded through Build-SingleSample and the parallel runspace). It
defaults to the latest (10.0.28000) and is surfaced in the build plan, summary,
and HTML report title. Documented in Building-Locally.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Exclusions:
- Add MinNtTargetVersion/MaxNtTargetVersion columns to exclusions.csv so a row can apply
  only within an _NT_TARGET_VERSION build-number range (parsed from -NtTargetVersion, e.g.
  22000 from 10.0.22000). Import-SampleExclusions filters this range at load time alongside
  the existing build-number range; blank = unbounded.
- Exclude the samples that fail only when linking against older library sets, with the
  reason taken from the build logs: audio.sysvad (<=22000, KSJACK_DESCRIPTION3);
  network.netadaptercx.netvadapter and network.wlan.wificx (<=22621, NDIS/DDI version);
  powerlimit.plclient/plpolicy (<=22621, POWER_LIMIT_ATTRIBUTES); storage classpnp/storahci
  (<=22621, STOR_ADDRESS_TYPE_NVME, Debug-only) and storage.msdsm (Debug|x64). usb.usbview is
  intentionally NOT excluded: it fails on every version for a known host reason (missing
  .NET 4.7.2/4.8.1 targeting packs).

CI:
- ci.yml and ci-pr.yml: add _NT_TARGET_VERSION as a manual matrix axis (4 newest versions,
  latest-first) so each version x configuration x platform runs on its own parallel runner.
- Build-Samples.ps1 and Join-CsvReports.ps1 now write an easy-to-scan Markdown summary to
  GITHUB_STEP_SUMMARY: each build job shows counts and a failures table with the first error;
  the report job shows per-version totals and a consolidated failures list, plus the
  colour-coded sample x version HTML/CSV overview.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove the -TargetVersion parameter and all its plumbing from Build-Samples.ps1 (restoring
  the original hard-coded -p:TargetVersion=Windows10), and drop the TargetVersions column from
  exclusions.csv and Import-SampleExclusions. Only _NT_TARGET_VERSION remains exposed.
- Add Get-NtTargetVersions.ps1, which auto-discovers the valid _NT_TARGET_VERSION values (and
  their NTDDI codes) by parsing the active WDK's DriverGeneral.xml rule. Build-Samples.ps1 uses
  it to validate -NtTargetVersion, default to the latest, and map to the msbuild code, so a new
  WDK version needs no script change (accepts '10.0.<build>' or the short '<build>' tag).
- CI: ci.yml and ci-pr.yml gain a 'discover' job that emits the newest-N versions as JSON; the
  build matrix consumes it via fromJSON, so there is no hand-maintained version list anywhere.
  Build-ChangedSamples.ps1 treats Get-NtTargetVersions.ps1 as a full-build trigger.
- Docs updated accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove the hand-maintained _NT_TARGET_VERSION -> friendly-name map (latest/24H2/...)
  from Join-CsvReports.ps1, along with its "Release" column in the HTML and step-summary
  tables; those labels cannot be auto-discovered.
- Stop hardcoding a version in the helper defaults: Import-SampleExclusions' -NtTargetVersion
  now defaults to empty (treated as the latest, so no NT-scoped row applies), and
  Build-SingleSample's -NtTargetVersionCode has no hardcoded code (the resolved value is
  always passed in). Blank MaxNtTargetVersion now uses [int]::MaxValue so 'latest'/empty
  matches the newest version's exclusion set.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a workflow_dispatch trigger so "Build all driver samples" can be started
on demand from the Actions tab.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@5an7y-Microsoft 5an7y-Microsoft marked this pull request as ready for review June 23, 2026 20:30
@5an7y-Microsoft 5an7y-Microsoft requested a review from a team as a code owner June 23, 2026 20:30
@5an7y-Microsoft 5an7y-Microsoft changed the title Enhance sample builds with TargetVersion and NT version support Expose the NT_TARGET_VERSION in the build samples script & workflow update Jun 23, 2026
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.

2 participants