Skip to content

[StaticWebAssets] Support disabling the task result caching, do not write the cache file if up to date or no assets #49020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

javiercn
Copy link
Member

@javiercn javiercn commented May 16, 2025

  • Makes sure to only write the file when it's out of date
  • Enables a way to disable caching.

Fixes #48985

@github-actions github-actions bot added the Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch label May 16, 2025
Copy link
Contributor

Thanks for your PR, @@javiercn.
To learn about the PR process and branching schedule of this repo, please take a look at the SDK PR Guide.

@javiercn javiercn marked this pull request as ready for review May 16, 2025 16:41
@Copilot Copilot AI review requested due to automatic review settings May 16, 2025 16:41
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds the ability to disable the static web assets cache and prevents writing the cache file when it’s already up-to-date or when there are no assets to cache.

  • WriteCacheManifest now only writes if the cache is out of date and there are input hashes.
  • Introduces StaticWebAssetsCacheDefineStaticWebAssetsEnabled (default: true) to toggle caching and conditionally set cache path properties in several targets.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/StaticWebAssetsSdk/Tasks/DefineStaticWebAssets.Cache.cs Guard WriteCacheManifest to skip file writes when up-to-date or no inputs
src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.targets Add StaticWebAssetsCacheDefineStaticWebAssetsEnabled property and apply it to project cache path
src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.JSModules.targets Apply the cache-enable condition to JS modules cache paths
src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.Compression.targets Apply the cache-enable condition to compressed assets cache path

@javiercn javiercn merged commit b5dbc69 into main May 16, 2025
30 checks passed
@javiercn javiercn deleted the javiercn/avoid-writing-cache-when-empty-or-up-to-date branch May 16, 2025 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

There doesn't appear to be an easy way to disable StaticWebAssets caching functionality
2 participants