[StaticWebAssets] Detects pre-compressed assets#44976
Merged
mkArtakMSFT merged 11 commits intorelease/9.0.1xxfrom Nov 20, 2024
Merged
[StaticWebAssets] Detects pre-compressed assets#44976mkArtakMSFT merged 11 commits intorelease/9.0.1xxfrom
mkArtakMSFT merged 11 commits intorelease/9.0.1xxfrom
Conversation
Contributor
|
Thanks for your PR, @javiercn. |
javiercn
commented
Nov 20, 2024
Comment on lines
+280
to
+300
| <!-- There might be assets that are precompressed on packages or that are precompressed by other tools. | ||
| In this case, we need to detect those assets, remove them and their endpoints, adjust the asset definition | ||
| and recreate the endpoints for those assets as the original ones will not be correct. | ||
| --> | ||
| <DiscoverPrecompressedAssets CandidateAssets="@(StaticWebAsset)"> | ||
| <Output TaskParameter="DiscoveredCompressedAssets" ItemName="_PrecompressedStaticWebAssets" /> | ||
| </DiscoverPrecompressedAssets> | ||
|
|
||
| <FilterStaticWebAssetEndpoints Condition="'@(_PrecompressedStaticWebAssets)' != ''" | ||
| Endpoints="@(StaticWebAssetEndpoint)" | ||
| Assets="@(_PrecompressedStaticWebAssets)" | ||
| Filters="" | ||
| > | ||
| <Output TaskParameter="FilteredEndpoints" ItemName="_PrecompressedEndpointsToRemove" /> | ||
| </FilterStaticWebAssetEndpoints> | ||
|
|
||
| <ItemGroup Condition="'@(_PrecompressedStaticWebAssets)' != ''"> | ||
| <StaticWebAssetEndpoint Remove="@(_PrecompressedEndpointsToRemove)" /> | ||
| <StaticWebAsset Remove="@(_PrecompressedStaticWebAssets)" /> | ||
| <StaticWebAsset Include="@(_PrecompressedStaticWebAssets)" /> | ||
| </ItemGroup> |
Member
Author
There was a problem hiding this comment.
- Discover existing pre-compressed assets.
- Remove their original definitions.
- Provide an updated definition.
- Remove the associated endpoint definitions and re-generate new endpoints.
This was referenced Nov 20, 2024
MackinnonBuck
approved these changes
Nov 20, 2024
src/StaticWebAssetsSdk/Tasks/Compression/DiscoverPrecompressedAssets.cs
Outdated
Show resolved
Hide resolved
src/StaticWebAssetsSdk/Tasks/Compression/DiscoverPrecompressedAssets.cs
Outdated
Show resolved
Hide resolved
MattParkerDev
approved these changes
Nov 20, 2024
Contributor
|
I've got verbal approval about this one (@marcpopMSFT , @SteveMCarroll ) |
javiercn
added a commit
that referenced
this pull request
Dec 13, 2024
Detects assets that have been pre-compressed by an external tool to avoid conflicts when we compress our own assets, and they end up on the same path as the existing pre-compressed assets. Forward port of #44976
javiercn
added a commit
that referenced
this pull request
Dec 13, 2024
Detects assets that have been pre-compressed by an external tool to avoid conflicts when we compress our own assets, and they end up on the same path as the existing pre-compressed assets. Forward port of #44976
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Detects pre-compressed assets
Detects assets that have been pre-compressed by an external tool to avoid conflicts when we compress our own assets, and they end up on the same path as the existing pre-compressed assets.
Description
We have received feedback that some customers are facing issues upgrading as they are consuming packages that contain pre-compressed assets or are using third-party tools (like webpack) that produce pre-compressed versions of those assets.
Our recommendation in these cases is to let the framework handle the compression, as it further optimizes the delivery of those assets. However, this requires changes on their project to disable the compression on the third-party tools / exclude the pre compressed assets or to disable the compression that is done by the framework (a one-line MSBuild change).
We, however, recognize that this cause friction during the upgrade process and want to improve the situation by following the most common convention, which is, detecting compressed versions of an asset that live side-by-side with it. (Same path with an extra .gz or .br for the compressed versions)
This change detects such scenarios and starts treating the assets in the same way as if they were defined by the framework.
Fixes dotnet/aspnetcore#57518
Customer Impact
Customers with pre compressed files in their web content are forced to either remove those assets from the build or disable compression when they upgrade, as otherwise the build breaks.
Regression?
It's not a regression because this is a new feature, but it impacts the upgrade flow in this particular scenario.
Risk
There is a flag that can be used to turn off compression on the framework, which will prevent any compression related code from running.
The new added logic should no-op in most common cases and only ever execute when we detect a pre-compressed asset that was not generated by the framework.
Verification
Packaging changes reviewed?
When servicing release/2.1