Skip to content

[build] Make local no-op SDK builds incremental - #13774

Draft
simonrozsival wants to merge 21 commits into
simonrozsival-build-entry-pointsfrom
simonrozsival-local-build-baseline
Draft

simonrozsival wants to merge 21 commits into
simonrozsival-build-entry-pointsfrom
simonrozsival-local-build-baseline

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Stacked on #13430. Context: dotnet/sourcelink#1290, dotnet/roslyn#86006.

With the dotnet build Microsoft.Android.slnx entry point, a build with no source changes still took ~19 s locally, and every C# or Java edit paid that cost before doing useful work. Incorrect inputs and outputs, unconditional file writes, and local workload work contributed to repeated builds:

  • Preserve WorkloadManifest.json/.targets timestamps when their contents have not changed, so they no longer invalidate workload installation on every build.
  • Skip WorkloadDependencies.proj for the local workload; packing the shipped manifest still generates data/WorkloadDependencies.json.
  • Correct the Bytecode tests' module-info.class output, exclude the templates project's bin/ and obj/ from template inputs, and touch the copied java-source-utils.jar so these targets can become up to date.
  • Give BuildExtraApiLevels file-based inputs and a stamp output, with state for relevant input settings and generated files. Missing files and changed API-specific profiles still trigger recovery; lists and asset caches produced by later workload setup are excluded.
  • Generate native runtime lists only for the latest stable API, where their packs exist. Track managed lists per API and copy the analyzer into extra-API reference packs, repairing it if deleted or updated.
  • Resolve workload packs each time, preserve an unchanged dependency project's timestamp, and combine restore and install in one MSBuild process. Record extracted entries in the existing install marker to repair missing files and obsolete or malformed markers.

Worktree revision accuracy

SourceLink 8 could report Repository has no commit in a Git worktree when the branch ref was packed in Git's common directory. A succeeding build could lose SourceRevisionId, changing AssemblyInformationalVersion and causing solution-wide recompilation without any source edit. Upgrade Microsoft.SourceLink.GitHub to 10.0.301, which resolves the packed-ref fixture correctly. Exclude its transitive compile and runtime assets so its System.IO.Hashing 10.0.10 dependency does not conflict with the repository's direct 12.0 dependency; its build tasks retain their own required assemblies.

Performance

Matched remeasurement (2026-11-26)

The sub-second no-op and sub-minute full binding-edit goals remain unmet; this PR remains draft. These measurements compare parent #13430 at b16dc101226746bb7feaabc2d0d85111d47b9b19 with this PR's head a1a65dd3c6632880bdc617a8b0076625e093b362, a merge of that parent and the earlier child head 691e8c6582e7b692f1438f3bc0fb330a712ffeef. The measured integration commit is now published.

Apple M5 Max (18 cores, 64 GB), macOS 26.7.3, .NET SDK 12.0.100-alpha.1.26551.101 via dotnetup. Each successful run used dotnetup dotnet build Microsoft.Android.slnx -c Debug -m:4 -nr:false -v:minimal -bl:<unique-binlog>, with built outputs, warm package/tool caches, separate primary NuGet/CLI/Gradle/TMPDIR roots, a session-owned Android toolchain, and the same global NuGet directory as a read-only fallback. Each worktree used a distinct SharedCompilationId environment value to isolate Roslyn's server pipe. The pinned SDK's satellite-assembly Csc does not forward SharedCompilationId, so those compiles share the SDK-derived pipe; replayed binlogs show they ran only in the Build.Tasks edit/revert runs (13 per run) and the cold runs (78 per run); no-op, Java, native, and binding runs skipped them. Every satellite compile in the reported Build.Tasks edit/revert runs (parent and PR) and both cold runs was server-processed with no connection failure; CoreGenerateSatelliteAssemblies totalled 0.20–0.56 s per reported Build.Tasks run and 1.9 / 0.6 s in the cold runs. The cold PR run's two server failures were the already-noted Mono.Android and Microsoft.Android.Templates project compiles. Because satellite compiles were not isolated, a cold run is not fully compiler-isolated even with distinct IDs. Runs were sequential, with alternating order; edits append the same comment and reverts restore the original file.

Scenario Parent Integration candidate
No-op (median of four; range) 17.73 s (16.84–19.69) 12.70 s (12.30–14.90)
Build.Tasks MonoAndroidHelper.cs edit / revert 27.40 / 28.22 s 19.37 / 17.26 s
Java MonoPackageManager.java edit / revert 22.88 / 25.79 s 16.36 / 19.01 s
Native clr/host/host.cc edit / revert 60.88 / 55.72 s 35.41 / 26.16 s
Binding JNIEnv.cs edit / revert 113.14 / 107.73 s 114.17 / 103.08 s

