Skip to content

Auto-derive BootstrapSdkVersion from global.json so it can never lag tools.dotnet#13694

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/auto-derive-bootstrap-sdk-version
Draft

Auto-derive BootstrapSdkVersion from global.json so it can never lag tools.dotnet#13694
Copilot wants to merge 2 commits intomainfrom
copilot/auto-derive-bootstrap-sdk-version

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 5, 2026

eng/Versions.props::BootstrapSdkVersion and global.json::tools.dotnet were independently maintained, allowing them to drift. When they drift, the bootstrap shared runtime ends up older than what the SDK's tools require, producing host-resolution failures (You must install or update .NET to run this application).

Changes Made

  • eng/Versions.props — Replace the hard-coded <BootstrapSdkVersion> with a reference to $(DotNetCliVersion), which is already read from global.json via regex in the same file. Drift is now structurally impossible.

    <!-- Before -->
    <BootstrapSdkVersion>10.0.106</BootstrapSdkVersion>
    
    <!-- After -->
    <!-- Derived from global.json so it can never lag tools.dotnet -->
    <BootstrapSdkVersion>$(DotNetCliVersion)</BootstrapSdkVersion>
  • eng/cibuild_bootstrapped_msbuild.ps1 — Switch from parsing Versions.props as raw XML (which would read the unevaluated $(DotNetCliVersion) literal after the props change) to reading tools.dotnet directly from global.json via ConvertFrom-Json.

  • eng/cibuild_bootstrapped_msbuild.sh — Same fix: read from global.json instead of grepping Versions.props. Uses jq when available for proper JSON path traversal (.tools.dotnet); falls back to grep/sed.

Both scripts now fail fast with a clear error if tools.dotnet cannot be read.

Testing

No new tests — the change is structural. The bootstrap CI pipelines (cibuild_bootstrapped_msbuild.ps1/.sh) exercise this path on every CI run.

Notes

The DotNetCliVersion regex pattern already existed in Versions.props for other purposes; BootstrapSdkVersion now piggybacks on it rather than duplicating logic or requiring a second independent update when Arcade bumps the SDK.

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Hello @copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo.

Copilot AI changed the title [WIP] Auto-derive BootstrapSdkVersion from global.json Auto-derive BootstrapSdkVersion from global.json so it can never lag tools.dotnet May 5, 2026
Copilot finished work on behalf of OvesN May 5, 2026 16:25
Copilot AI requested a review from OvesN May 5, 2026 16:25
Comment thread eng/Versions.props
<PropertyGroup>
<BootstrapSdkVersion>10.0.106</BootstrapSdkVersion>
<!-- Derived from global.json so it can never lag tools.dotnet -->
<BootstrapSdkVersion>$(DotNetCliVersion)</BootstrapSdkVersion>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we are missing here is doing some kind of Math.Min('$(NetCoreSdkVersion)', '10.0.106'))

Comment on lines +88 to +92
$globalJsonPath = Join-Path $PSScriptRoot "..\global.json"
$bootstrapSdkVersion = (Get-Content $globalJsonPath -Raw | ConvertFrom-Json).tools.dotnet
if ([string]::IsNullOrWhiteSpace($bootstrapSdkVersion)) {
throw "Could not read tools.dotnet from $globalJsonPath."
}
Copy link
Copy Markdown
Member

@ViktorHofer ViktorHofer May 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems wrong. It now always uses the SDK version from global.json. It would be better to still allow to hardcode a newer version via the BootstrapSdkVersion property but make sure that is never older than the SDK provided one.

I would use the msbuild -getproperty function here to avoid direct XML parsing and invoke some project that imports the microsoft.net.sdk, i.e. the msbuild.bootstrap.csproj.

This also applies to the bash changes.

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.

Auto-derive BootstrapSdkVersion from global.json so it can never lag tools.dotnet

3 participants