Skip to content

Commit 5493b41

Browse files
Add package for consuming Blazor framework assets (#58721)
1 parent 38250c1 commit 5493b41

File tree

45 files changed

+234
-235
lines changed

Some content is hidden

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

45 files changed

+234
-235
lines changed

AspNetCore.sln

+22
Original file line numberDiff line numberDiff line change
@@ -1816,6 +1816,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.OpenAp
18161816
EndProject
18171817
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.App.SourceGenerators", "src\Framework\AspNetCoreAnalyzers\src\SourceGenerators\Microsoft.AspNetCore.App.SourceGenerators.csproj", "{C3928C15-1836-46DB-A09D-9EFBCCA33E08}"
18181818
EndProject
1819+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Assets", "Assets", "{2B858B82-5F0B-4A24-B3C0-5E99149F70D6}"
1820+
EndProject
1821+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.App.Internal.Assets", "src\Assets\Microsoft.AspNetCore.App.Internal.Assets.csproj", "{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}"
1822+
EndProject
18191823
Global
18201824
GlobalSection(SolutionConfigurationPlatforms) = preSolution
18211825
Debug|Any CPU = Debug|Any CPU
@@ -10977,6 +10981,22 @@ Global
1097710981
{C3928C15-1836-46DB-A09D-9EFBCCA33E08}.Release|x64.Build.0 = Release|Any CPU
1097810982
{C3928C15-1836-46DB-A09D-9EFBCCA33E08}.Release|x86.ActiveCfg = Release|Any CPU
1097910983
{C3928C15-1836-46DB-A09D-9EFBCCA33E08}.Release|x86.Build.0 = Release|Any CPU
10984+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
10985+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Debug|Any CPU.Build.0 = Debug|Any CPU
10986+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Debug|arm64.ActiveCfg = Debug|Any CPU
10987+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Debug|arm64.Build.0 = Debug|Any CPU
10988+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Debug|x64.ActiveCfg = Debug|Any CPU
10989+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Debug|x64.Build.0 = Debug|Any CPU
10990+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Debug|x86.ActiveCfg = Debug|Any CPU
10991+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Debug|x86.Build.0 = Debug|Any CPU
10992+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Release|Any CPU.ActiveCfg = Release|Any CPU
10993+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Release|Any CPU.Build.0 = Release|Any CPU
10994+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Release|arm64.ActiveCfg = Release|Any CPU
10995+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Release|arm64.Build.0 = Release|Any CPU
10996+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Release|x64.ActiveCfg = Release|Any CPU
10997+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Release|x64.Build.0 = Release|Any CPU
10998+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Release|x86.ActiveCfg = Release|Any CPU
10999+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62}.Release|x86.Build.0 = Release|Any CPU
1098011000
EndGlobalSection
1098111001
GlobalSection(SolutionProperties) = preSolution
1098211002
HideSolutionNode = FALSE
@@ -11874,6 +11894,8 @@ Global
1187411894
{B32FF7A7-9CB3-4DCD-AE97-3B2594DB9DAC} = {2299CCD8-8F9C-4F2B-A633-9BF4DA81022B}
1187511895
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7} = {B32FF7A7-9CB3-4DCD-AE97-3B2594DB9DAC}
1187611896
{C3928C15-1836-46DB-A09D-9EFBCCA33E08} = {B5D98AEB-9409-4280-8225-9C1EC6A791B2}
11897+
{2B858B82-5F0B-4A24-B3C0-5E99149F70D6} = {017429CC-C5FB-48B4-9C46-034E29EE2F06}
11898+
{2AAE7819-BC3E-48F4-9CFA-5DD4CD5FFD62} = {2B858B82-5F0B-4A24-B3C0-5E99149F70D6}
1187711899
EndGlobalSection
1187811900
GlobalSection(ExtensibilityGlobals) = postSolution
1187911901
SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F}

eng/Build.props