The no-op median fell by 5.03 s (28.4%) in this four-pair sample; the observed ranges did not overlap, and sampled one-minute host load ranged 12.0–15.4. Changed-input numbers are single edit/revert pairs, not statistical estimates; load varied approximately 9.4–20.6. Binding edits remain roughly 1¾–2 minutes and show no established improvement. No-op binlogs show one redundant Bytecode-tests C# compilation and extra-API work in the parent, versus no C# compilation and a skipped BuildExtraApiLevels in the candidate. Both native-edit binlogs recorded six host.cc compilations; inclusive CreateLocalRuntimeLists time was 38.1 vs 14.7 seconds, and extra-API target work differed. Both Java-edit builds invoked javac, and both binding-edit builds compiled all three API-level Mono.Android assemblies. All sampled compiler requests in the replayed isolated-ID edit logs succeeded. Both final post-probe builds succeeded, all three reference packs were present, and both worktrees were clean after restoring the comments.

An earlier single cold-output pair completed in approximately 393.9 vs 272.0 s, with second builds at 156.0 vs 101.6 s. It is inconclusive: the runs were ordered, shared-host load and network/initial Gradle caches varied, and the candidate had two compiler-server connection failures. The baseline's outer timing sampled process completion in five-second intervals; 393.9 s is estimated from the final log write. Earlier setup attempts failed due to a missing private-cache runtime pack and an MSB3231 extraction collision on a shared Android SDK; those failed timings are excluded. The shared SDK Maven repository was subsequently verified against its archive, and later runs used a private toolchain.

The first Build.Tasks-edit comparison (111.20 vs 21.54 s) is also excluded: the parent recorded 17 compiler-server connection failures, with 92.7 s cumulative Csc time (including a 67.7 s CoreGenerateSatelliteAssemblies block from 13 failed satellite connections), whereas the candidate had 16 successful compiler requests and 3.0 s cumulative Csc. Separate TMPDIR roots alone did not isolate Roslyn: on Unix, the server mutex follows TMPDIR but the pipe is under /tmp. A separate owned-pipe reproduction demonstrated that two mutex namespaces can contend for the same pipe. The repeated measurements above used distinct compiler IDs; this changes the experimental setup, not the product.

Earlier evidence and unretained experiments

An earlier matched comparison at parent d0aa1bfd5a and child a9806c076d measured no-op medians 19.1 → 16.1 s (four runs each, load roughly 5–25); its single cold and binding-edit comparisons were inconclusive. Targeted CreateLocalRuntimeLists medians were 33.35 → 14.82 s, with child builds reduced from 21 to nine; this was not a full-solution comparison. Combined workload restore/install no-op medians were 16.03 → 14.45 s, confounded by falling host load.

A session-owned diagnostic compiler prototype for dotnet/roslyn#86006 was not shipped: four standalone binding builds per variant had stock/prototype medians 90.69 / 65.07 s, with matching DLL/PDB hashes and normalized warnings, under load ~33–68. Two full-solution binding builds per variant had medians 187.60 / 152.94 s with matching compiler commands, outputs and normalized diagnostics, under load ~21–46. These samples warrant upstream investigation, not a precise speedup claim or a patched compiler.

A targeted default-API binding workflow measured 55.71 / 66.12 s for edit/revert including framework and managed-list refresh, but updated only the default API and was not a complete solution or device build. A graph-build no-op took 4.39 s but bypassed solution preparation/workload hooks and left a deleted API 37 reference list missing; the ordinary build restored it. Explicit preparation + graph build + workload setup restored it, but measured 14.01 s median versus 12.30 s for ordinary no-ops and did not establish full equivalence. Neither shortcut was retained. Parallel extra-API builds, a framework-list shortcut with stale-metadata risk, analyzer/processor changes, parallel Prepare, workload-tool reuse/static-graph variants and OpenJDK target shortcuts were also not retained: they were unsafe, slower, too noisy, or offered insufficient measured benefit.

