Skip to content

Commit a4add5d

Browse files
authored
[Static Web Assets] Introduce static web asset endpoints and define compression endpoints (#39636)
* Defines a StaticWebAssetEndpoint to represent how an asset should be served. * Computes endpoints for each of the static web assets. * Generates a manifest containing all the endpoints that can be consumed by the runtime describing how to serve the files. * Updates packages to include endpoints as part of their static web assets metadata.
1 parent a4ecf6a commit a4add5d

File tree

161 files changed

+309880
-2259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+309880
-2259
lines changed
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
<Project />
1+
<Project>
2+
<PropertyGroup>
3+
<CheckEolTargetFramework>false</CheckEolTargetFramework>
4+
</PropertyGroup>
5+
</Project>

src/Assets/WasmOverride/Nuget.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3+
<add key="signatureValidationMode" value="accept" />
34
<packageSourceMapping>
45
<clear />
56
</packageSourceMapping>

src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,17 @@ Copyright (c) .NET Foundation. All rights reserved.
124124
<Output TaskParameter="Assets" ItemName="_BlazorJSStaticWebAsset" />
125125
</DefineStaticWebAssets>
126126

127+
<DefineStaticWebAssetEndpoints
128+
CandidateAssets="@(_BlazorJSStaticWebAsset)"
129+
ExistingEndpoints="@(StaticWebAssetEndpoint)"
130+
ContentTypeMappings="@(StaticWebAssetContentTypeMapping)"
131+
>
132+
<Output TaskParameter="Endpoints" ItemName="_BlazorStaticWebAssetEndpoint" />
133+
</DefineStaticWebAssetEndpoints>
134+
127135
<ItemGroup>
128136
<StaticWebAsset Include="@(_BlazorJSStaticWebAsset)" />
137+
<StaticWebAssetEndpoint Include="@(_BlazorStaticWebAssetEndpoint)" />
129138
</ItemGroup>
130139
</Target>
131140

src/RazorSdk/update-test-baselines.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ $TestProjects = "Microsoft.NET.Sdk.Razor.Tests", "Microsoft.NET.Sdk.BlazorWebAss
55
ForEach-Object { Join-Path -Path "$RepoRoot/test/" -ChildPath $_ };
66

77
if($Validate){
8-
$TestProjects | ForEach-Object { dotnet test --no-build -l "console;verbosity=normal" $_ --filter AspNetCore=BaselineTest }
8+
$TestProjects | ForEach-Object { dotnet test --no-build -c Release -l "console;verbosity=normal" $_ --filter AspNetCore=BaselineTest }
99
}else {
10-
$TestProjects | ForEach-Object { dotnet test --no-build -l "console;verbosity=normal" $_ -e ASPNETCORE_TEST_BASELINES=true --filter AspNetCore=BaselineTest }
10+
$TestProjects | ForEach-Object { dotnet test --no-build -c Release -l "console;verbosity=normal" $_ -e ASPNETCORE_TEST_BASELINES=true --filter AspNetCore=BaselineTest }
1111
}

src/RazorSdk/update-test-baselines.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ if [ $Validate -eq 1 ]; then
5151
echo "Running in validate mode"
5252
for TestProject in "${TestProjects[@]}"; do
5353
echo "Running dotnet test on $TestProject"
54-
dotnet test --no-build -l "console;verbosity=normal" "$TestProject" --filter AspNetCore=BaselineTest
54+
dotnet test --no-build -c Release -l "console;verbosity=normal" "$TestProject" --filter AspNetCore=BaselineTest
5555
done
5656
else
5757
echo "Running in non-validate mode"
5858
for TestProject in "${TestProjects[@]}"; do
5959
echo "Running dotnet test on $TestProject"
60-
dotnet test --no-build -l "console;verbosity=normal" "$TestProject" -e ASPNETCORE_TEST_BASELINES=true --filter AspNetCore=BaselineTest
60+
dotnet test --no-build -c Release -l "console;verbosity=normal" "$TestProject" -e ASPNETCORE_TEST_BASELINES=true --filter AspNetCore=BaselineTest
6161
done
6262
fi

src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.5_0.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Copyright (c) .NET Foundation. All rights reserved.
4343
Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />
4444

4545
<UsingTask
46-
TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAsssetsPropsFile"
46+
TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAssetsPropsFile"
4747
AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
4848
Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />
4949

@@ -513,7 +513,7 @@ Copyright (c) .NET Foundation. All rights reserved.
513513
<!-- Generates a props file that goes in build\Microsoft.AspNetCore.StaticWebAssets.props
514514
and that describes the static web assets for the package.
515515
-->
516-
<GenerateStaticWebAsssetsPropsFile
516+
<GenerateStaticWebAssetsPropsFile
517517
Condition="'$(_CurrentProjectHasStaticWebAssets)' == 'true'"
518518
StaticWebAssets="@(_CurrentProjectStaticWebAsset)"
519519
AllowEmptySourceType="true"

src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.Compression.targets

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Copyright (c) .NET Foundation. All rights reserved.
1515
<UsingTask TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.BrotliCompress" AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)" />
1616
<UsingTask TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.GZipCompress" AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)" />
1717
<UsingTask TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.ResolveCompressedAssets" AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)" />
18+
<UsingTask TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.ApplyCompressionNegotiation" AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)" />
1819

1920
<PropertyGroup>
2021

@@ -220,8 +221,35 @@ Copyright (c) .NET Foundation. All rights reserved.
220221
<DefineStaticWebAssets
221222
CandidateAssets="@(_CompressedStaticWebAssets)"
222223
>
223-
<Output TaskParameter="Assets" ItemName="StaticWebAsset" />
224+
<Output TaskParameter="Assets" ItemName="_CompressionBuildStaticWebAsset" />
224225
</DefineStaticWebAssets>
226+
227+
<DefineStaticWebAssetEndpoints
228+
CandidateAssets="@(_CompressionBuildStaticWebAsset)"
229+
ExistingEndpoints="@(StaticWebAssetEndpoint)"
230+
ContentTypeMappings="@(StaticWebAssetContentTypeMapping)"
231+
>
232+
<Output TaskParameter="Endpoints" ItemName="_CompressionBuildStaticWebAssetEndpoint" />
233+
</DefineStaticWebAssetEndpoints>
234+
235+
<ItemGroup>
236+
<StaticWebAsset Include="@(_CompressionBuildStaticWebAsset)" />
237+
<StaticWebAssetEndpoint Include="@(_CompressionBuildStaticWebAssetEndpoint)" />
238+
<_CompressionCurrentProjectBuildAssets Include="@(StaticWebAsset)" />
239+
</ItemGroup>
240+
241+
<ApplyCompressionNegotiation
242+
CandidateEndpoints="@(StaticWebAssetEndpoint)"
243+
CandidateAssets="@(_CompressionCurrentProjectBuildAssets)"
244+
>
245+
<Output TaskParameter="UpdatedEndpoints" ItemName="_UpdatedCompressionBuildEndpoints" />
246+
</ApplyCompressionNegotiation>
247+
248+
<ItemGroup>
249+
<StaticWebAssetEndpoint Remove="@(_UpdatedCompressionBuildEndpoints)" />
250+
<StaticWebAssetEndpoint Include="@(_UpdatedCompressionBuildEndpoints)" />
251+
</ItemGroup>
252+
225253
</Target>
226254

227255
<Target Name="GenerateBuildCompressedStaticWebAssets" DependsOnTargets="$(GenerateBuildCompressedStaticWebAssetsDependsOn);$(CompressFilesDependsOn)">
@@ -275,8 +303,35 @@ Copyright (c) .NET Foundation. All rights reserved.
275303
<DefineStaticWebAssets
276304
CandidateAssets="@(_CompressedStaticWebAssetsForPublish)"
277305
>
278-
<Output TaskParameter="Assets" ItemName="StaticWebAsset" />
306+
<Output TaskParameter="Assets" ItemName="_CompressionPublishStaticWebAsset" />
279307
</DefineStaticWebAssets>
308+
309+
<DefineStaticWebAssetEndpoints
310+
CandidateAssets="@(_CompressionPublishStaticWebAsset)"
311+
ExistingEndpoints="@(StaticWebAssetEndpoint)"
312+
ContentTypeMappings="@(StaticWebAssetContentTypeMapping)"
313+
>
314+
<Output TaskParameter="Endpoints" ItemName="_CompressionPublishStaticWebAssetEndpoint" />
315+
</DefineStaticWebAssetEndpoints>
316+
317+
<ItemGroup>
318+
<StaticWebAsset Include="@(_CompressionPublishStaticWebAsset)" />
319+
<StaticWebAssetEndpoint Include="@(_CompressionPublishStaticWebAssetEndpoint)" />
320+
<_CompressionCurrentProjectPublishAssets Include="@(StaticWebAsset)" Condition="'%(AssetKind)' != 'Build'" />
321+
</ItemGroup>
322+
323+
<ApplyCompressionNegotiation
324+
CandidateEndpoints="@(StaticWebAssetEndpoint)"
325+
CandidateAssets="@(_CompressionCurrentProjectPublishAssets)"
326+
>
327+
<Output TaskParameter="UpdatedEndpoints" ItemName="_UpdatedCompressionPublishEndpoints" />
328+
</ApplyCompressionNegotiation>
329+
330+
<ItemGroup>
331+
<StaticWebAssetEndpoint Remove="@(_UpdatedCompressionPublishEndpoints)" />
332+
<StaticWebAssetEndpoint Include="@(_UpdatedCompressionPublishEndpoints)" />
333+
</ItemGroup>
334+
280335
</Target>
281336

282337
<Target Name="GeneratePublishCompressedStaticWebAssets" DependsOnTargets="$(CompressFilesForPublishDependsOn);$(GeneratePublishCompressedStaticWebAssetsDependsOn)">

0 commit comments

Comments
 (0)