Auto-derive BootstrapSdkVersion from global.json so it can never lag tools.dotnet#13694
Auto-derive BootstrapSdkVersion from global.json so it can never lag tools.dotnet#13694
Conversation
|
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. |
Agent-Logs-Url: https://github.com/dotnet/msbuild/sessions/8519415e-ce9b-4854-8348-2c215f5d4c4c Co-authored-by: OvesN <150850103+OvesN@users.noreply.github.com>
| <PropertyGroup> | ||
| <BootstrapSdkVersion>10.0.106</BootstrapSdkVersion> | ||
| <!-- Derived from global.json so it can never lag tools.dotnet --> | ||
| <BootstrapSdkVersion>$(DotNetCliVersion)</BootstrapSdkVersion> |
There was a problem hiding this comment.
That's not a standard property. Use NetCoreSdkVersion instead: https://github.com/dotnet/sdk/blob/7bfcbfa069151ac1f7b602fd4cad874f99fb2c1d/src/Layout/redist/targets/GenerateBundledVersions.targets#L654
There was a problem hiding this comment.
What we are missing here is doing some kind of Math.Min('$(NetCoreSdkVersion)', '10.0.106'))
| $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." | ||
| } |
There was a problem hiding this comment.
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.
eng/Versions.props::BootstrapSdkVersionandglobal.json::tools.dotnetwere 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 fromglobal.jsonvia regex in the same file. Drift is now structurally impossible.eng/cibuild_bootstrapped_msbuild.ps1— Switch from parsingVersions.propsas raw XML (which would read the unevaluated$(DotNetCliVersion)literal after the props change) to readingtools.dotnetdirectly fromglobal.jsonviaConvertFrom-Json.eng/cibuild_bootstrapped_msbuild.sh— Same fix: read fromglobal.jsoninstead of greppingVersions.props. Usesjqwhen available for proper JSON path traversal (.tools.dotnet); falls back to grep/sed.Both scripts now fail fast with a clear error if
tools.dotnetcannot 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
DotNetCliVersionregex pattern already existed inVersions.propsfor other purposes;BootstrapSdkVersionnow piggybacks on it rather than duplicating logic or requiring a second independent update when Arcade bumps the SDK.