+2
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
$(RepoRoot)src\Framework\App.Ref.Internal\src\Microsoft.AspNetCore.App.Ref.Internal.csproj;
178178
$(RepoRoot)src\Framework\AspNetCoreAnalyzers\test\Microsoft.AspNetCore.App.Analyzers.Test.csproj;
179179
$(RepoRoot)src\Framework\test\Microsoft.AspNetCore.App.UnitTests.csproj;
180+
$(RepoRoot)src\Assets\**\*.*proj;
180181
$(RepoRoot)src\Caching\**\*.*proj;
181182
$(RepoRoot)src\DefaultBuilder\**\*.*proj;
182183
$(RepoRoot)src\Features\JsonPatch\**\*.*proj;
@@ -225,6 +226,7 @@
225226
$(RepoRoot)**\obj\**\*;"
226227
Condition=" '$(BuildMainlyReferenceProviders)' != 'true' " />
227228
<DotNetProjects Include="
229+
$(RepoRoot)src\Assets\**\*.*proj;
228230
$(RepoRoot)src\Caching\**\src\*.csproj;
229231
$(RepoRoot)src\DefaultBuilder\**\src\*.csproj;
230232
$(RepoRoot)src\Features\JsonPatch\**\src\*.csproj;

eng/ProjectReferences.props

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
-->
66
<Project>
77
<ItemGroup>
8+
<ProjectReferenceProvider Include="Microsoft.AspNetCore.App.Internal.Assets" ProjectPath="$(RepoRoot)src\Assets\Microsoft.AspNetCore.App.Internal.Assets.csproj" />
89
<ProjectReferenceProvider Include="Microsoft.Extensions.Caching.SqlServer" ProjectPath="$(RepoRoot)src\Caching\SqlServer\src\Microsoft.Extensions.Caching.SqlServer.csproj" />
910
<ProjectReferenceProvider Include="Microsoft.Extensions.Caching.StackExchangeRedis" ProjectPath="$(RepoRoot)src\Caching\StackExchangeRedis\src\Microsoft.Extensions.Caching.StackExchangeRedis.csproj" />
1011
<ProjectReferenceProvider Include="Microsoft.AspNetCore" ProjectPath="$(RepoRoot)src\DefaultBuilder\src\Microsoft.AspNetCore.csproj" />

eng/ShippingAssemblies.props

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
<AspNetCoreShippingAssembly Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" />
106106
<AspNetCoreShippingAssembly Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
107107
<AspNetCoreShippingAssembly Include="Microsoft.Extensions.Features" />
108+
<AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.App.Internal.Assets" />
108109
<AspNetCoreShippingAssembly Include="Microsoft.Extensions.Caching.SqlServer" />
109110
<AspNetCoreShippingAssembly Include="Microsoft.Extensions.Caching.StackExchangeRedis" />
110111
<AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.JsonPatch" />

eng/scripts/npm/update-dependency-versions.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function applyPackageVersion(packagesToPack, defaultPackageVersion) {
5252
renames.push([`${packagePath}.bak`, packagePath]);
5353

5454
process.chdir(packageDir);
55-
execSync(`npm version ${packageVersion} --no-git-tag-version`, { stdio: 'inherit' });
55+
execSync(`npm version ${packageVersion} --no-git-tag-version --allow-same-version`, { stdio: 'inherit' });
5656
process.chdir(currentDir);
5757
console.log(`Applied version ${packageVersion} to ${packageName} in ${packageDir}...`);
5858
}

