@@ -92,9 +92,12 @@ import '../validation.dart';
9292/// * **Path and system roots:**
9393/// * `PATH`: Invoke native tools.
9494/// * `HOME`, `USERPROFILE`: Find tools in default install locations.
95+ /// * `APPDATA`, `LOCALAPPDATA`: NuGet, dart_data_home, and pub on
96+ /// Windows.
9597/// * `SYSTEMDRIVE`, `SYSTEMROOT`, `WINDIR`: Process invocations and CMake
9698/// on Windows.
9799/// * `PROGRAMDATA`: For `vswhere.exe` on Windows.
100+ /// * `PROCESSOR_ARCHITECTURE`: CMake Android on Windows.
98101/// * **Temporary directories:**
99102/// * `TEMP`, `TMP`, `TMPDIR`: Temporary directories.
100103/// * **HTTP proxies:**
@@ -110,12 +113,52 @@ import '../validation.dart';
110113/// * Any variable starting with `CCACHE_`.
111114/// * **Nix:**
112115/// * Any variable starting with `NIX_`.
116+ /// * **.NET and NuGet:**
117+ /// * Any variable starting with `DOTNET_`.
118+ /// * Any variable starting with `NUGET_`.
113119///
114120/// Any changes to these environment variables will cause cache invalidation for
115121/// hooks.
116122///
117123/// All other environment variables are stripped.
118124///
125+ /// ## Caching
126+ ///
127+ /// Hook execution is automatically cached by the hooks runner to avoid
128+ /// unnecessary runs.
129+ ///
130+ /// An execution of this hook is skipped, and the cached output is reused, if
131+ /// and only if:
132+ ///
133+ /// * The input to the hook didn't change (including the configuration fields
134+ /// in [BuildConfig] and the `user-defines` in the workspace `pubspec.yaml` ).
135+ /// * No environment variables (that are not filtered out) changed.
136+ /// * None of the files or directories declared in
137+ /// [HookOutputBuilder.dependencies] changed.
138+ /// * None of the transitive Dart sources of the hook script itself changed.
139+ /// * The workspace `package_config.json` didn't change.
140+ /// * The Dart SDK version didn't change.
141+ ///
142+ /// If any of these conditions are not met, the hook is re-run.
143+ ///
144+ /// ### Hook Output Dependencies
145+ ///
146+ /// To ensure cache correctness when external files or assets are modified,
147+ /// hooks must explicitly declare their file and directory dependencies using
148+ /// [HookOutputBuilder.dependencies] (e.g., via
149+ /// `output.dependencies.add(uri)` ).
150+ ///
151+ /// ### Cache Isolation
152+ ///
153+ /// Outputs are cached in a configuration-specific subdirectory inside
154+ /// `.dart_tool/hooks_runner/` . This directory is unique per hook and is derived
155+ /// from the [HookConfig] /[BuildConfig] structure. Therefore, different
156+ /// configurations (e.g., building for a different target OS or architecture)
157+ /// do not collide.
158+ ///
159+ /// The cache is reused for identical configurations across different builds,
160+ /// even when inputs outside the configuration or environment variables change.
161+ ///
119162/// ## Debugging
120163///
121164/// When a build hook doesn't work as expected, you can investigate the
@@ -260,9 +303,12 @@ Future<void> build(
260303/// * **Path and system roots:**
261304/// * `PATH`: Invoke native tools.
262305/// * `HOME`, `USERPROFILE`: Find tools in default install locations.
306+ /// * `APPDATA`, `LOCALAPPDATA`: NuGet, dart_data_home, and pub on
307+ /// Windows.
263308/// * `SYSTEMDRIVE`, `SYSTEMROOT`, `WINDIR`: Process invocations and CMake
264309/// on Windows.
265310/// * `PROGRAMDATA`: For `vswhere.exe` on Windows.
311+ /// * `PROCESSOR_ARCHITECTURE`: CMake Android on Windows.
266312/// * **Temporary directories:**
267313/// * `TEMP`, `TMP`, `TMPDIR`: Temporary directories.
268314/// * **HTTP proxies:**
@@ -278,12 +324,52 @@ Future<void> build(
278324/// * Any variable starting with `CCACHE_`.
279325/// * **Nix:**
280326/// * Any variable starting with `NIX_`.
327+ /// * **.NET and NuGet:**
328+ /// * Any variable starting with `DOTNET_`.
329+ /// * Any variable starting with `NUGET_`.
281330///
282331/// Any changes to these environment variables will cause cache invalidation for
283332/// hooks.
284333///
285334/// All other environment variables are stripped.
286335///
336+ /// ## Caching
337+ ///
338+ /// Hook execution is automatically cached by the hooks runner to avoid
339+ /// unnecessary runs.
340+ ///
341+ /// An execution of this hook is skipped, and the cached output is reused, if
342+ /// and only if:
343+ ///
344+ /// * The input to the hook didn't change (including the configuration fields
345+ /// in [LinkConfig] and the `user-defines` in the workspace `pubspec.yaml` ).
346+ /// * No environment variables (that are not filtered out) changed.
347+ /// * None of the files or directories declared in
348+ /// [HookOutputBuilder.dependencies] changed.
349+ /// * None of the transitive Dart sources of the hook script itself changed.
350+ /// * The workspace `package_config.json` didn't change.
351+ /// * The Dart SDK version didn't change.
352+ ///
353+ /// If any of these conditions are not met, the hook is re-run.
354+ ///
355+ /// ### Hook Output Dependencies
356+ ///
357+ /// To ensure cache correctness when external files or assets are modified,
358+ /// hooks must explicitly declare their file and directory dependencies using
359+ /// [HookOutputBuilder.dependencies] (e.g., via
360+ /// `output.dependencies.add(uri)` ).
361+ ///
362+ /// ### Cache Isolation
363+ ///
364+ /// Outputs are cached in a configuration-specific subdirectory inside
365+ /// `.dart_tool/hooks_runner/` . This directory is unique per hook and is derived
366+ /// from the [HookConfig] /[LinkConfig] structure. Therefore, different
367+ /// configurations (e.g., building for a different target OS or architecture)
368+ /// do not collide.
369+ ///
370+ /// The cache is reused for identical configurations across different builds,
371+ /// even when inputs outside the configuration or environment variables change.
372+ ///
287373/// ## Debugging
288374///
289375/// When a link hook doesn't work as expected, you can investigate the
0 commit comments