Validation

  • On the published integration commit and parent, dotnetup dotnet build Microsoft.Android.slnx -c Debug -m:4 -nr:false -v:minimal -bl:<unique-binlog> passed the isolated-ID warmups, four interleaved no-op pairs, each named edit/revert pair and final no-op. Representative binlogs confirmed the affected work and no isolated-ID compiler-server failures. Both produced API 37, 37.1 and 37.2 Mono.Android.dll reference packs. The cold-output pair also succeeded but is not a controlled speed comparison.
  • At earlier child revisions, dotnetup dotnet pack build-tools/create-packs/Microsoft.NET.Sdk.Android.proj -c Debug -o /tmp/mpack passed; the manifest package contained WorkloadDependencies.json, WorkloadManifest.json and WorkloadManifest.targets. Isolated Debug and Release workload-install fixtures verified changed roots and package membership, missing extracted and packed files, legacy/malformed markers, and retry after failed extraction. Inventories check existence, not hashes; existing SDK-root packs remain trusted.
  • Earlier ./dotnet-local.sh new android -o /tmp/benchapp/App1 && ./dotnet-local.sh build /tmp/benchapp/App1 -c Debug passed and produced a signed APK. Changing and reverting a template and WorkloadManifest.in.json repacked the templates and updated/restored the installed manifest. Earlier Debug API 37.0/37.1/37.2 CoreCLR, Release API 37.1, and optimized Debug NativeAOT/arm64 app smoke builds produced signed APKs; the NativeAOT build reported _AndroidRuntime=NativeAOT and included the native app library.
  • Earlier dotnetup dotnet build Microsoft.Android.slnx -c Debug -m:4 -nr:false -v:diag no-ops passed and skipped BuildExtraApiLevels; touching the 37.1 profile reran it, deleting a generated 37.1 Java.Interop.dll restored it, and the next no-op skipped it. Runtime-list tests covered unchanged, changed and missing per-API inputs; deleting the 37.1 analyzer restored it byte-for-byte.
  • An isolated packed-ref Git worktree fixture reproduced SourceLink 8.0.0 and 10.0.300 failing to resolve HEAD; 10.0.301 resolved it and emitted the correct SourceLink mapping. Direct hashing references retained version 12.0, while projects with only SourceLink had compile/runtime placeholders. A Debug full build at 691e8c6582 and three following no-ops passed; the no-ops invoked no Csc. An earlier Release solution build with -warnaserror:MSB3277 also passed.
  • dotnetup dotnet test tests/Microsoft.Android.Build.BaseTasks-Tests/Microsoft.Android.Build.BaseTasks-Tests.csproj -c Debug -m:4 -nr:false "-bl:$logdir/sourcelink-final-basetasks-tests.binlog": 167 passed, 4 skipped at 691e8c6582.
  • dotnetup dotnet test tests/Xamarin.Android.Tools.AndroidSdk-Tests/Xamarin.Android.Tools.AndroidSdk-Tests.csproj -c Debug -p:AndroidToolsDisableMultiTargeting=false -p:DotNetTargetFrameworkVersion=10.0 --no-build --environment "HOME=$testhome": 450 passed, 7 skipped with an isolated home. The first attempt encountered an unrelated host JDK discovery conflict. These historical tests and app builds were not rerun on the integration commit.

simonrozsival and others added 15 commits November 24, 2026 21:06
Replace Make and private SDK installers with an SDK pinned in
global.json and selected by dotnetup.  Run preparation and local
workload configuration from solution build hooks, and expose product
packaging through the standard solution Pack target.

Keep SDK binaries shared while isolating Android and MAUI workloads
inside each worktree.  Reduce dotnet-local to workload selection and
argument forwarding, and use it in CI only where local workloads are
required.  Update build and test documentation to match.

Use the checked-out branch when GitBranch runs in a worktree so
packages and workload manifests receive consistent versions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve the SDK argument separator through dotnetup so NUnit run settings and tool arguments reach their intended parsers. Avoid quoting trailing Windows directory separators in workload dependency resolution.

Configure source workloads for solution builds on CI as well as local builds. Disable the CLI MSBuild server in the minimal local-workload wrappers so a previously cached resolver cannot select manifests from another workload root.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
CI SDKs can already contain every workload dependency. The generated plan then has no _WorkloadPack items, but its Install target still invokes Unzip with an empty DestinationFolder and fails with MSB4044. Skip the target when the plan has no packs, preserving installation for nonempty plans.

Reproduced the empty-plan failure locally before the fix, verified the guarded plan succeeds without Unzip execution, and verified a four-pack source dependency installation still runs successfully.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
CI installed the SDK pinned by global.json, but workload resolution used the dependency package version from the merged main branch. That SDK directory did not exist, so the resolver silently omitted host-specific Android and MonoTargets packs. Extraction appeared successful, then app and test builds failed with NETSDK1147 or missing SDK directories.

Use NETCoreSdkVersion, as the workload feature-band calculation already does, and reject nonexistent SDK directories before resolving packs. A local mismatched-version reproduction confirmed the missing host packs; the corrected MSBuild target produced the complete plan, and a legitimate empty-plan Install still succeeds.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Context: #13430