eng/tools/GenerateFiles/Directory.Build.targets.in

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
TargetFramework="${DefaultNetCoreTargetFramework}"
4040
Condition="'@(KnownWebAssemblySdkPack->Count())' != '0' AND
4141
!(@(KnownWebAssemblySdkPack->AnyHaveMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}')))" />
42+
<KnownAspNetCorePack
43+
Include="@(KnownAspNetCorePack->WithMetadataValue('TargetFramework', 'net9.0'))"
44+
TargetFramework="${DefaultNetCoreTargetFramework}"
45+
Condition="'@(KnownAspNetCorePack->Count())' != '0' AND
46+
!(@(KnownAspNetCorePack->AnyHaveMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}')))" />
4247
</ItemGroup>
4348

4449
<ItemGroup>
@@ -95,6 +100,11 @@
95100
Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftNETCoreAppRuntimeVersion}</WebAssemblySdkPackVersion>
96101
</KnownWebAssemblySdkPack>
97102

103+
<KnownAspNetCorePack Update="Microsoft.AspNetCore.App.Internal.Assets">
104+
<AspNetCorePackVersion
105+
Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftAspNetCoreAppRuntimeVersion}</AspNetCorePackVersion>
106+
</KnownAspNetCorePack>
107+
98108
<KnownCrossgen2Pack Update="Microsoft.NETCore.App.Crossgen2" Condition=" '$(DotNetBuildSourceOnly)' == 'true' ">
99109
<Crossgen2PackVersion
100110
Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftNETCoreAppRuntimeVersion}</Crossgen2PackVersion>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Pack">
2+
3+
<PropertyGroup>
4+
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
5+
<Description>ASP.NET Core static framework assets</Description>
6+
<PackageId>Microsoft.AspNetCore.App.Internal.Assets</PackageId>
7+
<IsPackable>true</IsPackable>
8+
<OutputType>Library</OutputType>
9+
<ExcludeFromSourceOnlyBuild>true</ExcludeFromSourceOnlyBuild>
10+
<CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
11+
<IncludeBuildOutput>false</IncludeBuildOutput>
12+
<IncludeSymbols>false</IncludeSymbols>
13+
<ImplicitUsings>disable</ImplicitUsings>
14+
15+
<!-- The package doesn't produce any lib or ref assemblies -->
16+
<NoWarn>$(NoWarn);NU5128</NoWarn>
17+
</PropertyGroup>
18+
19+
<PropertyGroup>
20+
<_BlazorJSContentRoot Condition="'$(Configuration)' == 'Debug'">$(RepoRoot)src\Components\Web.JS\dist\Debug</_BlazorJSContentRoot>
21+
<_BlazorJSContentRoot Condition="'$(Configuration)' == 'Release'">$(RepoRoot)src\Components\Web.JS\dist\Release</_BlazorJSContentRoot>
22+
</PropertyGroup>
23+
24+
<ItemGroup>
25+
<_BlazorJSFile Include="$(_BlazorJSContentRoot)\blazor.web.js" />
26+
<_BlazorJSFile Include="$(_BlazorJSContentRoot)\blazor.server.js" />
27+
<_BlazorJSFile Include="$(_BlazorJSContentRoot)\blazor.webassembly.js" />
28+
29+
<_BlazorJSFile Include="$(_BlazorJSContentRoot)\blazor.web.js.map" />
30+
<_BlazorJSFile Include="$(_BlazorJSContentRoot)\blazor.server.js.map" />
31+
<_BlazorJSFile Include="$(_BlazorJSContentRoot)\blazor.webassembly.js.map" />
32+
</ItemGroup>
33+
34+
<ItemGroup>
35+
<None Include="build\*" Pack="true" PackagePath="%(Identity)" />
36+
<None Include="buildMultiTargeting\*" Pack="true" PackagePath="%(Identity)" />
37+
<None Include="buildTransitive\*" Pack="true" PackagePath="%(Identity)" />
38+
<None Include="@(_BlazorJSFile)" Pack="true" PackagePath="_framework\%(FileName)%(Extension)" />
39+
</ItemGroup>
40+
41+
<Target Name="_CheckBlazorJSPath" AfterTargets="ResolveProjectReferences">
42+
<ItemGroup>
43+
<_MissingBlazorJSFile Include="@(_BlazorJSFile)" Condition="!EXISTS('%(_BlazorJSFile.FullPath)')" />
44+
</ItemGroup>
45+
46+
<Error
47+
Condition="'@(_MissingBlazorJSFile)' != ''"
48+
Text="'%(_MissingBlazorJSFile.Identity)' does not exist. Run 'npm run build' in the repo root to generate the file." />
49+
</Target>
50+
51+
</Project>

