Commit ad5cf59
[build] skip DownloadOneFileWithRetry on no-op builds (#11693)
A no-op build binlog showed `DownloadOneFileWithRetry` running 17 times
for a total of ~20s on a 77s no-op build: every invocation re-hashed an
already-cached file (e.g. xamarin-android-toolchain-L_18.1.6-8.0.0-1.7z,
build-tools_r36_macosx.zip) just to confirm the SHA-256 still matches.
The Hash MSBuild task showed maxDurationMs=2005 per call across 32
invocations. Nothing changes on a no-op build, so this work was pure
waste.
Add a per-file stamp file (`<cache>/<file>.<SHA>.stamp`, or `.stamp`
when no hash is supplied) that gets touched once the download and SHA
verification succeed, and gate the target with:
Inputs=`$(MSBuildThisFileFullPath)`
Outputs=`$(_DownloadPath);$(_DownloadStamp)`
so MSBuild''s incremental engine skips the target - and the expensive
re-hash - on no-op builds. Self-heal is preserved:
* Cached file deleted -> output missing -> target re-runs.
* `_DownloadSha256` updated in a caller -> stamp file name changes ->
new stamp output missing -> target re-runs and re-verifies.
* This .targets file itself modified -> Inputs newer -> target
re-runs.
The Touch lands after the SHA Error gate so a mismatch still fails the
build with the existing message and never persists a stale stamp.
### [build] only stamp file in Outputs; add self-heal helper
Listing the cached file in `Outputs` alongside the stamp defeats the
no-op gate when cache files restored from CI caches keep their original
old timestamps: Inputs.max (this targets file) > Outputs.min (the cache
file from a year ago) -> target re-runs and re-hashes every build.
Drop the cache file from `Outputs` and add `_PrepareDownloadOneFileWithRetry`
as `DependsOnTargets`. It always runs (no Inputs/Outputs of its own) and
deletes the stamp when the cached file is gone, so MSBuild re-runs
DownloadOneFileWithRetry with a now-incomplete output set.
Verified end-to-end against `Xamarin.Android.sln`:
BEFORE: 18 invocations, 22.53s of GetFileHash work on a no-op build
(matches the user's reference msbuild.binlog at 20.08s)
AFTER : 18 invocations, 1ms total - ALL skipped via Inputs/Outputs.
Build wall: 101.94s -> 62.39s (~40s saved).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 313da6b commit ad5cf59
1 file changed
Lines changed: 46 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
52 | 69 | | |
53 | 70 | | |
54 | 71 | | |
| |||
81 | 98 | | |
82 | 99 | | |
83 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
84 | 109 | | |
85 | 110 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
91 | 115 | | |
92 | 116 | | |
93 | 117 | | |
| |||
146 | 170 | | |
147 | 171 | | |
148 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
149 | 190 | | |
150 | 191 | | |
151 | 192 | | |
0 commit comments