A source build with NUGET_PACKAGES pointing at a private cache reached workload installation, then failed with MSB3932 because the generated path joined the cache directory and package ID without a separator. NuGetPackageRoot can retain the environment-provided directory without a trailing slash.

Use MSBuild EnsureTrailingSlash when generating dependency archive paths. Item evaluation with and without a trailing separator now produces identical paths, including the physically present archive from the failed build.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Context: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1672175

The worktree-local installer uses MSBuild Unzip instead of the SDK workload installer. Unzip preserves zone-less ZIP entry timestamps, so files packed on another agent can be extracted into the future. CI consequently rebuilt unchanged SDK and reference inputs on every invocation: AutoImport.props invalidated Android targets, and Java.Interop.dll forced CoreCompile to run again.

Finalize each unpacked workload pack by clamping only future file timestamps to the current UTC time before applying Unix permissions. Existing older timestamps, file contents and modes remain unchanged; packed template and library archives are unaffected.

The generated-install fixture reproduces future inputs with the old tool, verifies the timestamp correction and permission preservation, and skips an unchanged installation. After real extraction under America/Los_Angeles, retained ordinary and unchanged CoreCLR app build logs show CoreCompile, Java stubs, Java compilation and Dalvik compilation correctly skipped on the second build.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Context: #13430

Linux template tests in Azure build 1672175 fail with "No templates or subcommands found matching: android". The local workload installer preserves the uppercase Microsoft.Android.Templates archive filename when copying it into template-packs, but the SDK workload resolver requires a lowercase package ID and version. Case-insensitive hosts conceal the mismatch.

Copy template and library archives to the existing canonical PackageFileName instead of preserving the source basename. A generated two-pack Install fixture verifies the exact directory entries and copied bytes for mixed-case package IDs and prerelease versions; both unchanged Install batches skip without copying again.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Update the newly added local-build skill for the shared SDK and standard solution build entrypoints.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Host-side tools targeting earlier frameworks need their runtimes, not separate SDK installations. Keep the repository-pinned SDK as the single build SDK and install the .NET 11 runtime independently of the stable tooling target framework.

Use the same SDK for the isolated Arcade signing adapter, preserve its global.json pin, and publish the resolved shared dotnet root to Arcade. Install the .NET 8 runtime for SwixBuild. Make the manifest project SDK-free and remove its obsolete SDK 8 pin and redundant restore, so desktop MSBuild does not need to import the newer SDK.

Validation: git diff --check passed. Parsed 48 pipeline YAML files and both signing XML projects; checked 29 affected template calls, runtime pins, signing working directories and obsolete-variable removal. Compared all six PowerShell scripts and the property-query project with the previously accepted V5 inputs; they remain unchanged apart from checkout line endings. The earlier V5 check parsed representative parameter-rendered scripts and evaluated MSBuildToolsPath successfully. Actual provisioning and Windows Swix/signing were not run; no new managed validation phase was executed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep SDKs, runtimes, and dotnetup metadata shared across worktrees while
making CI installation explicitly noninteractive. Log the selected tool's
path and version so differences between cached agent tools are visible.

Resolve the first application match once and invoke that executable for
the entire setup step; Get-Command can otherwise return multiple paths.
Apply the same noninteractive option to signing's .NET 8 runtime install.

Validation: the installed dotnetup accepts all three install argument
sets with --help. An extracted PowerShell step harness passed seven
stubbed success/failure cases, including paths with spaces, multiple
application matches, command order, and native exit propagation. All 48
pipeline YAML documents parse, and git diff --check passed. No SDK/runtime
installation or Windows signing execution was performed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Darc already updates tools.dotnet and an existing sdk.version together
when Arcade brings a newer bootstrap SDK. Setting tools.pinned disables
both updates and leaves the shared SDK selection stuck.

Remove that opt-out without changing the currently selected SDK. Document
that automatic updates follow Arcade's bootstrap SDK, not the produced
Microsoft.NET.Sdk dependency, and never downgrade to an older version.

Validation: JSON parsing and a semantic comparison against the parent
passed: tools.pinned is the only removed setting, both SDK version fields
remain equal, and the resolver policy is unchanged. git diff --check
passed. No SDK installation or build was needed because the selected
SDK and build inputs are unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Normal solution Pack also builds, so mark its Build dependency before local workload configuration and preserve extracted workloads in that context. Keep ordinary Build/Rebuild cleanup unchanged.

Condition preparation and finalization on build-enabled Mono.Android solution references so host-only filters skip both hooks and their dependencies. Replace the deleted skill-runner installer invocation with dotnetup and regenerate its workflow lock using the existing compiler.