src/Assets/build.cmd

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@ECHO OFF
2+
SET RepoRoot=%~dp0..\..
3+
%RepoRoot%\eng\build.cmd -projects %~dp0**\*.*proj %*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<Project>
2+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ResolveStaticWebAssetsInputsDependsOn>
4+
$(ResolveStaticWebAssetsInputsDependsOn);
5+
_AddBlazorFrameworkStaticWebAssets;
6+
</ResolveStaticWebAssetsInputsDependsOn>
7+
</PropertyGroup>
8+
9+
<PropertyGroup>
10+
<BlazorFrameworkStaticWebAssetRoot Condition="'$(BlazorFrameworkStaticWebAssetRoot)' == ''">$(MSBuildThisFileDirectory)..\_framework</BlazorFrameworkStaticWebAssetRoot>
11+
</PropertyGroup>
12+
13+
<Target Name="_AddBlazorFrameworkStaticWebAssets" Condition="'$(OutputType)' == 'Exe'">
14+
<ItemGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true'">
15+
<_FrameworkStaticWebAssetCandidate Include="$(BlazorFrameworkStaticWebAssetRoot)\blazor.web.js" />
16+
<_FrameworkStaticWebAssetCandidate Include="$(BlazorFrameworkStaticWebAssetRoot)\blazor.server.js" />
17+
</ItemGroup>
18+
19+
<ItemGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' AND '$(UseBlazorFrameworkDebugAssets)' == 'true'">
20+
<_FrameworkStaticWebAssetCandidate Include="$(BlazorFrameworkStaticWebAssetRoot)\blazor.web.js.map" />
21+
<_FrameworkStaticWebAssetCandidate Include="$(BlazorFrameworkStaticWebAssetRoot)\blazor.server.js.map" />
22+
</ItemGroup>
23+
24+
<PropertyGroup>
25+
<_IncludeAssetsInBlazorWebAssemblyProject Condition="'$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true' AND '$(StaticWebAssetProjectMode)' != 'Default'">true</_IncludeAssetsInBlazorWebAssemblyProject>
26+
</PropertyGroup>
27+
28+
<ItemGroup Condition="'$(_IncludeAssetsInBlazorWebAssemblyProject)' == 'true'">
29+
<_FrameworkStaticWebAssetCandidate Include="$(BlazorFrameworkStaticWebAssetRoot)\blazor.webassembly.js" />
30+
</ItemGroup>
31+
32+
<ItemGroup Condition="'$(_IncludeAssetsInBlazorWebAssemblyProject)' == 'true' AND '$(UseBlazorFrameworkDebugAssets)' == 'true'">
33+
<_FrameworkStaticWebAssetCandidate Include="$(BlazorFrameworkStaticWebAssetRoot)\blazor.webassembly.js.map" />
34+
</ItemGroup>
35+
36+
<PropertyGroup>
37+
<_FrameworkAssetsPath>$(IntermediateOutputPath)frameworkassets</_FrameworkAssetsPath>
38+
</PropertyGroup>
39+
40+
<MakeDir
41+
Directories="$(_FrameworkAssetsPath)"
42+
Condition="!Exists('$(_FrameworkAssetsPath)')" />
43+
44+
<Copy
45+
SourceFiles="@(_FrameworkStaticWebAssetCandidate)"
46+
DestinationFolder="$(_FrameworkAssetsPath)"
47+
SkipUnchangedFiles="true">
48+
<Output TaskParameter="CopiedFiles" ItemName="_CopiedFrameworkStaticWebAssetCandidate" />
49+
</Copy>
50+
51+
<ItemGroup>
52+
<_CopiedFrameworkStaticWebAssetCandidate>
53+
<RelativePath>_framework\%(FileName)%(Extension)</RelativePath>
54+
<ContentRoot>$(_FrameworkAssetsPath)</ContentRoot>
55+
</_CopiedFrameworkStaticWebAssetCandidate>
56+
</ItemGroup>
57+
58+
<DefineStaticWebAssets
59+
Condition="'@(_CopiedFrameworkStaticWebAssetCandidate->Count())' != '0'"
60+
CandidateAssets="@(_CopiedFrameworkStaticWebAssetCandidate)"
61+
SourceId="$(PackageId)"
62+
SourceType="Discovered"
63+
AssetKind="All"
64+
AssetMode="All"
65+
AssetRole="Primary"
66+
FingerprintCandidates="true"
67+
BasePath="$(StaticWebAssetBasePath)">
68+
<Output TaskParameter="Assets" ItemName="_FrameworkStaticWebAsset" />
69+
</DefineStaticWebAssets>
70+
71+
<DefineStaticWebAssetEndpoints
72+
Condition="'@(_FrameworkStaticWebAsset)' != ''"
73+
CandidateAssets="@(_FrameworkStaticWebAsset)"
74+
ExistingEndpoints=""
75+
ContentTypeMappings="@(StaticWebAssetContentTypeMapping)">
76+
<Output TaskParameter="Endpoints" ItemName="_FrameworkStaticAssetEndpoint" />
77+
</DefineStaticWebAssetEndpoints>
78+
79+
<ItemGroup>
80+
<StaticWebAsset Include="@(_FrameworkStaticWebAsset)" />
81+
<StaticWebAssetEndpoint Include="@(_FrameworkStaticAssetEndpoint)" />
82+
</ItemGroup>
83+
</Target>
84+
85+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<Import Project="$(MSBuildThisFileDirectory)..\buildTransitive\Microsoft.AspNetCore.App.Internal.Assets.targets"/>
3+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<Import Project="$(MSBuildThisFileDirectory)..\build\Microsoft.AspNetCore.App.Internal.Assets.targets"/>
3+
</Project>

