-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Cache assemblies and wasm using content hashes #18859
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
Changes from all commits
4791469
bca2a4b
02137de
a1121e9
0ebda64
bbc1024
ba98132
457fab5
2521224
e32d9ff
832a5ee
706268a
29418fe
4dded78
7d7acc4
95f31fa
945b8f0
e1dcf8e
faed3a4
781caef
777d91e
cf9018a
ec8206a
85c42bb
203f1a7
a28a257
62fd199
a35d1e8
9f58b70
9c8e2ae
323843c
6cabf3b
63360d1
fe3476c
7337f88
ddf1a45
5346ee8
888e93b
7613e67
01bc2a3
3a0e839
e5a3cf4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -52,26 +52,6 @@ | |||||
<Target | ||||||
Name="PrepareBlazorOutputs" | ||||||
DependsOnTargets="_ResolveBlazorInputs;_ResolveBlazorOutputs;_GenerateBlazorBootJson"> | ||||||
|
||||||
<ItemGroup> | ||||||
<MonoWasmFile Include="$(DotNetWebAssemblyRuntimePath)*" /> | ||||||
<BlazorJSFile Include="$(BlazorJSPath)" /> | ||||||
<BlazorJSFile Include="$(BlazorJSMapPath)" Condition="Exists('$(BlazorJSMapPath)')" /> | ||||||
|
||||||
<BlazorOutputWithTargetPath Include="@(MonoWasmFile)"> | ||||||
<TargetOutputPath>$(BlazorRuntimeWasmOutputPath)%(FileName)%(Extension)</TargetOutputPath> | ||||||
</BlazorOutputWithTargetPath> | ||||||
<BlazorOutputWithTargetPath Include="@(BlazorJSFile)"> | ||||||
<TargetOutputPath>$(BaseBlazorRuntimeOutputPath)%(FileName)%(Extension)</TargetOutputPath> | ||||||
</BlazorOutputWithTargetPath> | ||||||
</ItemGroup> | ||||||
|
||||||
<ItemGroup Label="Static content supplied by NuGet packages"> | ||||||
<_BlazorPackageContentOutput Include="@(BlazorPackageContentFile)" Condition="%(SourcePackage) != ''"> | ||||||
<TargetOutputPath>$(BaseBlazorPackageContentOutputPath)%(SourcePackage)\%(RecursiveDir)\%(Filename)%(Extension)</TargetOutputPath> | ||||||
</_BlazorPackageContentOutput> | ||||||
<BlazorOutputWithTargetPath Include="@(_BlazorPackageContentOutput)" /> | ||||||
</ItemGroup> | ||||||
</Target> | ||||||
|
||||||
<Target Name="_ResolveBlazorInputs" DependsOnTargets="ResolveReferences;ResolveRuntimePackAssets"> | ||||||
|
@@ -128,6 +108,11 @@ | |||||
Message="Unrecongnized value for BlazorLinkOnBuild: '$(BlazorLinkOnBuild)'. Valid values are 'true' or 'false'." | ||||||
Condition="'$(BlazorLinkOnBuild)' != 'true' AND '$(BlazorLinkOnBuild)' != 'false'" /> | ||||||
|
||||||
<!-- | ||||||
These are the items calculated as the closure of the runtime assemblies, either by calling the linker | ||||||
or by calling our custom ResolveBlazorRuntimeDependencies task if the linker was disabled. Other than | ||||||
satellite assemblies, this should include all assemblies needed to run the application. | ||||||
--> | ||||||
<ItemGroup> | ||||||
<!-- | ||||||
ReferenceCopyLocalPaths includes all files that are part of the build out with CopyLocalLockFileAssemblies on. | ||||||
|
@@ -146,6 +131,49 @@ | |||||
<BlazorRuntimeFile>true</BlazorRuntimeFile> | ||||||
<TargetOutputPath>$(BlazorRuntimeBinOutputPath)%(FileName)%(Extension)</TargetOutputPath> | ||||||
<RelativeOutputPath>%(FileName)%(Extension)</RelativeOutputPath> | ||||||
</BlazorOutputWithTargetPath> | ||||||
</ItemGroup> | ||||||
|
||||||
<!-- | ||||||
We need to know at build time (not publish time) whether or not to include pdbs in the | ||||||
blazor.boot.json file, so this is controlled by the BlazorEnableDebugging flag, whose | ||||||
default value is determined by the build configuration. | ||||||
--> | ||||||
<ItemGroup Condition="'$(BlazorEnableDebugging)' != 'true'"> | ||||||
<BlazorOutputWithTargetPath Remove="@(BlazorOutputWithTargetPath)" Condition="'%(Extension)' == '.pdb'" /> | ||||||
</ItemGroup> | ||||||
|
||||||
<!-- | ||||||
The following itemgroup attempts to extend the set to include satellite assemblies. | ||||||
The mechanism behind this (or whether it's correct) is a bit unclear so | ||||||
https://github.com/dotnet/aspnetcore/issues/18951 tracks the need for follow-up. | ||||||
--> | ||||||
<ItemGroup> | ||||||
<!-- | ||||||
ReferenceCopyLocalPaths includes all files that are part of the build out with CopyLocalLockFileAssemblies on. | ||||||
Remove assemblies that are inputs to calculating the assembly closure. Instead use the resolved outputs, since it is the minimal set. | ||||||
--> | ||||||
<_BlazorCopyLocalPaths Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)' == '.dll'" /> | ||||||
<_BlazorCopyLocalPaths Remove="@(_BlazorManagedRuntimeAssemby)" Condition="'%(Extension)' == '.dll'" /> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This condition is needed as a workaround for #18951. We might find a better solution later, but that's separate from this PR. |
||||||
|
||||||
<BlazorOutputWithTargetPath Include="@(_BlazorCopyLocalPaths)"> | ||||||
<BlazorRuntimeFile>true</BlazorRuntimeFile> | ||||||
<TargetOutputPath>$(BlazorRuntimeBinOutputPath)%(_BlazorCopyLocalPaths.DestinationSubDirectory)%(FileName)%(Extension)</TargetOutputPath> | ||||||
<RelativeOutputPath>%(_BlazorCopyLocalPaths.DestinationSubDirectory)%(FileName)%(Extension)</RelativeOutputPath> | ||||||
</BlazorOutputWithTargetPath> | ||||||
</ItemGroup> | ||||||
|
||||||
<ItemGroup> | ||||||
<MonoWasmFile Include="$(DotNetWebAssemblyRuntimePath)*" /> | ||||||
<BlazorJSFile Include="$(BlazorJSPath)" /> | ||||||
<BlazorJSFile Include="$(BlazorJSMapPath)" Condition="Exists('$(BlazorJSMapPath)')" /> | ||||||
|
||||||
<BlazorOutputWithTargetPath Include="@(MonoWasmFile)"> | ||||||
<TargetOutputPath>$(BlazorRuntimeWasmOutputPath)%(FileName)%(Extension)</TargetOutputPath> | ||||||
<BlazorRuntimeFile>true</BlazorRuntimeFile> | ||||||
</BlazorOutputWithTargetPath> | ||||||
<BlazorOutputWithTargetPath Include="@(BlazorJSFile)"> | ||||||
<TargetOutputPath>$(BaseBlazorRuntimeOutputPath)%(FileName)%(Extension)</TargetOutputPath> | ||||||
</BlazorOutputWithTargetPath> | ||||||
</ItemGroup> | ||||||
</Target> | ||||||
|
@@ -267,7 +295,7 @@ | |||||
|
||||||
<ItemGroup> | ||||||
<_LinkerResult Include="$(BlazorIntermediateLinkerOutputPath)*.dll" /> | ||||||
<_LinkerResult Include="$(BlazorIntermediateLinkerOutputPath)*.pdb" Condition="'$(BlazorEnableDebugging)' == 'true'" /> | ||||||
<_LinkerResult Include="$(BlazorIntermediateLinkerOutputPath)*.pdb" /> | ||||||
</ItemGroup> | ||||||
|
||||||
<WriteLinesToFile File="$(_BlazorLinkerOutputCache)" Lines="@(_LinkerResult)" Overwrite="true" /> | ||||||
|
@@ -318,13 +346,27 @@ | |||||
Inputs="$(MSBuildAllProjects);@(BlazorOutputWithTargetPath)" | ||||||
Outputs="$(BlazorBootJsonIntermediateOutputPath)"> | ||||||
<ItemGroup> | ||||||
<_BlazorRuntimeFile Include="@(BlazorOutputWithTargetPath->WithMetadataValue('BlazorRuntimeFile', 'true'))" /> | ||||||
<_BlazorBootResource Include="@(BlazorOutputWithTargetPath->WithMetadataValue('BlazorRuntimeFile', 'true'))" /> | ||||||
<_BlazorBootResource BootResourceType="assembly" Condition="'%(Extension)' == '.dll'" /> | ||||||
<_BlazorBootResource BootResourceType="pdb" Condition="'%(Extension)' == '.pdb'" /> | ||||||
<_BlazorBootResource BootResourceType="wasm" Condition="'%(Extension)' == '.wasm'" /> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we be concerned about files that don't match one of these extension types? Are the non-matching files all of the other static assets that don't belong in boot.json? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ones without the BlazorRuntimeFile are the other static assets that don’t belong in the boot json. Additionally we’re excluding other extensions from boot json by virtue of not assigning any BootResourceType. This eliminates the AssemblyName.xml files that would otherwise sometimes appear. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we think it is important to differentiate by dll, pdbs and wasm? I think having the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic about how to distinguish the file types has to exist somewhere. I agree it could be done on the .NET side too but that seems neither better nor worse. If you can anticipate some problem with doing it on the MSBuild side I'm fine with changing it, but otherwise I suspect it's a neutral choice and we're just as well leaving it as-is. It's an internal implementation detail we can change later if we want. |
||||||
</ItemGroup> | ||||||
|
||||||
<GetFileHash Files="@(_BlazorBootResource->HasMetadata('BootResourceType'))" Algorithm="SHA256" HashEncoding="base64"> | ||||||
SteveSandersonMS marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
<Output TaskParameter="Items" ItemName="_BlazorBootResourceWithHash" /> | ||||||
</GetFileHash> | ||||||
|
||||||
<PropertyGroup> | ||||||
<_IsDebugBuild>false</_IsDebugBuild> | ||||||
<_IsDebugBuild Condition="'$(Configuration)' == 'Debug'">true</_IsDebugBuild> | ||||||
<BlazorCacheBootResources Condition="'$(BlazorCacheBootResources)' == ''">true</BlazorCacheBootResources> | ||||||
</PropertyGroup> | ||||||
<GenerateBlazorBootJson | ||||||
AssemblyPath="@(IntermediateAssembly)" | ||||||
References="@(_BlazorRuntimeFile)" | ||||||
Resources="@(_BlazorBootResourceWithHash)" | ||||||
DebugBuild="$(_IsDebugBuild)" | ||||||
LinkerEnabled="$(BlazorLinkOnBuild)" | ||||||
CacheBootResources="$(BlazorCacheBootResources)" | ||||||
OutputPath="$(BlazorBootJsonIntermediateOutputPath)" /> | ||||||
|
||||||
<ItemGroup> | ||||||
|
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.