Validated the generator solution filter and BootstrapTasks builds, nine focused MSBuild regression cases, and six isolated bootstrap success/failure cases. Normal workflow compilation passed; diagnostic dry-run failed on existing token-pool shellcheck findings.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Solution Clean deleted shared Android SDK/NDK and JDK installations and cached downloads. Native cleanup also invoked Ninja in potentially missing CMake directories, while Java utility cleanup required Gradle.

Preserve shared toolchains and cached archives. Initialize native flavor paths before removing generated intermediates and per-RID outputs, without deleting a custom output root. Remove local Java build directories directly and correct aapt2 cleanup to delete executables rather than directories. Document the selected-configuration Clean entrypoint.

Validation on macOS: both commands passed, including repeated Debug cleanup and cleanup after the generator build:

  * dotnetup dotnet clean Microsoft.Android.slnx -c Debug -m:2 -nr:false -v:minimal
  * dotnetup dotnet clean Microsoft.Android.slnx -c Release -m:2 -nr:false -v:minimal

DOTNET_CLI_DO_NOT_USE_MSBUILD_SERVER=1 dotnetup dotnet build src/generator/generator.slnf -c Debug -m:2 -nr:false -v:minimal passed with 38 existing SourceLink/repository-information warnings and no errors.

A temporary regression harness passed all 17 actual-project MSBuild invocations, including missing native/Java tools, repeated cleanup, flavor/configuration/output-root isolation, and preservation of 21 owned shared-tool sentinels. An additional aapt2 custom-output-path probe passed. XML parsing and git diff --check passed. Windows, full SDK rebuild, product packaging, and device tests were not run for this Clean-only correction.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival and others added 2 commits November 25, 2026 12:55
Give BuildExtraApiLevels real file inputs and track its output set so no-op solution builds can skip extra API-level builds while detecting changed profiles, changed settings, and missing pack outputs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Generate native runtime lists only for the existing API-level packs and track managed lists independently. Restore missing extra-API analyzers and incomplete workload packs, and combine workload restore and installation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival and others added 4 commits November 25, 2026 21:47
Upgrade SourceLink so worktrees whose branch refs are packed retain the correct revision and do not trigger a solution-wide rebuild when source metadata changes. Exclude its compile and runtime assets to avoid conflicting with the System.IO.Hashing version used by Android build tasks.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Installing the pinned SDK through dotnetup does not make the runner preinstalled dotnet select that shared installation. The selected SDK-update skill still used bare dotnet run, so its file-based helpers could fail exact SDK selection after removal of the PATH override.

Forward all eight helper invocations through dotnetup. Keep workflow guidance, the package-catalog reference, and helper usage comments/messages consistent. Preserve shared installation selection and existing helper logic; regenerate the workflow lock with the matching compiler, changing only its body hash.

Validation: gh-aw v0.92.0 compile skill-runner --no-check-update passed with the existing missing concurrency.job-discriminator warning. Static checks passed for all eight commands, no remaining bare-dotnet helper guidance in the selected skill/workflow, and unchanged executable lock contents; git diff --check passed. Diagnostic compile skill-runner --dry-run --no-check-update emitted a diagnostic lock but failed on existing token-pool SC2206/SC2004. No workflow was dispatched.

Helper execution and publication remain pending: the scoped security reviewer found no confirmed new vulnerability but returned incomplete coverage. Its synchronous invocation cannot accept the necessary follow-up, so no unreviewed harness execution or upload was performed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The SDK dependency's package version can differ from the SDK selected by global.json. Installing extracted Android or MAUI manifests under the dependency's feature band makes them invisible to the running SDK. MTP-only test global.json files also hide the root SDK pin when commands run from test directories.

Reuse the running-SDK feature-band calculation for manifest installation, Android manifest lookup, and workload-plan inputs. Preserve the dependency band for selecting the MAUI NuGet package. Resolve the repository-pinned SDK in dotnet-local before forwarding SDK commands in the caller's directory; preserve test-runner settings and direct host execution.

Update the related build/test guidance and forward the remaining sliced-test example through dotnetup.

Validation: DOTNET_CLI_DO_NOT_USE_MSBUILD_SERVER=1 dotnetup dotnet build src/generator/generator.slnf -c Debug --no-restore -m:2 -nr:false -v:minimal passed with no warnings or errors. All 19 isolated SDK/manifest/wrapper probes and nine solution-orchestration probes passed. bash -n dotnet-local.sh, shellcheck dotnet-local.sh, and git diff --check passed. Windows wrapper execution was unavailable on macOS; no full SDK rebuild, product packaging, or device testing is claimed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

1 participant