src/Components/Components.slnf

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"projects": [
55
"src\\Analyzers\\Microsoft.AspNetCore.Analyzer.Testing\\src\\Microsoft.AspNetCore.Analyzer.Testing.csproj",
66
"src\\Antiforgery\\src\\Microsoft.AspNetCore.Antiforgery.csproj",
7+
"src\\Assets\\Microsoft.AspNetCore.App.Internal.Assets.csproj",
78
"src\\Components\\Analyzers\\src\\Microsoft.AspNetCore.Components.Analyzers.csproj",
89
"src\\Components\\Analyzers\\test\\Microsoft.AspNetCore.Components.Analyzers.Tests.csproj",
910
"src\\Components\\Authorization\\src\\Microsoft.AspNetCore.Components.Authorization.csproj",
@@ -156,4 +157,4 @@
156157
"src\\WebEncoders\\src\\Microsoft.Extensions.WebEncoders.csproj"
157158
]
158159
}
159-
}
160+
}

src/Components/Directory.Build.props

+9
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,13 @@
1818
<AddSyntheticProjectReferencesForSolutionDependencies>false</AddSyntheticProjectReferencesForSolutionDependencies>
1919
</PropertyGroup>
2020

21+
<!-- Workaround to add Blazor framework static assets without requiring a package reference -->
22+
<PropertyGroup>
23+
<UseBlazorFrameworkDebugAssets>true</UseBlazorFrameworkDebugAssets>
24+
<BlazorFrameworkStaticWebAssetRoot Condition="'$(Configuration)' == 'Debug'">$(RepoRoot)src\Components\Web.JS\dist\Debug</BlazorFrameworkStaticWebAssetRoot>
25+
<BlazorFrameworkStaticWebAssetRoot Condition="'$(Configuration)' == 'Release'">$(RepoRoot)src\Components\Web.JS\dist\Release</BlazorFrameworkStaticWebAssetRoot>
26+
</PropertyGroup>
27+
28+
<Import Project="$(RepoRoot)\src\Assets\build\Microsoft.AspNetCore.App.Internal.Assets.targets" />
29+
2130
</Project>
-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
11
<Project>
2-
<PropertyGroup Condition="'$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true'">
3-
<BlazorWebAssemblyJSPath
4-
Condition=" '$(Configuration)' == 'Debug' ">$(RepoRoot)src\Components\Web.JS\dist\Debug\blazor.webassembly.js</BlazorWebAssemblyJSPath>
5-
<BlazorWebAssemblyJSPath
6-
Condition=" '$(Configuration)' != 'Debug' ">$(RepoRoot)src\Components\Web.JS\dist\Release\blazor.webassembly.js</BlazorWebAssemblyJSPath>
7-
<BlazorWebAssemblyJSMapPath>$(BlazorWebAssemblyJSPath).map</BlazorWebAssemblyJSMapPath>
8-
9-
<_BlazorDevServerPath>$(ArtifactsDir)bin/Microsoft.AspNetCore.Components.WebAssembly.DevServer/$(Configuration)/$(DefaultNetCoreTargetFramework)/blazor-devserver.dll</_BlazorDevServerPath>
10-
<RunCommand>dotnet</RunCommand>
11-
<_RunExtraArguments Condition="'$(WasmEnableThreads)' == 'true'">--apply-cop-headers</_RunExtraArguments>
12-
<RunArguments>exec &quot;$(_BlazorDevServerPath)&quot; --applicationpath &quot;$(TargetPath)&quot; $(_RunExtraArguments) $(AdditionalRunArguments)</RunArguments>
13-
</PropertyGroup>
14-
15-
<Target Name="_CheckBlazorWebAssemblyJSPath" AfterTargets="ResolveProjectReferences"
16-
Condition=" '$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true' AND !EXISTS('$(BlazorWebAssemblyJSPath)') ">
17-
<Error Text="'$(BlazorWebAssemblyJSPath)' does not exist. Enable NodeJS to build this project." />
18-
</Target>
19-
202
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.targets))\Directory.Build.targets" />
213
</Project>

src/Components/Endpoints/src/Builder/RazorComponentEndpointDataSource.cs

-54
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
using Microsoft.AspNetCore.Components.Endpoints.Infrastructure;
1111
using Microsoft.AspNetCore.Http;
1212
using Microsoft.AspNetCore.Routing;
13-
using Microsoft.AspNetCore.Routing.Patterns;
14-
using Microsoft.AspNetCore.StaticFiles;
15-
using Microsoft.Extensions.FileProviders;
1613
using Microsoft.Extensions.Primitives;
1714
using static Microsoft.AspNetCore.Internal.LinkerFlags;
1815

@@ -180,7 +177,6 @@ private void UpdateEndpoints()
180177
private void AddBlazorWebEndpoints(List<Endpoint> endpoints)
181178
{
182179
List<EndpointBuilder> blazorWebEndpoints = [
183-
..GetBlazorWebJsEndpoint(_endpointRouteBuilder),
184180
OpaqueRedirection.GetBlazorOpaqueRedirectionEndpoint()];
185181

186182
foreach (var endpoint in blazorWebEndpoints)
@@ -199,56 +195,6 @@ private void AddBlazorWebEndpoints(List<Endpoint> endpoints)
199195
}
200196
}
201197

202-
private static IEnumerable<EndpointBuilder> GetBlazorWebJsEndpoint(IEndpointRouteBuilder endpoints)
203-
{
204-
var app = endpoints.CreateApplicationBuilder();
205-
206-
var options = new StaticFileOptions
207-
{
208-
FileProvider = new ManifestEmbeddedFileProvider(typeof(RazorComponentsEndpointRouteBuilderExtensions).Assembly),
209-
OnPrepareResponse = CacheHeaderSettings.SetCacheHeaders
210-
};
211-
212-
app.Use(next => context =>
213-
{
214-
// Set endpoint to null so the static files middleware will handle the request.
215-
context.SetEndpoint(null);
216-
217-
return next(context);
218-
});
219-
220-
app.UseStaticFiles(options);
221-
222-
var requestDelegate = app.Build();
223-
224-
var blazorWebJsBuilder = new RouteEndpointBuilder(
225-
requestDelegate,
226-
RoutePatternFactory.Parse("/_framework/blazor.web.js"),
227-
int.MinValue)
228-
{
229-
DisplayName = "Blazor web static files"
230-
};
231-
232-
var allowedHttpMethods = new HttpMethodMetadata([HttpMethods.Get, HttpMethods.Head]);
233-
blazorWebJsBuilder.Metadata.Add(allowedHttpMethods);
234-
235-
#if !DEBUG
236-
return [blazorWebJsBuilder];
237-
#else
238-
// We only need to serve the sourcemap when working on the framework, not in the distributed packages
239-
var blazorWebJsDebugBuilder = new RouteEndpointBuilder(
240-
requestDelegate,
241-
RoutePatternFactory.Parse("/_framework/blazor.web.js.map"),
242-
int.MinValue)
243-
{
244-
DisplayName = "Blazor web static files sourcemap"
245-
};
246-
blazorWebJsDebugBuilder.Metadata.Add(allowedHttpMethods);
247-
248-
return [blazorWebJsBuilder, blazorWebJsDebugBuilder];
249-
#endif
250-
}
251-
252198
public void OnHotReloadClearCache(Type[]? types)
253199
{
254200
lock (_lock)
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
<Project>
22
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.targets))\Directory.Build.targets" />
3-
<!-- Workaround target import for project references to Microsoft.Extensions.FileProviders.Embedded -->
4-
<Import
5-
Project="$(RepoRoot)src\FileProviders\Embedded\src\build\netstandard2.0\Microsoft.Extensions.FileProviders.Embedded.targets" />
63
</Project>

0 commit comments

Comments
 (0)