[Fixes #12588][Blazor] Move Blazor to use Static Web Assets (#18409)

* [Blazor] Move Blazor to use Static Web Assets
* Plugs-in Blazor wasm through the static web assets infrastructure.
* Avoids the need for a custom Blazor.config file.
* Removes broken auto-rebuild and debug support.
* Removes unnecessary server-side Blazor helpers.
This commit is contained in:
Javier Calvarro Nelson 2020-02-19 04:05:03 -08:00 committed by GitHub
parent 92409e2e57
commit 0e155fd7ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 476 additions and 778 deletions

View File

@ -214,9 +214,9 @@ stages:
- bash: "./eng/scripts/install-nginx-mac.sh"
displayName: Installing Nginx
afterBuild:
- bash: ./build.sh --ci --pack --no-build --no-restore --no-build-deps "/bl:artifacts/log/packages.pack.binlog"
- bash: ./build.sh --ci --pack --no-restore "/bl:artifacts/log/packages.pack.binlog"
displayName: Pack Packages (for Template tests)
- bash: ./src/ProjectTemplates/build.sh --ci --pack --no-restore --no-build-deps "/bl:artifacts/log/template.pack.binlog"
- bash: ./src/ProjectTemplates/build.sh --ci --pack --no-restore "/bl:artifacts/log/template.pack.binlog"
displayName: Pack Templates (for Template tests)
- bash: ./build.sh --no-build --ci --test -p:RunFlakyTests=true
displayName: Run Flaky Tests
@ -251,9 +251,9 @@ stages:
- bash: "echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p"
displayName: Increase inotify limit
afterBuild:
- bash: ./build.sh --ci --pack --no-build --no-restore --no-build-deps "/bl:artifacts/log/packages.pack.binlog"
- bash: ./build.sh --ci --pack --no-restore "/bl:artifacts/log/packages.pack.binlog"
displayName: Pack Packages (for Template tests)
- bash: ./src/ProjectTemplates/build.sh --ci --pack --no-restore --no-build-deps "/bl:artifacts/log/template.pack.binlog"
- bash: ./src/ProjectTemplates/build.sh --ci --pack --no-restore "/bl:artifacts/log/template.pack.binlog"
displayName: Pack Templates (for Template tests)
- bash: ./build.sh --no-build --ci --test -p:RunFlakyTests=true
displayName: Run Flaky Tests

View File

@ -89,15 +89,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Components.TestServer", "te
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebAssembly.Authentication", "WebAssembly.Authentication", "{C4D74173-702B-428A-B689-1A9AF51CE356}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.WebAssembly.Authentication", "Blazor\WebAssembly.Authentication\src\Microsoft.AspNetCore.Components.WebAssembly.Authentication.csproj", "{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.WebAssembly.Authentication", "WebAssembly\WebAssembly.Authentication\src\Microsoft.AspNetCore.Components.WebAssembly.Authentication.csproj", "{B3EF0C88-3466-40AE-9080-F694370F4192}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.WebAssembly.Authentication.Tests", "Blazor\WebAssembly.Authentication\test\Microsoft.AspNetCore.Components.WebAssembly.Authentication.Tests.csproj", "{E450CCAC-6E03-4306-9919-47AB0EE98657}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.WebAssembly.Authentication.Tests", "WebAssembly\WebAssembly.Authentication\test\Microsoft.AspNetCore.Components.WebAssembly.Authentication.Tests.csproj", "{2916EC17-1D1F-4949-9EC7-50725157F1A6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wasm.Authentication.Server", "Blazor\testassets\Wasm.Authentication.Server\Wasm.Authentication.Server.csproj", "{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wasm.Authentication.Client", "WebAssembly\testassets\Wasm.Authentication.Client\Wasm.Authentication.Client.csproj", "{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wasm.Authentication.Client", "Blazor\testassets\Wasm.Authentication.Client\Wasm.Authentication.Client.csproj", "{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wasm.Authentication.Server", "WebAssembly\testassets\Wasm.Authentication.Server\Wasm.Authentication.Server.csproj", "{194EBC45-F98E-4919-B714-C1624EF17B31}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wasm.Authentication.Shared", "Blazor\testassets\Wasm.Authentication.Shared\Wasm.Authentication.Shared.csproj", "{A82A1C13-C452-423A-9287-A7E52F6A43E8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wasm.Authentication.Shared", "WebAssembly\testassets\Wasm.Authentication.Shared\Wasm.Authentication.Shared.csproj", "{EAF50654-98ED-44BB-A120-0436EC0CD3E0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -445,66 +445,66 @@ Global
{EACC194A-8C1B-424D-B8FE-330E14CAF525}.Release|x64.Build.0 = Release|Any CPU
{EACC194A-8C1B-424D-B8FE-330E14CAF525}.Release|x86.ActiveCfg = Release|Any CPU
{EACC194A-8C1B-424D-B8FE-330E14CAF525}.Release|x86.Build.0 = Release|Any CPU
{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE}.Debug|x64.ActiveCfg = Debug|Any CPU
{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE}.Debug|x64.Build.0 = Debug|Any CPU
{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE}.Debug|x86.ActiveCfg = Debug|Any CPU
{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE}.Debug|x86.Build.0 = Debug|Any CPU
{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE}.Release|Any CPU.Build.0 = Release|Any CPU
{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE}.Release|x64.ActiveCfg = Release|Any CPU
{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE}.Release|x64.Build.0 = Release|Any CPU
{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE}.Release|x86.ActiveCfg = Release|Any CPU
{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE}.Release|x86.Build.0 = Release|Any CPU
{E450CCAC-6E03-4306-9919-47AB0EE98657}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E450CCAC-6E03-4306-9919-47AB0EE98657}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E450CCAC-6E03-4306-9919-47AB0EE98657}.Debug|x64.ActiveCfg = Debug|Any CPU
{E450CCAC-6E03-4306-9919-47AB0EE98657}.Debug|x64.Build.0 = Debug|Any CPU
{E450CCAC-6E03-4306-9919-47AB0EE98657}.Debug|x86.ActiveCfg = Debug|Any CPU
{E450CCAC-6E03-4306-9919-47AB0EE98657}.Debug|x86.Build.0 = Debug|Any CPU
{E450CCAC-6E03-4306-9919-47AB0EE98657}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E450CCAC-6E03-4306-9919-47AB0EE98657}.Release|Any CPU.Build.0 = Release|Any CPU
{E450CCAC-6E03-4306-9919-47AB0EE98657}.Release|x64.ActiveCfg = Release|Any CPU
{E450CCAC-6E03-4306-9919-47AB0EE98657}.Release|x64.Build.0 = Release|Any CPU
{E450CCAC-6E03-4306-9919-47AB0EE98657}.Release|x86.ActiveCfg = Release|Any CPU
{E450CCAC-6E03-4306-9919-47AB0EE98657}.Release|x86.Build.0 = Release|Any CPU
{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB}.Debug|x64.ActiveCfg = Debug|Any CPU
{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB}.Debug|x64.Build.0 = Debug|Any CPU
{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB}.Debug|x86.ActiveCfg = Debug|Any CPU
{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB}.Debug|x86.Build.0 = Debug|Any CPU
{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB}.Release|Any CPU.Build.0 = Release|Any CPU
{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB}.Release|x64.ActiveCfg = Release|Any CPU
{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB}.Release|x64.Build.0 = Release|Any CPU
{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB}.Release|x86.ActiveCfg = Release|Any CPU
{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB}.Release|x86.Build.0 = Release|Any CPU
{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8}.Debug|x64.ActiveCfg = Debug|Any CPU
{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8}.Debug|x64.Build.0 = Debug|Any CPU
{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8}.Debug|x86.ActiveCfg = Debug|Any CPU
{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8}.Debug|x86.Build.0 = Debug|Any CPU
{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8}.Release|Any CPU.Build.0 = Release|Any CPU
{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8}.Release|x64.ActiveCfg = Release|Any CPU
{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8}.Release|x64.Build.0 = Release|Any CPU
{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8}.Release|x86.ActiveCfg = Release|Any CPU
{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8}.Release|x86.Build.0 = Release|Any CPU
{A82A1C13-C452-423A-9287-A7E52F6A43E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A82A1C13-C452-423A-9287-A7E52F6A43E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A82A1C13-C452-423A-9287-A7E52F6A43E8}.Debug|x64.ActiveCfg = Debug|Any CPU
{A82A1C13-C452-423A-9287-A7E52F6A43E8}.Debug|x64.Build.0 = Debug|Any CPU
{A82A1C13-C452-423A-9287-A7E52F6A43E8}.Debug|x86.ActiveCfg = Debug|Any CPU
{A82A1C13-C452-423A-9287-A7E52F6A43E8}.Debug|x86.Build.0 = Debug|Any CPU
{A82A1C13-C452-423A-9287-A7E52F6A43E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A82A1C13-C452-423A-9287-A7E52F6A43E8}.Release|Any CPU.Build.0 = Release|Any CPU
{A82A1C13-C452-423A-9287-A7E52F6A43E8}.Release|x64.ActiveCfg = Release|Any CPU
{A82A1C13-C452-423A-9287-A7E52F6A43E8}.Release|x64.Build.0 = Release|Any CPU
{A82A1C13-C452-423A-9287-A7E52F6A43E8}.Release|x86.ActiveCfg = Release|Any CPU
{A82A1C13-C452-423A-9287-A7E52F6A43E8}.Release|x86.Build.0 = Release|Any CPU
{B3EF0C88-3466-40AE-9080-F694370F4192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3EF0C88-3466-40AE-9080-F694370F4192}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3EF0C88-3466-40AE-9080-F694370F4192}.Debug|x64.ActiveCfg = Debug|Any CPU
{B3EF0C88-3466-40AE-9080-F694370F4192}.Debug|x64.Build.0 = Debug|Any CPU
{B3EF0C88-3466-40AE-9080-F694370F4192}.Debug|x86.ActiveCfg = Debug|Any CPU
{B3EF0C88-3466-40AE-9080-F694370F4192}.Debug|x86.Build.0 = Debug|Any CPU
{B3EF0C88-3466-40AE-9080-F694370F4192}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3EF0C88-3466-40AE-9080-F694370F4192}.Release|Any CPU.Build.0 = Release|Any CPU
{B3EF0C88-3466-40AE-9080-F694370F4192}.Release|x64.ActiveCfg = Release|Any CPU
{B3EF0C88-3466-40AE-9080-F694370F4192}.Release|x64.Build.0 = Release|Any CPU
{B3EF0C88-3466-40AE-9080-F694370F4192}.Release|x86.ActiveCfg = Release|Any CPU
{B3EF0C88-3466-40AE-9080-F694370F4192}.Release|x86.Build.0 = Release|Any CPU
{2916EC17-1D1F-4949-9EC7-50725157F1A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2916EC17-1D1F-4949-9EC7-50725157F1A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2916EC17-1D1F-4949-9EC7-50725157F1A6}.Debug|x64.ActiveCfg = Debug|Any CPU
{2916EC17-1D1F-4949-9EC7-50725157F1A6}.Debug|x64.Build.0 = Debug|Any CPU
{2916EC17-1D1F-4949-9EC7-50725157F1A6}.Debug|x86.ActiveCfg = Debug|Any CPU
{2916EC17-1D1F-4949-9EC7-50725157F1A6}.Debug|x86.Build.0 = Debug|Any CPU
{2916EC17-1D1F-4949-9EC7-50725157F1A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2916EC17-1D1F-4949-9EC7-50725157F1A6}.Release|Any CPU.Build.0 = Release|Any CPU
{2916EC17-1D1F-4949-9EC7-50725157F1A6}.Release|x64.ActiveCfg = Release|Any CPU
{2916EC17-1D1F-4949-9EC7-50725157F1A6}.Release|x64.Build.0 = Release|Any CPU
{2916EC17-1D1F-4949-9EC7-50725157F1A6}.Release|x86.ActiveCfg = Release|Any CPU
{2916EC17-1D1F-4949-9EC7-50725157F1A6}.Release|x86.Build.0 = Release|Any CPU
{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6}.Debug|x64.ActiveCfg = Debug|Any CPU
{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6}.Debug|x64.Build.0 = Debug|Any CPU
{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6}.Debug|x86.ActiveCfg = Debug|Any CPU
{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6}.Debug|x86.Build.0 = Debug|Any CPU
{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6}.Release|Any CPU.Build.0 = Release|Any CPU
{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6}.Release|x64.ActiveCfg = Release|Any CPU
{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6}.Release|x64.Build.0 = Release|Any CPU
{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6}.Release|x86.ActiveCfg = Release|Any CPU
{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6}.Release|x86.Build.0 = Release|Any CPU
{194EBC45-F98E-4919-B714-C1624EF17B31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{194EBC45-F98E-4919-B714-C1624EF17B31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{194EBC45-F98E-4919-B714-C1624EF17B31}.Debug|x64.ActiveCfg = Debug|Any CPU
{194EBC45-F98E-4919-B714-C1624EF17B31}.Debug|x64.Build.0 = Debug|Any CPU
{194EBC45-F98E-4919-B714-C1624EF17B31}.Debug|x86.ActiveCfg = Debug|Any CPU
{194EBC45-F98E-4919-B714-C1624EF17B31}.Debug|x86.Build.0 = Debug|Any CPU
{194EBC45-F98E-4919-B714-C1624EF17B31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{194EBC45-F98E-4919-B714-C1624EF17B31}.Release|Any CPU.Build.0 = Release|Any CPU
{194EBC45-F98E-4919-B714-C1624EF17B31}.Release|x64.ActiveCfg = Release|Any CPU
{194EBC45-F98E-4919-B714-C1624EF17B31}.Release|x64.Build.0 = Release|Any CPU
{194EBC45-F98E-4919-B714-C1624EF17B31}.Release|x86.ActiveCfg = Release|Any CPU
{194EBC45-F98E-4919-B714-C1624EF17B31}.Release|x86.Build.0 = Release|Any CPU
{EAF50654-98ED-44BB-A120-0436EC0CD3E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EAF50654-98ED-44BB-A120-0436EC0CD3E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EAF50654-98ED-44BB-A120-0436EC0CD3E0}.Debug|x64.ActiveCfg = Debug|Any CPU
{EAF50654-98ED-44BB-A120-0436EC0CD3E0}.Debug|x64.Build.0 = Debug|Any CPU
{EAF50654-98ED-44BB-A120-0436EC0CD3E0}.Debug|x86.ActiveCfg = Debug|Any CPU
{EAF50654-98ED-44BB-A120-0436EC0CD3E0}.Debug|x86.Build.0 = Debug|Any CPU
{EAF50654-98ED-44BB-A120-0436EC0CD3E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EAF50654-98ED-44BB-A120-0436EC0CD3E0}.Release|Any CPU.Build.0 = Release|Any CPU
{EAF50654-98ED-44BB-A120-0436EC0CD3E0}.Release|x64.ActiveCfg = Release|Any CPU
{EAF50654-98ED-44BB-A120-0436EC0CD3E0}.Release|x64.Build.0 = Release|Any CPU
{EAF50654-98ED-44BB-A120-0436EC0CD3E0}.Release|x86.ActiveCfg = Release|Any CPU
{EAF50654-98ED-44BB-A120-0436EC0CD3E0}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -550,11 +550,11 @@ Global
{BC3DDF14-4961-49AB-8F19-2A23F535B0DE} = {10C06583-8506-42DE-863E-EAD48A1F7579}
{EACC194A-8C1B-424D-B8FE-330E14CAF525} = {10C06583-8506-42DE-863E-EAD48A1F7579}
{C4D74173-702B-428A-B689-1A9AF51CE356} = {B29FB58D-FAE5-405E-9695-BCF93582BE9A}
{E5C5D4E9-2442-4C4C-94E7-1EDB8ADAD1FE} = {C4D74173-702B-428A-B689-1A9AF51CE356}
{E450CCAC-6E03-4306-9919-47AB0EE98657} = {C4D74173-702B-428A-B689-1A9AF51CE356}
{B88282F3-1DEF-4B06-8AD6-5A9EF6BAFEEB} = {CBD2BB24-3EC3-4950-ABE4-8C521D258DCD}
{7EF0A33A-3E96-4DF5-973C-257CFE6F79D8} = {CBD2BB24-3EC3-4950-ABE4-8C521D258DCD}
{A82A1C13-C452-423A-9287-A7E52F6A43E8} = {CBD2BB24-3EC3-4950-ABE4-8C521D258DCD}
{B3EF0C88-3466-40AE-9080-F694370F4192} = {C4D74173-702B-428A-B689-1A9AF51CE356}
{2916EC17-1D1F-4949-9EC7-50725157F1A6} = {C4D74173-702B-428A-B689-1A9AF51CE356}
{7EFB9CAF-6716-43BF-A6EF-C2878E95F8A6} = {B4ACD900-27B6-482B-B434-2C1E86E9D8BC}
{194EBC45-F98E-4919-B714-C1624EF17B31} = {B4ACD900-27B6-482B-B434-2C1E86E9D8BC}
{EAF50654-98ED-44BB-A120-0436EC0CD3E0} = {B4ACD900-27B6-482B-B434-2C1E86E9D8BC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {27A36094-AA50-4FFD-ADE6-C055E391F741}

View File

@ -1,8 +1,12 @@
<Project>
<Import Project="Blazor.MonoRuntime.props" />
<Import Project="StaticWebAssets.props" />
<PropertyGroup>
<DefaultWebContentItemExcludes>$(DefaultWebContentItemExcludes);wwwroot\**</DefaultWebContentItemExcludes>
<!-- Assets for a Blazor app are exposed on the root folder by default. -->
<StaticWebAssetBasePath>/</StaticWebAssetBasePath>
<!-- When using IISExpress with a standalone app, there's no point restarting IISExpress after build. It slows things unnecessarily and breaks in-flight HTTP requests. -->
<NoRestartServerOnBuild>true</NoRestartServerOnBuild>

View File

@ -23,28 +23,4 @@
<Import Project="StaticWebAssets.targets" />
<Import Project="ServiceWorkerAssetsManifest.targets" />
<Target Name="GenerateBlazorMetadataFile"
BeforeTargets="GetCopyToOutputDirectoryItems">
<PropertyGroup>
<BlazorMetadataFileName>$(AssemblyName).blazor.config</BlazorMetadataFileName>
<BlazorMetadataFilePath>$(TargetDir)$(BlazorMetadataFileName)</BlazorMetadataFilePath>
</PropertyGroup>
<ItemGroup>
<_BlazorConfigContent Include="$(MSBuildProjectFullPath)" />
<_BlazorConfigContent Include="$(TargetPath)" />
<_BlazorConfigContent Include="debug:true" Condition="'$(BlazorEnableDebugging)'=='true'" />
</ItemGroup>
<WriteLinesToFile
File="$(BlazorMetadataFilePath)"
Lines="@(_BlazorConfigContent)"
Overwrite="true"
WriteOnlyWhenDifferent="True" />
<ItemGroup>
<ContentWithTargetPath Include="$(BlazorMetadataFilePath)" TargetPath="$(BlazorMetadataFileName)" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Target>
</Project>

View File

@ -19,36 +19,6 @@
<DotNetWebAssemblyFrameworkPath>$(DotNetWebAssemblyArtifactsRoot)\framework\</DotNetWebAssemblyFrameworkPath>
</PropertyGroup>
<Target
Name="_BlazorCopyFilesToOutputDirectory"
DependsOnTargets="PrepareBlazorOutputs;$(_BlazorCopyFilesToOutputDirectoryDependsOn)"
AfterTargets="CopyFilesToOutputDirectory"
Condition="'$(OutputType.ToLowerInvariant())'=='exe'">
<!-- Copy the blazor output files -->
<Copy
SourceFiles="@(BlazorOutputWithTargetPath)"
DestinationFiles="@(BlazorOutputWithTargetPath->'$(TargetDir)%(TargetOutputPath)')"
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)"
Condition="'@(BlazorOutputWithTargetPath)' != '' and '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true'">
</Copy>
<ItemGroup>
<FileWrites Include="@(BlazorOutputWithTargetPath->'$(TargetDir)%(TargetOutputPath)')" />
</ItemGroup>
<ItemGroup>
<_BlazorStatisticsOutput Include="@(BlazorOutputWithTargetPath->'%(TargetOutputPath)')" />
</ItemGroup>
<Message Importance="high" Text="$(TargetName) (Blazor output) -> $(TargetDir)dist" />
</Target>
<Target
Name="PrepareBlazorOutputs"
DependsOnTargets="_ResolveBlazorInputs;_ResolveBlazorOutputs;_GenerateBlazorBootJson">
@ -131,7 +101,7 @@
<BlazorRuntimeFile>true</BlazorRuntimeFile>
<TargetOutputPath>$(BlazorRuntimeBinOutputPath)%(FileName)%(Extension)</TargetOutputPath>
<RelativeOutputPath>%(FileName)%(Extension)</RelativeOutputPath>
</BlazorOutputWithTargetPath>
</BlazorOutputWithTargetPath>
</ItemGroup>
<!--

View File

@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<BlazorLinkOnBuild Condition="'$(BlazorLinkOnBuild)'==''">true</BlazorLinkOnBuild>
<BlazorPublishDistDir>$(AssemblyName)\dist\</BlazorPublishDistDir>
<!-- Disable unwanted parts of the default publish process -->
<CopyBuildOutputToPublishDirectory>false</CopyBuildOutputToPublishDirectory>
@ -10,61 +10,7 @@
<RazorCompileOnPublish>false</RazorCompileOnPublish>
<GenerateDependencyFile>false</GenerateDependencyFile>
<IsWebConfigTransformDisabled>true</IsWebConfigTransformDisabled>
</PropertyGroup>
<Target Name="BlazorGetCopyToPublishDirectoryItems"
BeforeTargets="GetCopyToPublishDirectoryItems"
DependsOnTargets="PrepareBlazorOutputs"
Condition="'$(OutputType.ToLowerInvariant())'=='exe'">
<ItemGroup>
<!-- Don't want to publish the assemblies from the regular 'bin' dir. Instead we publish ones from 'dist'. -->
<ResolvedAssembliesToPublish Remove="@(ResolvedAssembliesToPublish)" />
<!-- Move wwwroot files to output root -->
<ContentWithTargetPath Update="@(ContentWithTargetPath)" Condition="$([System.String]::new(%(TargetPath)).StartsWith('wwwroot\')) OR $([System.String]::new(%(TargetPath)).StartsWith('wwwroot/'))">
<TargetPath>$(BlazorPublishDistDir)$([System.String]::new(%(TargetPath)).Substring(8))</TargetPath>
</ContentWithTargetPath>
<!-- Publish all the 'dist' files -->
<_BlazorGCTPDI Include="%(BlazorOutputWithTargetPath.Identity)">
<TargetPath>$(AssemblyName)\%(TargetOutputPath)</TargetPath>
</_BlazorGCTPDI>
<ContentWithTargetPath Include="@(_BlazorGCTPDI)">
<TargetPath>%(TargetPath)</TargetPath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ContentWithTargetPath>
</ItemGroup>
<!-- Replace the .blazor.config contents with what we need to serve in production -->
<PropertyGroup>
<_BlazorConfigPath>$(OutDir)$(AssemblyName).blazor.config</_BlazorConfigPath>
</PropertyGroup>
<ItemGroup>
<_BlazorPublishConfigContent Include="." />
<_BlazorPublishConfigContent Include="$(AssemblyName)/" />
</ItemGroup>
<WriteLinesToFile
File="$(_BlazorConfigPath)"
Lines="@(_BlazorPublishConfigContent)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
</Target>
<!-- The following target runs only for standalone publishing -->
<Target Name="BlazorCompleteStandalonePublish" AfterTargets="CopyFilesToPublishDirectory">
<!-- Add a suitable web.config file if there isn't one already -->
<ItemGroup>
<_StandaloneWebConfigContent Include="$([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)Standalone.Web.config'))"/>
</ItemGroup>
<WriteLinesToFile
Condition="!Exists('$(PublishDir)web.config')"
File="$(PublishDir)web.config"
Lines="@(_StandaloneWebConfigContent->Replace('[ServeSubdirectory]','$(BlazorPublishDistDir)'))" />
<!-- Remove the .blazor.config file, since it's irrelevant for standalone publishing -->
<Delete Files="$(PublishDir)$(AssemblyName).blazor.config" />
</Target>
</Project>

View File

@ -1,44 +1,17 @@
<Project>
<PropertyGroup>
<_BlazorCopyFilesToOutputDirectoryDependsOn>
$(_BlazorCopyFilesToOutputDirectoryDependsOn);
_ComputeServiceWorkerAssetsManifestInputs;
_WriteServiceWorkerAssetsManifest;
</_BlazorCopyFilesToOutputDirectoryDependsOn>
</PropertyGroup>
<Target Name="_ComputeServiceWorkerAssetsManifestInputs"
Condition="'$(ServiceWorkerAssetsManifest)' != ''"
DependsOnTargets="PrepareBlazorOutputs">
BeforeTargets="_ResolveBlazorOutputs">
<PropertyGroup>
<_ServiceWorkerAssetsManifestIntermediateOutputPath>$(BlazorIntermediateOutputPath)serviceworkerassets.js</_ServiceWorkerAssetsManifestIntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<!-- Include _framework/* content -->
<ServiceWorkerAssetsManifestItem
Include="@(BlazorOutputWithTargetPath)"
Condition="$([System.String]::Copy('%(BlazorOutputWithTargetPath.TargetOutputPath)').Replace('\','/').StartsWith('dist/'))">
<AssetUrl>$([System.String]::Copy('%(BlazorOutputWithTargetPath.TargetOutputPath)').Replace('\','/').Substring(5))</AssetUrl>
</ServiceWorkerAssetsManifestItem>
<!-- Include content from wwwroot -->
<ServiceWorkerAssetsManifestItem
Include="@(ContentWithTargetPath)"
Condition="
('%(ContentWithTargetPath.CopyToPublishDirectory)' == 'Always' OR '%(ContentWithTargetPath.CopyToPublishDirectory)' == 'PreserveNewest')
AND $([System.String]::Copy('%(ContentWithTargetPath.TargetPath)').Replace('\','/').StartsWith('wwwroot/'))">
<AssetUrl>$([System.String]::Copy('%(ContentWithTargetPath.TargetPath)').Replace('\','/').Substring(8))</AssetUrl>
</ServiceWorkerAssetsManifestItem>
<!-- Include SWA from references -->
<ServiceWorkerAssetsManifestItem
Include="@(StaticWebAsset)"
Condition="'%(StaticWebAsset.SourceType)' != ''">
<AssetUrl>%(StaticWebAsset.BasePath)/%(StaticWebAsset.RelativePath)</AssetUrl>
</ServiceWorkerAssetsManifestItem>
<BlazorOutputWithTargetPath Condition="'$(ServiceWorkerAssetsManifest)' != ''"
Include="$(_ServiceWorkerAssetsManifestIntermediateOutputPath)"
TargetOutputPath="$(BaseBlazorDistPath)$(ServiceWorkerAssetsManifest)" />
</ItemGroup>
</Target>
@ -48,6 +21,7 @@
<Target Name="_WriteServiceWorkerAssetsManifest"
Inputs="@(ServiceWorkerAssetsManifestItem)"
Outputs="$(_ServiceWorkerAssetsManifestIntermediateOutputPath)"
BeforeTargets="_BlazorStaticWebAssetsCopyGeneratedFilesToOutputDirectory"
DependsOnTargets="_ComputeServiceWorkerAssetsManifestFileHashes; _ComputeDefaultServiceWorkerAssetsManifestVersion">
<GenerateServiceWorkerAssetsManifest
@ -56,16 +30,19 @@
OutputPath="$(_ServiceWorkerAssetsManifestIntermediateOutputPath)" />
<ItemGroup>
<BlazorOutputWithTargetPath
Include="$(_ServiceWorkerAssetsManifestIntermediateOutputPath)"
TargetOutputPath="$(BaseBlazorDistPath)$(ServiceWorkerAssetsManifest)" />
<FileWrites Include="$(_ServiceWorkerAssetsManifestIntermediateOutputPath)" />
</ItemGroup>
</Target>
<Target Name="_ComputeServiceWorkerAssetsManifestFileHashes">
<ItemGroup>
<ServiceWorkerAssetsManifestItem Include="%(StaticWebAsset.Identity)" Condition="'%(RelativePath)' != '$(ServiceWorkerAssetsManifest)'">
<AssetUrl>$([System.String]::Copy('$([System.String]::Copy('%(StaticWebAsset.BasePath)').TrimEnd('/'))/%(StaticWebAsset.RelativePath)').Replace('\','/').TrimStart('/'))</AssetUrl>
</ServiceWorkerAssetsManifestItem>
</ItemGroup>
<GetFileHash Files="@(ServiceWorkerAssetsManifestItem)" Algorithm="SHA256" HashEncoding="base64">
<Output TaskParameter="Items" ItemName="_ServiceWorkerAssetsManifestItemWithHash" />
</GetFileHash>
@ -94,5 +71,5 @@
<ServiceWorkerAssetsManifestVersion>$([System.String]::Copy('%(_ServiceWorkerAssetsManifestCombinedHash.FileHash)').Substring(0, 8))</ServiceWorkerAssetsManifestVersion>
</PropertyGroup>
</Target>
</Project>

View File

@ -11,7 +11,7 @@
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".wasm" mimeType="application/wasm" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
</staticContent>
<httpCompression>
<dynamicTypes>
@ -23,14 +23,14 @@
<rules>
<rule name="Serve subdir">
<match url=".*" />
<action type="Rewrite" url="[ServeSubdirectory]{R:0}" />
<action type="Rewrite" url="wwwroot\{R:0}" />
</rule>
<rule name="SPA fallback routing" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="[ServeSubdirectory]" />
<action type="Rewrite" url="wwwroot\" />
</rule>
</rules>
</rewrite>

View File

@ -0,0 +1,15 @@
<Project>
<PropertyGroup>
<ResolveStaticWebAssetsInputsDependsOn>
$(ResolveStaticWebAssetsInputsDependsOn);
_BlazorApplyLinkPreferencesToStaticWebAssets;
_ResolveBlazorGeneratedAssets;
</ResolveStaticWebAssetsInputsDependsOn>
<GetCurrentProjectStaticWebAssetsDependsOn>
$(GetCurrentProjectStaticWebAssetsDependsOn);
_BlazorApplyLinkPreferencesToStaticWebAssets;
_ResolveBlazorGeneratedAssets;
</GetCurrentProjectStaticWebAssetsDependsOn>
</PropertyGroup>
</Project>

View File

@ -1,37 +1,161 @@
<Project>
<PropertyGroup>
<ResolveStaticWebAssetsInputsDependsOn>
$(ResolveStaticWebAssetsInputsDependsOn);
_RemoveBlazorCurrentProjectAssetsFromStaticWebAssets;
</ResolveStaticWebAssetsInputsDependsOn>
<GetCurrentProjectStaticWebAssetsDependsOn>
$(GetCurrentProjectStaticWebAssetsDependsOn);
_RemoveBlazorCurrentProjectAssetsFromStaticWebAssets;
</GetCurrentProjectStaticWebAssetsDependsOn>
</PropertyGroup>
<Target Name="_RemoveBlazorCurrentProjectAssetsFromStaticWebAssets">
<Target Name="_ResolveBlazorGeneratedAssets" DependsOnTargets="PrepareBlazorOutputs">
<ItemGroup>
<StaticWebAsset Remove="@(StaticWebAsset)" Condition="'%(SourceType)' == ''" />
<StaticWebAsset Include="@(BlazorOutputWithTargetPath->'%(FullPath)')" RemoveMetadata="TargetOutputPath">
<SourceType></SourceType>
<SourceId>$(PackageId)</SourceId>
<ContentRoot>$([MSBuild]::NormalizeDirectory('$(TargetDir)wwwroot\'))</ContentRoot>
<BasePath>$(StaticWebAssetBasePath)</BasePath>
<RelativePath>$([System.String]::Copy('%(BlazorOutputWithTargetPath.TargetOutputPath)').Replace('\','/').Replace('dist/',''))</RelativePath>
</StaticWebAsset>
<StaticWebAsset Remove="@(StaticWebAsset)" Condition="'$(BlazorEnableDebugging)' != 'true' and '%(SourceType)' == '' and '%(Extension)' == '.pdb'" />
<!-- We are dependingo on a "private" property for static web assets, but this is something we can clean-up in a later release.
These files are not "external" in the "traditional" sense but it is fine for now as this is an implementation detail.
We only need to do this for the standalone case, for hosted scenarios this works just fine as the assets are considered
external. -->
<_ExternalStaticWebAsset Include="@(BlazorOutputWithTargetPath->'%(FullPath)')">
<SourceId>$(PackageId)</SourceId>
<!-- We just do this to keep the existing implementation happy. We will update this in the next release. -->
<SourceType>Generated</SourceType>
<ContentRoot>$([MSBuild]::NormalizeDirectory('$(TargetDir)wwwroot\'))</ContentRoot>
<BasePath>$(StaticWebAssetBasePath)</BasePath>
</_ExternalStaticWebAsset>
<!-- These items we are adding for forward-compatibility with newer SDK versions. The paths listed here will be added unconditionally
to the generated static web assets manifest. This is only needed for forward compatibility in Blazor standalone scenarios. -->
<StaticWebAssetsManifestPath Include="$([MSBuild]::NormalizeDirectory('$(TargetDir)wwwroot\'))">
<SourceId>$(PackageId)</SourceId>
<BasePath>$(StaticWebAssetBasePath)</BasePath>
</StaticWebAssetsManifestPath>
</ItemGroup>
</Target>
<Target Name="BlazorStaticWebAssetsComputeFilesToPublish"
<Target Name="_BlazorStaticWebAssetsCopyGeneratedFilesToOutputDirectory"
DependsOnTargets="ResolveStaticWebAssetsInputs;$(_BlazorCopyFilesToOutputDirectoryDependsOn)"
AfterTargets="CopyFilesToOutputDirectory"
Condition="'$(OutputType.ToLowerInvariant())'=='exe'">
<PropertyGroup>
<_BlazorCurrentProjectWWWroot>$([MSBuild]::NormalizeDirectory('$(MSBuildProjectDirectory)\wwwroot\'))</_BlazorCurrentProjectWWWroot>
</PropertyGroup>
<ItemGroup>
<_BlazorCopyLocalAssets Include="@(StaticWebAsset)" Condition="'%(SourceType)' == '' and '%(ContentRoot)' != '$(_BlazorCurrentProjectWWWroot)'" />
</ItemGroup>
<!-- Copy the blazor output files -->
<Copy
SourceFiles="@(_BlazorCopyLocalAssets)"
DestinationFiles="@(_BlazorCopyLocalAssets->'%(ContentRoot)%(RelativePath)')"
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)"
Condition="'@(_BlazorCopyLocalAssets)' != '' and '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true'">
</Copy>
<ItemGroup>
<FileWrites Include="@(_BlazorCopyLocalAssets->'%(ContentRoot)%(RelativePath)')" />
</ItemGroup>
<ItemGroup>
<_BlazorStatisticsOutput Include="@(_BlazorCopyLocalAssets->'%(RelativePath)')" />
</ItemGroup>
<Message Importance="high" Text="$(TargetName) (Blazor output) -> $(TargetDir)wwwroot" />
</Target>
<Target Name="_StaticWebAssetsBlazorStandalonePublish"
AfterTargets="_StaticWebAssetsComputeFilesToPublish">
<ItemGroup>
<!-- We need to update the external static web assets to follow the blazor publish output convention that puts them inside $(TargetName)/dist instead of wwwroot -->
<_StandaloneExternalPublishStaticWebAsset Include="@(_ExternalPublishStaticWebAsset)" Condition="'%(RelativePath)' != ''">
<RelativePath>$([MSBuild]::MakeRelative('$(MSBuildProjectDirectory)', '$([MSBuild]::NormalizePath('$([System.Text.RegularExpressions.Regex]::Replace('%(RelativePath)','^wwwroot\\?\/?(.*)','$(BlazorPublishDistDir)$1'))'))'))</RelativePath>
</_StandaloneExternalPublishStaticWebAsset>
<!-- Update doesn't work inside targets so we need to remove the items and re-add them. See https://github.com/microsoft/msbuild/issues/2835 for details -->
<ResolvedFileToPublish Remove="@(_StandaloneExternalPublishStaticWebAsset)" />
<ResolvedFileToPublish Include="@(_StandaloneExternalPublishStaticWebAsset)" />
<_CurrentProjectStandalonePublishStaticWebAsset Include="%(StaticWebAsset.FullPath)" Condition="'%(StaticWebAsset.SourceType)' == ''">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<RelativePath>$([MSBuild]::MakeRelative('$(MSBuildProjectDirectory)','$([MSBuild]::NormalizePath('wwwroot\%(BasePath)\%(RelativePath)'))'))</RelativePath>
</_CurrentProjectStandalonePublishStaticWebAsset>
<!-- Remove any existing external static web asset that might have been added as part of the
regular publish pipeline. -->
<ResolvedFileToPublish Remove="@(_CurrentProjectStandalonePublishStaticWebAsset)" />
<ResolvedFileToPublish Include="@(_CurrentProjectStandalonePublishStaticWebAsset)">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</ResolvedFileToPublish>
<ResolvedFileToPublish Include="$(MSBuildThisFileDirectory)Standalone.Web.config">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<RelativePath>web.config</RelativePath>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
<Target Name="_BlazorApplyLinkPreferencesToStaticWebAssets">
<ItemGroup>
<_ContentWithWwrootLinkAttribute Include="@(Content)" Condition="'%(Content.Link)' != '' and $([System.String]::Copy('%(Content.Link)').Replace('\','/').StartsWith('wwwroot/'))" />
<_ContentLinkedIntoWwwroot
Include="@(_ContentWithWwrootLinkAttribute)"
Condition="@(_ContentWithWwrootLinkAttribute) != '' and '%(_ContentWithWwrootLinkAttribute.CopyToPublishDirectory)' != 'false'">
<!-- This gets rid of wwwroot\ -->
<RelativePath>$([System.String]::Copy('%(Link)').Substring(8))</RelativePath>
</_ContentLinkedIntoWwwroot>
<_OutsideContentLinkedIntoWwwroot Include="@(_ContentLinkedIntoWwwroot->'%(FullPath)')" Condition="@(_ContentLinkedIntoWwwroot) != '' and !$([System.String]::Copy('%(Identity)').Replace('\','/').StartsWith('wwwroot/'))" />
<_WwwrootLinkedContent Include="@(_ContentLinkedIntoWwwroot->'%(FullPath)')" Condition="@(_ContentLinkedIntoWwwroot) != '' and $([System.String]::Copy('%(Identity)').Replace('\','/').StartsWith('wwwroot/'))" KeepMetadata="RelativePath" />
<!-- For content items with the Link attribute on them, we update the relative path. This enables support at publish time for these assets but forgoes any
dev-time support. (If you want to have dev-time support, you need to add an appropriate file into the wwwroot folder with CopyToPublishDirectory="false")
-->
<_NonLinkedStaticWebAssets Include="@(StaticWebAsset)" Exclude="@(_WwwrootLinkedContent)" />
<_LinkedStaticWebAssets Include="@(StaticWebAsset)" Exclude="@(_NonLinkedStaticWebAssets)" />
<_UpdatedStaticWebAssets Include="%(Identity)">
<SourceType>@(_LinkedStaticWebAssets->'%(SourceType)')</SourceType>
<SourceId>@(_LinkedStaticWebAssets->'%(SourceId)')</SourceId>
<ContentRoot>@(_LinkedStaticWebAssets->'%(ContentRoot)')</ContentRoot>
<BasePath>@(_LinkedStaticWebAssets->'%(BasePath)')</BasePath>
<RelativePath>@(_WwwrootLinkedContent->'%(RelativePath)')</RelativePath>
</_UpdatedStaticWebAssets>
<StaticWebAsset Remove="@(_UpdatedStaticWebAssets)" />
<StaticWebAsset Include="@(_UpdatedStaticWebAssets)" />
<!-- This allows limited publish time support for content items that are outside the wwwroot folder but are linked into the wwwroot folder. For example:
* Imagine a set of items in <ProjectDir>/Client/publish that are linked into <ProjectDir>/wwwroot/.
* We will consider them static web assets and default their content root to `<ProjectDir>/wwwroot` and their relative path will be whatever is after wwwroot\
* We don't guarantee that these assets can be resolved at development time.
* We do guarantee that we will copy them into the actual wwwroot folder at publish time.
* If you want this type of dev-time support, the recomendation is to add the list of assets to the item group manually indicating a suitable content root.
-->
<StaticWebAsset Include="@(_OutsideContentLinkedIntoWwwroot)" Condition="@(_OutsideContentLinkedIntoWwwroot) != ''">
<SourceType></SourceType>
<SourceId>$(PackageId)</SourceId>
<!-- We don't try to come up with a separate content root to make the inner loop work.
You can add items with CopyToPublishDirectory=false for development time support or add the assets directly by pasing in the parameters
-->
<ContentRoot>$([MSBuild]::NormalizeDirectory('$(MSBuildProjectDirectory)\wwwroot\'))</ContentRoot>
<BasePath>$(StaticWebAssetBasePath)</BasePath>
<RelativePath>%(_OutsideContentLinkedIntoWwwroot.RelativePath)</RelativePath>
</StaticWebAsset>
<_StaticWebAssetsPublishFalse Include="@(Content->'%(FullPath)')" Condition="'%(Content.CopyToPublishDirectory)' == 'false'" />
<_StaticWebAssetsLinkOutsideWwwroot Include="@(Content->'%(FullPath)')" Condition="'%(Content.Link)' != '' and !$([System.String]::Copy('%(Content.Link)').Replace('\','/').StartsWith('wwwroot/'))" />
<!-- Remove files that wouldn't be copied to the publish folder or that would be copied outside of the wwwroot folder if they were ever considered static web assets -->
<StaticWebAsset Remove="@(_StaticWebAssetsPublishFalse)" />
<StaticWebAsset Remove="@(_StaticWebAssetsLinkOutsideWwwroot)" />
</ItemGroup>
</Target>
</Project>

View File

@ -20,12 +20,15 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
var buildOutputDirectory = project.BuildOutputDirectory;
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "blazor.boot.json");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "blazor.webassembly.js");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "blazor.boot.json");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "blazor.webassembly.js");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
var staticWebAssets = Assert.FileExists(result, buildOutputDirectory, "standalone.StaticWebAssets.xml");
Assert.FileContains(result, staticWebAssets, Path.Combine("netstandard2.1", "wwwroot"));
}
[Fact]
@ -39,12 +42,14 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
Assert.BuildPassed(result);
var buildOutputDirectory = project.BuildOutputDirectory;
var blazorConfig = Path.Combine(buildOutputDirectory, "standalone.blazor.config");
Assert.FileExists(result, blazorConfig);
var path = Path.GetFullPath(Path.Combine(project.SolutionPath, "standalone", "bin", project.Configuration, "netstandard2.1", "standalone.dll"));
Assert.FileContains(result, blazorConfig, path);
Assert.FileDoesNotExist(result, buildOutputDirectory, "dist", "_framework", "_bin", "standalone.dll");
Assert.FileDoesNotExist(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "standalone.dll");
var staticWebAssets = Assert.FileExists(result, buildOutputDirectory, "blazorhosted.StaticWebAssets.xml");
Assert.FileContains(result, staticWebAssets, Path.Combine("netstandard2.1", "wwwroot"));
Assert.FileContains(result, staticWebAssets, Path.Combine("razorclasslibrary", "wwwroot"));
Assert.FileContains(result, staticWebAssets, Path.Combine("standalone", "wwwroot"));
}
[Fact]
@ -63,12 +68,12 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
var buildOutputDirectory = project.BuildOutputDirectory;
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "blazor.boot.json");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "blazor.webassembly.js");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "blazor.boot.json");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "blazor.webassembly.js");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
}
[Fact]
@ -91,12 +96,12 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
var buildOutputDirectory = project.BuildOutputDirectory;
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "_bin", "classlibrarywithsatelliteassemblies.dll");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "_bin", "Microsoft.CodeAnalysis.CSharp.dll");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "_bin", "fr", "Microsoft.CodeAnalysis.CSharp.resources.dll"); // Verify satellite assemblies are present in the build output.
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "classlibrarywithsatelliteassemblies.dll");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "Microsoft.CodeAnalysis.CSharp.dll");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "fr", "Microsoft.CodeAnalysis.CSharp.resources.dll"); // Verify satellite assemblies are present in the build output.
var bootJsonPath = Path.Combine(buildOutputDirectory, "dist", "_framework", "blazor.boot.json");
var bootJsonPath = Path.Combine(buildOutputDirectory, "wwwroot", "_framework", "blazor.boot.json");
Assert.FileContains(result, bootJsonPath, "\"Microsoft.CodeAnalysis.CSharp.dll\"");
Assert.FileContains(result, bootJsonPath, "\"fr\\/Microsoft.CodeAnalysis.CSharp.resources.dll\"");
}
@ -122,12 +127,12 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
var buildOutputDirectory = project.BuildOutputDirectory;
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "_bin", "classlibrarywithsatelliteassemblies.dll");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "_bin", "Microsoft.CodeAnalysis.CSharp.dll");
Assert.FileExists(result, buildOutputDirectory, "dist", "_framework", "_bin", "fr", "Microsoft.CodeAnalysis.CSharp.resources.dll"); // Verify satellite assemblies are present in the build output.
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "classlibrarywithsatelliteassemblies.dll");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "Microsoft.CodeAnalysis.CSharp.dll");
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "fr", "Microsoft.CodeAnalysis.CSharp.resources.dll"); // Verify satellite assemblies are present in the build output.
var bootJsonPath = Path.Combine(buildOutputDirectory, "dist", "_framework", "blazor.boot.json");
var bootJsonPath = Path.Combine(buildOutputDirectory, "wwwroot", "_framework", "blazor.boot.json");
Assert.FileContains(result, bootJsonPath, "\"Microsoft.CodeAnalysis.CSharp.dll\"");
Assert.FileContains(result, bootJsonPath, "\"fr\\/Microsoft.CodeAnalysis.CSharp.resources.dll\"");
}

View File

@ -13,27 +13,33 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
public async Task Publish_WithDefaultSettings_Works()
{
// Arrange
using var project = ProjectDirectory.Create("standalone", additionalProjects: new [] { "razorclasslibrary" });
using var project = ProjectDirectory.Create("standalone", additionalProjects: new [] { "razorclasslibrary", "LinkBaseToWebRoot" });
var result = await MSBuildProcessManager.DotnetMSBuild(project, "Publish");
Assert.BuildPassed(result);
var publishDirectory = project.PublishOutputDirectory;
var blazorPublishDirectory = Path.Combine(publishDirectory, Path.GetFileNameWithoutExtension(project.ProjectFilePath));
var blazorPublishDirectory = Path.Combine(publishDirectory, "wwwroot");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "blazor.boot.json");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "blazor.webassembly.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.boot.json");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.webassembly.js");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
// Verify referenced static web assets
Assert.FileExists(result, blazorPublishDirectory, "dist", "_content", "RazorClassLibrary", "wwwroot", "exampleJsInterop.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_content", "RazorClassLibrary", "styles.css");
Assert.FileExists(result, blazorPublishDirectory, "_content", "RazorClassLibrary", "wwwroot", "exampleJsInterop.js");
Assert.FileExists(result, blazorPublishDirectory, "_content", "RazorClassLibrary", "styles.css");
// Verify static assets are in the publish directory
Assert.FileExists(result, blazorPublishDirectory, "dist", "index.html");
Assert.FileExists(result, blazorPublishDirectory, "index.html");
// Verify link item assets are in the publish directory
Assert.FileExists(result, blazorPublishDirectory, "js", "LinkedScript.js");
var cssFile = Assert.FileExists(result, blazorPublishDirectory, "css", "site.css");
Assert.FileContains(result, cssFile, ".publish");
Assert.FileDoesNotExist(result, "dist", "Fake-License.txt");
// Verify web.config
Assert.FileExists(result, publishDirectory, "web.config");
@ -53,25 +59,24 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
Assert.BuildPassed(result);
var publishDirectory = project.PublishOutputDirectory;
var blazorPublishDirectory = Path.Combine(publishDirectory, Path.GetFileNameWithoutExtension(project.ProjectFilePath));
var blazorPublishDirectory = Path.Combine(publishDirectory, "wwwroot");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "blazor.boot.json");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "blazor.webassembly.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.boot.json");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.webassembly.js");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
// Verify static assets are in the publish directory
Assert.FileExists(result, blazorPublishDirectory, "dist", "index.html");
Assert.FileExists(result, blazorPublishDirectory, "index.html");
// Verify static web assets from referenced projects are copied.
// Uncomment once https://github.com/aspnet/AspNetCore/issues/17426 is resolved.
// Assert.FileExists(result, blazorPublishDirectory, "dist", "_content", "RazorClassLibrary", "wwwroot", "exampleJsInterop.js");
// Assert.FileExists(result, blazorPublishDirectory, "dist", "_content", "RazorClassLibrary", "styles.css");
Assert.FileExists(result, blazorPublishDirectory, "_content", "RazorClassLibrary", "wwwroot", "exampleJsInterop.js");
Assert.FileExists(result, blazorPublishDirectory, "_content", "RazorClassLibrary", "styles.css");
// Verify static assets are in the publish directory
Assert.FileExists(result, blazorPublishDirectory, "dist", "index.html");
Assert.FileExists(result, blazorPublishDirectory, "index.html");
// Verify web.config
Assert.FileExists(result, publishDirectory, "web.config");
@ -92,21 +97,21 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
Assert.BuildPassed(result);
var publishDirectory = project.PublishOutputDirectory;
var blazorPublishDirectory = Path.Combine(publishDirectory, Path.GetFileNameWithoutExtension(project.ProjectFilePath));
var blazorPublishDirectory = Path.Combine(publishDirectory, "wwwroot");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "blazor.boot.json");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "blazor.webassembly.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.boot.json");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.webassembly.js");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
// Verify static assets are in the publish directory
Assert.FileExists(result, blazorPublishDirectory, "dist", "index.html");
Assert.FileExists(result, blazorPublishDirectory, "index.html");
// Verify referenced static web assets
Assert.FileExists(result, blazorPublishDirectory, "dist", "_content", "RazorClassLibrary", "wwwroot", "exampleJsInterop.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_content", "RazorClassLibrary", "styles.css");
Assert.FileExists(result, blazorPublishDirectory, "_content", "RazorClassLibrary", "wwwroot", "exampleJsInterop.js");
Assert.FileExists(result, blazorPublishDirectory, "_content", "RazorClassLibrary", "styles.css");
// Verify web.config
Assert.FileExists(result, publishDirectory, "web.config");
@ -131,12 +136,12 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
Assert.BuildPassed(result);
var publishDirectory = project.PublishOutputDirectory;
var blazorPublishDirectory = Path.Combine(publishDirectory, Path.GetFileNameWithoutExtension(project.ProjectFilePath));
var blazorPublishDirectory = Path.Combine(publishDirectory, "wwwroot");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "Microsoft.CodeAnalysis.CSharp.dll");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "fr", "Microsoft.CodeAnalysis.CSharp.resources.dll"); // Verify satellite assemblies are present in the build output.
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "Microsoft.CodeAnalysis.CSharp.dll");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "fr", "Microsoft.CodeAnalysis.CSharp.resources.dll"); // Verify satellite assemblies are present in the build output.
var bootJsonPath = Path.Combine(blazorPublishDirectory, "dist", "_framework", "blazor.boot.json");
var bootJsonPath = Path.Combine(blazorPublishDirectory, "_framework", "blazor.boot.json");
Assert.FileContains(result, bootJsonPath, "\"Microsoft.CodeAnalysis.CSharp.dll\"");
Assert.FileContains(result, bootJsonPath, "\"fr\\/Microsoft.CodeAnalysis.CSharp.resources.dll\"");
}
@ -155,31 +160,23 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
// Make sure the main project exists
Assert.FileExists(result, publishDirectory, "blazorhosted.dll");
var blazorPublishDirectory = Path.Combine(publishDirectory, "standalone");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "blazor.boot.json");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "blazor.webassembly.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
var blazorPublishDirectory = Path.Combine(publishDirectory, "wwwroot");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.boot.json");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.webassembly.js");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
// Verify static assets are in the publish directory
Assert.FileExists(result, blazorPublishDirectory, "dist", "index.html");
Assert.FileExists(result, blazorPublishDirectory, "index.html");
// Verify static web assets from referenced projects are copied.
Assert.FileExists(result, publishDirectory, "wwwroot", "_content", "RazorClassLibrary", "wwwroot", "exampleJsInterop.js");
Assert.FileExists(result, publishDirectory, "wwwroot", "_content", "RazorClassLibrary", "styles.css");
// Verify static assets are in the publish directory
Assert.FileExists(result, blazorPublishDirectory, "dist", "index.html");
// Verify web.config
Assert.FileExists(result, publishDirectory, "web.config");
var blazorConfig = Path.Combine(result.Project.DirectoryPath, publishDirectory, "standalone.blazor.config");
var blazorConfigLines = File.ReadAllLines(blazorConfig);
Assert.Equal(".", blazorConfigLines[0]);
Assert.Equal("standalone/", blazorConfigLines[1]);
}
[Fact]
@ -207,32 +204,27 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
// Make sure the main project exists
Assert.FileExists(result, publishDirectory, "blazorhosted.dll");
var blazorPublishDirectory = Path.Combine(publishDirectory, "standalone");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "blazor.boot.json");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "blazor.webassembly.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
var blazorPublishDirectory = Path.Combine(publishDirectory, "wwwroot");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.boot.json");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.webassembly.js");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
// Verify static assets are in the publish directory
Assert.FileExists(result, blazorPublishDirectory, "dist", "index.html");
Assert.FileExists(result, blazorPublishDirectory, "index.html");
// Verify static web assets from referenced projects are copied.
Assert.FileExists(result, publishDirectory, "wwwroot", "_content", "RazorClassLibrary", "wwwroot", "exampleJsInterop.js");
Assert.FileExists(result, publishDirectory, "wwwroot", "_content", "RazorClassLibrary", "styles.css");
// Verify static assets are in the publish directory
Assert.FileExists(result, blazorPublishDirectory, "dist", "index.html");
Assert.FileExists(result, blazorPublishDirectory, "index.html");
// Verify web.config
Assert.FileExists(result, publishDirectory, "web.config");
var blazorConfig = Path.Combine(result.Project.DirectoryPath, publishDirectory, "standalone.blazor.config");
var blazorConfigLines = File.ReadAllLines(blazorConfig);
Assert.Equal(".", blazorConfigLines[0]);
Assert.Equal("standalone/", blazorConfigLines[1]);
void AddSiblingProjectFileContent(string content)
{
var path = Path.Combine(project.SolutionPath, "standalone", "standalone.csproj");
@ -258,24 +250,21 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
// Make sure the main project exists
Assert.FileExists(result, publishDirectory, "blazorhosted.dll");
var blazorPublishDirectory = Path.Combine(publishDirectory, "standalone");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "blazor.boot.json");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "blazor.webassembly.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, blazorPublishDirectory, "dist", "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
var blazorPublishDirectory = Path.Combine(publishDirectory, "wwwroot");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.boot.json");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "blazor.webassembly.js");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", "dotnet.wasm");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "wasm", "dotnet.js");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "standalone.dll");
Assert.FileExists(result, blazorPublishDirectory, "_framework", "_bin", "Microsoft.Extensions.Logging.Abstractions.dll"); // Verify dependencies are part of the output.
// Verify static assets are in the publish directory
Assert.FileExists(result, blazorPublishDirectory, "dist", "index.html");
Assert.FileExists(result, blazorPublishDirectory, "index.html");
// Verify static web assets from referenced projects are copied.
// Uncomment once https://github.com/aspnet/AspNetCore/issues/17426 is resolved.
// Assert.FileExists(result, publishDirectory, "wwwroot", "_content", "RazorClassLibrary", "wwwroot", "exampleJsInterop.js");
// Assert.FileExists(result, publishDirectory, "wwwroot", "_content", "RazorClassLibrary", "styles.css");
// Verify static assets are in the publish directory
Assert.FileExists(result, blazorPublishDirectory, "dist", "index.html");
Assert.FileExists(result, publishDirectory, "wwwroot", "_content", "RazorClassLibrary", "wwwroot", "exampleJsInterop.js");
Assert.FileExists(result, publishDirectory, "wwwroot", "_content", "RazorClassLibrary", "styles.css");
// Verify web.config
Assert.FileExists(result, publishDirectory, "web.config");

View File

@ -17,4 +17,21 @@
<ProjectReference Include="..\razorclasslibrary\RazorClassLibrary.csproj" />
</ItemGroup>
<ItemGroup>
<!-- These assets should be treated as static web assets for publish purposes -->
<Content Include="..\LinkBaseToWebRoot\**\*.js">
<LinkBase>wwwroot\</LinkBase>
</Content>
<!-- This asset should be ignored as a static web assets as it defines CopyToPublishDirectory="false" -->
<Content Update="wwwroot\css\site.css" CopyToPublishDirectory="false" />
<!-- This asset should be treated as a static web asset and copied into the right location defined by its link attribute. -->
<Content Include="LinkToWebRoot\css\site.css" Link="wwwroot\css\site.css" />
<!-- This asset should not be treated as a static web asset as it is being linked out of the wwwroot folder. -->
<Content Update="wwwroot\Fake-License.txt" Link="Excluded-Static-Web-Assets\Fake-License.txt" />
</ItemGroup>
</Project>

View File

@ -0,0 +1 @@
.build { }

View File

@ -28,6 +28,8 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server
{
services.AddRouting();
services.AddWebAssemblyStaticFilesConfiguration();
services.AddResponseCompression(options =>
{
options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[]
@ -40,8 +42,6 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server
public void Configure(IApplicationBuilder app, IWebHostEnvironment environment, IConfiguration configuration)
{
var applicationAssemblyFullPath = ResolveApplicationAssemblyFullPath();
app.UseDeveloperExceptionPage();
app.UseResponseCompression();
EnableConfiguredPathbase(app, configuration);
@ -49,34 +49,15 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server
app.UseBlazorDebugging();
app.UseStaticFiles();
app.UseClientSideBlazorFiles(applicationAssemblyFullPath);
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapFallbackToClientSideBlazor(applicationAssemblyFullPath, "index.html");
endpoints.MapFallbackToFile("index.html");
});
}
private string ResolveApplicationAssemblyFullPath()
{
const string applicationPathKey = "applicationpath";
var configuredApplicationPath = Configuration.GetValue<string>(applicationPathKey);
if (string.IsNullOrEmpty(configuredApplicationPath))
{
throw new InvalidOperationException($"No value was supplied for the required option '{applicationPathKey}'.");
}
var resolvedApplicationPath = Path.GetFullPath(configuredApplicationPath);
if (!File.Exists(resolvedApplicationPath))
{
throw new InvalidOperationException($"Application assembly not found at {resolvedApplicationPath}.");
}
return resolvedApplicationPath;
}
private static void EnableConfiguredPathbase(IApplicationBuilder app, IConfiguration configuration)
{
var pathBase = configuration.GetValue<string>("pathbase");

View File

@ -1,76 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using System.Linq;
namespace Microsoft.AspNetCore.Components.WebAssembly.Server
{
internal class BlazorConfig
{
public string SourceMSBuildPath { get; }
public string SourceOutputAssemblyPath { get; }
public string WebRootPath { get; }
public string DistPath
=> Path.Combine(Path.GetDirectoryName(SourceOutputAssemblyPath), "dist");
public bool EnableDebugging { get; }
public static BlazorConfig Read(string assemblyPath)
=> new BlazorConfig(assemblyPath);
private BlazorConfig(string assemblyPath)
{
// TODO: Instead of assuming the lines are in a specific order, either JSON-encode
// the whole thing, or at least give the lines key prefixes (e.g., "reload:<someuri>")
// so we're not dependent on order and all lines being present.
var configFilePath = Path.ChangeExtension(assemblyPath, ".blazor.config");
var configLines = File.ReadLines(configFilePath).ToList();
SourceMSBuildPath = configLines[0];
if (SourceMSBuildPath == ".")
{
SourceMSBuildPath = assemblyPath;
}
var sourceMsBuildDir = Path.GetDirectoryName(SourceMSBuildPath);
SourceOutputAssemblyPath = Path.Combine(sourceMsBuildDir, configLines[1]);
var webRootPath = Path.Combine(sourceMsBuildDir, "wwwroot");
if (Directory.Exists(webRootPath))
{
WebRootPath = webRootPath;
}
EnableDebugging = configLines.Contains("debug:true", StringComparer.Ordinal);
}
public string FindIndexHtmlFile()
{
// Before publishing, the client project may have a wwwroot directory.
// If so, and if it contains index.html, use that.
if (!string.IsNullOrEmpty(WebRootPath))
{
var wwwrootIndexHtmlPath = Path.Combine(WebRootPath, "index.html");
if (File.Exists(wwwrootIndexHtmlPath))
{
return wwwrootIndexHtmlPath;
}
}
// After publishing, the client project won't have a wwwroot directory.
// The contents from that dir will have been copied to "dist" during publish.
// So if "dist/index.html" now exists, use that.
var distIndexHtmlPath = Path.Combine(DistPath, "index.html");
if (File.Exists(distIndexHtmlPath))
{
return distIndexHtmlPath;
}
// Since there's no index.html, we'll use the default DefaultPageStaticFileOptions,
// hence we'll look for index.html in the host server app's wwwroot.
return null;
}
}
}

View File

@ -1,98 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Net.Mime;
using Microsoft.AspNetCore.Components.WebAssembly.Server;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.FileProviders;
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Provides extension methods for hosting Blazor WebAssembly applications in ASP.NET Core.
/// </summary>
public static class ComponentsWebAssemblyHostingApplicationBuilderExtensions
{
/// <summary>
/// Adds a <see cref="StaticFileMiddleware"/> that will serve static files from the Blazor WebAssembly application
/// specified by <typeparamref name="TClientApp"/>.
/// </summary>
/// <typeparam name="TClientApp">A type in the Blazor WebAssembly application.</typeparam>
/// <param name="app">The <see cref="IApplicationBuilder"/>.</param>
/// <returns>The <see cref="IApplicationBuilder"/>.</returns>
public static IApplicationBuilder UseClientSideBlazorFiles<TClientApp>(this IApplicationBuilder app)
{
if (app == null)
{
throw new ArgumentNullException(nameof(app));
}
UseClientSideBlazorFiles(app, typeof(TClientApp).Assembly.Location);
return app;
}
/// <summary>
/// Adds a <see cref="StaticFileMiddleware"/> that will serve static files from the Blazor WebAssembly application
/// specified by <paramref name="clientAssemblyFilePath"/>.
/// </summary>
/// <param name="clientAssemblyFilePath">The file path of the Blazor WebAssembly application assembly.</param>
/// <param name="app">The <see cref="IApplicationBuilder"/>.</param>
/// <returns>The <see cref="IApplicationBuilder"/>.</returns>
public static IApplicationBuilder UseClientSideBlazorFiles(this IApplicationBuilder app, string clientAssemblyFilePath)
{
if (clientAssemblyFilePath == null)
{
throw new ArgumentNullException(nameof(clientAssemblyFilePath));
}
var fileProviders = new List<IFileProvider>();
// TODO: Make the .blazor.config file contents sane
// Currently the items in it are bizarre and don't relate to their purpose,
// hence all the path manipulation here. We shouldn't be hardcoding 'dist' here either.
var config = BlazorConfig.Read(clientAssemblyFilePath);
// First, match the request against files in the client app dist directory
fileProviders.Add(new PhysicalFileProvider(config.DistPath));
// * Before publishing, we serve the wwwroot files directly from source
// (and don't require them to be copied into dist).
// In this case, WebRootPath will be nonempty if that directory exists.
// * After publishing, the wwwroot files are already copied to 'dist' and
// will be served by the above middleware, so we do nothing here.
// In this case, WebRootPath will be empty (the publish process sets this).
if (!string.IsNullOrEmpty(config.WebRootPath))
{
fileProviders.Add(new PhysicalFileProvider(config.WebRootPath));
}
// We can't modify an IFileContentTypeProvider, so we have to decorate.
var contentTypeProvider = new FileExtensionContentTypeProvider();
AddMapping(contentTypeProvider, ".dll", MediaTypeNames.Application.Octet);
if (config.EnableDebugging)
{
AddMapping(contentTypeProvider, ".pdb", MediaTypeNames.Application.Octet);
}
var options = new StaticFileOptions()
{
ContentTypeProvider = contentTypeProvider,
FileProvider = new CompositeFileProvider(fileProviders),
OnPrepareResponse = CacheHeaderSettings.SetCacheHeaders,
};
app.UseStaticFiles(options);
return app;
static void AddMapping(FileExtensionContentTypeProvider provider, string name, string mimeType)
{
if (!provider.Mappings.ContainsKey(name))
{
provider.Mappings.Add(name, mimeType);
}
}
}
}
}

View File

@ -1,193 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using Microsoft.AspNetCore.Components.WebAssembly.Server;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Provides extension methods for hosting client-side Blazor applications in ASP.NET Core.
/// </summary>
public static class ComponentsWebAssemblyHostingEndpointRouteBuilderExtensions
{
/// <summary>
/// Adds a low-priority endpoint that will serve the the file specified by <paramref name="filePath"/> from the client-side
/// Blazor application specified by <typeparamref name="TClientApp"/>.
/// </summary>
/// <typeparam name="TClientApp">A type in the client-side application.</typeparam>
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
/// <param name="filePath">
/// The relative path to the entry point of the client-side application. The path is relative to the
/// <see cref="IWebHostEnvironment.WebRootPath"/>, commonly <c>wwwroot</c>.
/// </param>
/// <returns>The <see cref="IApplicationBuilder"/>.</returns>
/// <remarks>
/// <para>
/// This method is intended to handle cases where URL path of the request does not contain a filename, and no other
/// endpoint has matched. This is convenient for routing requests for dynamic content to the client-side blazor
/// application, while also allowing requests for non-existent files to result in an HTTP 404.
/// </para>
/// </remarks>
public static IEndpointConventionBuilder MapFallbackToClientSideBlazor<TClientApp>(this IEndpointRouteBuilder endpoints, string filePath)
{
if (endpoints == null)
{
throw new ArgumentNullException(nameof(endpoints));
}
if (filePath == null)
{
throw new ArgumentNullException(nameof(filePath));
}
return MapFallbackToClientSideBlazor(endpoints, typeof(TClientApp).Assembly.Location, FallbackEndpointRouteBuilderExtensions.DefaultPattern, filePath);
}
/// <summary>
/// Adds a low-priority endpoint that will serve the the file specified by <paramref name="filePath"/> from the client-side
/// Blazor application specified by <paramref name="clientAssemblyFilePath"/>.
/// </summary>
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
/// <param name="clientAssemblyFilePath">The file path of the client-side Blazor application assembly.</param>
/// <param name="filePath">
/// The relative path to the entry point of the client-side application. The path is relative to the
/// <see cref="IWebHostEnvironment.WebRootPath"/>, commonly <c>wwwroot</c>.
/// </param>
/// <returns>The <see cref="IApplicationBuilder"/>.</returns>
/// <remarks>
/// <para>
/// This method is intended to handle cases where URL path of the request does not contain a filename, and no other
/// endpoint has matched. This is convenient for routing requests for dynamic content to the client-side blazor
/// application, while also allowing requests for non-existent files to result in an HTTP 404.
/// </para>
/// </remarks>
public static IEndpointConventionBuilder MapFallbackToClientSideBlazor(this IEndpointRouteBuilder endpoints, string clientAssemblyFilePath, string filePath)
{
if (endpoints == null)
{
throw new ArgumentNullException(nameof(endpoints));
}
if (clientAssemblyFilePath == null)
{
throw new ArgumentNullException(nameof(clientAssemblyFilePath));
}
if (filePath == null)
{
throw new ArgumentNullException(nameof(filePath));
}
return MapFallbackToClientSideBlazor(endpoints, clientAssemblyFilePath, FallbackEndpointRouteBuilderExtensions.DefaultPattern, filePath);
}
/// <summary>
/// Adds a low-priority endpoint that will serve the the file specified by <paramref name="filePath"/> from the client-side
/// Blazor application specified by <typeparamref name="TClientApp"/>.
/// </summary>
/// <typeparam name="TClientApp">A type in the client-side application.</typeparam>
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
/// <param name="pattern">The route pattern to match.</param>
/// <param name="filePath">
/// The relative path to the entry point of the client-side application. The path is relative to the
/// <see cref="IWebHostEnvironment.WebRootPath"/>, commonly <c>wwwroot</c>.
/// </param>
/// <returns>The <see cref="IApplicationBuilder"/>.</returns>
/// <remarks>
/// <para>
/// This method is intended to handle cases where URL path of the request does not contain a filename, and no other
/// endpoint has matched. This is convenient for routing requests for dynamic content to the client-side blazor
/// application, while also allowing requests for non-existent files to result in an HTTP 404.
/// </para>
/// </remarks>
public static IEndpointConventionBuilder MapFallbackToClientSideBlazor<TClientApp>(this IEndpointRouteBuilder endpoints, string pattern, string filePath)
{
if (endpoints == null)
{
throw new ArgumentNullException(nameof(endpoints));
}
if (pattern == null)
{
throw new ArgumentNullException(nameof(pattern));
}
if (filePath == null)
{
throw new ArgumentNullException(nameof(filePath));
}
return MapFallbackToClientSideBlazor(endpoints, typeof(TClientApp).Assembly.Location, pattern, filePath);
}
/// <summary>
/// Adds a low-priority endpoint that will serve the the file specified by <paramref name="filePath"/> from the client-side
/// Blazor application specified by <paramref name="clientAssemblyFilePath"/>.
/// </summary>
/// <param name="clientAssemblyFilePath">The file path of the client-side Blazor application assembly.</param>
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
/// <param name="pattern">The route pattern to match.</param>
/// <param name="filePath">
/// The relative path to the entry point of the client-side application. The path is relative to the
/// <see cref="IWebHostEnvironment.WebRootPath"/>, commonly <c>wwwroot</c>.
/// </param>
/// <returns>The <see cref="IApplicationBuilder"/>.</returns>
/// <remarks>
/// <para>
/// This method is intended to handle cases where URL path of the request does not contain a filename, and no other
/// endpoint has matched. This is convenient for routing requests for dynamic content to the client-side blazor
/// application, while also allowing requests for non-existent files to result in an HTTP 404.
/// </para>
/// </remarks>
public static IEndpointConventionBuilder MapFallbackToClientSideBlazor(this IEndpointRouteBuilder endpoints, string clientAssemblyFilePath, string pattern, string filePath)
{
if (endpoints == null)
{
throw new ArgumentNullException(nameof(endpoints));
}
if (clientAssemblyFilePath == null)
{
throw new ArgumentNullException(nameof(clientAssemblyFilePath));
}
if (pattern == null)
{
throw new ArgumentNullException(nameof(pattern));
}
if (filePath == null)
{
throw new ArgumentNullException(nameof(filePath));
}
var config = BlazorConfig.Read(clientAssemblyFilePath);
// We want to serve "index.html" from whichever directory contains it in this priority order:
// 1. Client app "dist" directory
// 2. Client app "wwwroot" directory
// 3. Server app "wwwroot" directory
var directory = endpoints.ServiceProvider.GetRequiredService<IWebHostEnvironment>().WebRootPath;
var indexHtml = config.FindIndexHtmlFile();
if (indexHtml != null)
{
directory = Path.GetDirectoryName(indexHtml);
}
var options = new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(directory),
OnPrepareResponse = CacheHeaderSettings.SetCacheHeaders,
};
return endpoints.MapFallbackToFile(pattern, filePath, options);
}
}
}

View File

@ -0,0 +1,51 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Net.Mime;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.DependencyInjection
{
public static class ComponentsWebAssemblyServiceCollectionExtensions
{
public static IServiceCollection AddWebAssemblyStaticFilesConfiguration(this IServiceCollection services)
{
services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<StaticFileOptions>, ClientSideBlazorStaticFilesConfiguration>());
return services;
}
private class ClientSideBlazorStaticFilesConfiguration : IConfigureOptions<StaticFileOptions>
{
private readonly IWebHostEnvironment _webHostEnvironment;
public ClientSideBlazorStaticFilesConfiguration(IWebHostEnvironment webHostEnvironment)
{
_webHostEnvironment = webHostEnvironment;
}
public void Configure(StaticFileOptions options)
{
options.FileProvider = _webHostEnvironment.WebRootFileProvider;
var contentTypeProvider = new FileExtensionContentTypeProvider();
AddMapping(contentTypeProvider, ".dll", MediaTypeNames.Application.Octet);
// We unconditionally map pdbs as there will be no pdbs in the output folder for
// release builds unless BlazorEnableDebugging is explicitly set to true.
AddMapping(contentTypeProvider, ".pdb", MediaTypeNames.Application.Octet);
options.ContentTypeProvider = contentTypeProvider;
}
private static void AddMapping(FileExtensionContentTypeProvider provider, string name, string mimeType)
{
if (!provider.Mappings.ContainsKey(name))
{
provider.Mappings.Add(name, mimeType);
}
}
}
}
}

View File

@ -17,6 +17,10 @@ namespace HostedInAspNet.Server
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webHostBuilder =>
{
// We require this line because we run in Production environment
// and static web assets are only on by default during development.
webHostBuilder.UseStaticWebAssets();
webHostBuilder.UseStartup<Startup>();
})
.Build();

View File

@ -15,6 +15,7 @@ namespace HostedInAspNet.Server
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<RequestLog>();
services.AddWebAssemblyStaticFilesConfiguration();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -34,13 +35,12 @@ namespace HostedInAspNet.Server
}
app.UseStaticFiles();
app.UseClientSideBlazorFiles<Client.Program>();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapFallbackToClientSideBlazor<Client.Program>("index.html");
endpoints.MapFallbackToFile("index.html");
});
}
}

View File

@ -17,6 +17,9 @@ namespace MonoSanity
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webHostBuilder =>
{
// We require this line because we run in Production environment
// and static web assets are only on by default during development.
webHostBuilder.UseStaticWebAssets();
webHostBuilder.UseStartup<Startup>();
})
.Build();

View File

@ -10,6 +10,7 @@ namespace MonoSanity
{
public void ConfigureServices(IServiceCollection services)
{
services.AddWebAssemblyStaticFilesConfiguration();
}
public void Configure(IApplicationBuilder app)
@ -17,11 +18,10 @@ namespace MonoSanity
app.UseDeveloperExceptionPage();
app.UseFileServer(new FileServerOptions() { EnableDefaultFiles = true, });
app.UseStaticFiles();
app.UseClientSideBlazorFiles<MonoSanityClient.Program>();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapFallbackToClientSideBlazor<MonoSanityClient.Program>("index.html");
endpoints.MapFallbackToFile("index.html");
});
}
}

View File

@ -37,6 +37,8 @@ namespace Wasm.Authentication.Server
services.AddAuthentication()
.AddIdentityServerJwt();
services.AddWebAssemblyStaticFilesConfiguration();
services.AddMvc();
services.AddResponseCompression(opts =>
{
@ -57,7 +59,6 @@ namespace Wasm.Authentication.Server
}
app.UseStaticFiles();
app.UseClientSideBlazorFiles<Client.Program>();
app.UseRouting();
@ -69,7 +70,7 @@ namespace Wasm.Authentication.Server
{
endpoints.MapControllers();
endpoints.MapRazorPages();
endpoints.MapFallbackToClientSideBlazor<Client.Program>("index.html");
endpoints.MapFallbackToFile("index.html");
});
}
}

View File

@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
ITestOutputHelper output)
: base(browserFixture, serverFixture, output)
{
serverFixture.BuildWebHostMethod = HostedInAspNet.Server.Program.BuildWebHost;
serverFixture.BuildWebHostMethod = Program.BuildWebHost;
}
public override Task InitializeAsync()
@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
var subsequentResourcesRequested = GetAndClearRequestedPaths();
Assert.NotEmpty(initialResourcesRequested.Where(path => path.EndsWith("/blazor.boot.json")));
Assert.Empty(subsequentResourcesRequested.Where(path => path.EndsWith("/dotnet.wasm")));
Assert.NotEmpty(subsequentResourcesRequested.Where(path => path.EndsWith(".js")));
Assert.Empty(subsequentResourcesRequested.Where(path => path.EndsWith(".js")));
Assert.Empty(subsequentResourcesRequested.Where(path => path.EndsWith(".dll")));
}

View File

@ -1,4 +1,4 @@
{
{
"Logging": {
"IncludeScopes": false,
"Debug": {

View File

@ -27,6 +27,9 @@ namespace TestServer
services.AddMvc();
services.AddServerSideBlazor();
services.AddWebAssemblyStaticFilesConfiguration();
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
services.AddAuthorization(options =>
{
@ -49,7 +52,6 @@ namespace TestServer
app.Map("/subdir", app =>
{
app.UseStaticFiles();
app.UseClientSideBlazorFiles<BasicTestApp.Program>();
app.UseRouting();
app.UseEndpoints(endpoints =>
@ -66,7 +68,7 @@ namespace TestServer
public class AuthenticationStartup : AuthenticationStartupBase
{
public AuthenticationStartup(IConfiguration configuration)
: base(configuration, (endpoints) => endpoints.MapFallbackToClientSideBlazor<BasicTestApp.Program>("index.html"))
: base(configuration, (endpoints) => endpoints.MapFallbackToFile("index.html"))
{
}
}

View File

@ -23,6 +23,7 @@ namespace TestServer
{
services.AddMvc();
services.AddServerSideBlazor();
services.AddWebAssemblyStaticFilesConfiguration();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -37,7 +38,6 @@ namespace TestServer
app.Map("/subdir", app =>
{
// Add it before to ensure it takes priority over files in wwwroot
app.UseClientSideBlazorFiles<BasicTestApp.Program>();
app.UseStaticFiles();
app.UseRouting();
@ -45,7 +45,7 @@ namespace TestServer
{
endpoints.MapRazorPages();
endpoints.MapControllers();
endpoints.MapFallbackToClientSideBlazor<BasicTestApp.Program>("index.html");
endpoints.MapFallbackToFile("index.html");
});
});
}

View File

@ -19,6 +19,7 @@ namespace TestServer
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddWebAssemblyStaticFilesConfiguration();
services.AddCors(options =>
{
// It's not enough just to return "Access-Control-Allow-Origin: *", because
@ -46,7 +47,6 @@ namespace TestServer
app.Map("/subdir", app =>
{
app.UseStaticFiles();
app.UseClientSideBlazorFiles<BasicTestApp.Program>();
app.UseRouting();
@ -55,7 +55,7 @@ namespace TestServer
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapFallbackToClientSideBlazor<BasicTestApp.Program>("index.html");
endpoints.MapFallbackToFile("index.html");
});
});
}

View File

@ -23,6 +23,7 @@ namespace TestServer
{
services.AddMvc();
services.AddServerSideBlazor();
services.AddWebAssemblyStaticFilesConfiguration();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -37,7 +38,6 @@ namespace TestServer
app.Map("/subdir", app =>
{
app.UseStaticFiles();
app.UseClientSideBlazorFiles<BasicTestApp.Program>();
app.UseRequestLocalization(options =>
{

View File

@ -1,11 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using BasicTestApp;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Components.Server;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -24,6 +21,7 @@ namespace TestServer
public void ConfigureServices(IServiceCollection services)
{
services.AddWebAssemblyStaticFilesConfiguration();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
@ -36,7 +34,7 @@ namespace TestServer
// The client-side files middleware needs to be here because the base href in hardcoded to /subdir/
app.Map("/subdir", app =>
{
app.UseClientSideBlazorFiles<BasicTestApp.Program>();
app.UseStaticFiles();
});
// The calls to `Map` allow us to test each of these overloads, while keeping them isolated.
@ -46,7 +44,7 @@ namespace TestServer
app.UseEndpoints(endpoints =>
{
endpoints.MapFallbackToClientSideBlazor<BasicTestApp.Program>("index.html");
endpoints.MapFallbackToFile("index.html");
});
});
@ -56,7 +54,7 @@ namespace TestServer
app.UseEndpoints(endpoints =>
{
endpoints.MapFallbackToClientSideBlazor<BasicTestApp.Program>("test/{*path:nonfile}", "index.html");
endpoints.MapFallbackToFile("test/{*path:nonfile}", "index.html");
});
});
@ -66,7 +64,7 @@ namespace TestServer
app.UseEndpoints(endpoints =>
{
endpoints.MapFallbackToClientSideBlazor(typeof(BasicTestApp.Program).Assembly.Location, "index.html");
endpoints.MapFallbackToFile("index.html");
});
});
@ -76,7 +74,7 @@ namespace TestServer
app.UseEndpoints(endpoints =>
{
endpoints.MapFallbackToClientSideBlazor(typeof(BasicTestApp.Program).Assembly.Location, "test/{*path:nonfile}", "index.html");
endpoints.MapFallbackToFile("test/{*path:nonfile}", "index.html");
});
});
}

View File

@ -21,13 +21,10 @@
<!--#endif -->
<!--#if PWA -->
<ItemGroup>
<!-- When publishing, swap service-worker.published.js in place of service-worker.js -->
<Content Update="wwwroot\service-worker*.js" CopyToPublishDirectory="false" />
<ContentWithTargetPath Include="wwwroot\service-worker.published.js">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<TargetPath>wwwroot\service-worker.js</TargetPath>
</ContentWithTargetPath>
<!-- When publishing, swap service-worker.published.js in place of service-worker.js -->
<ItemGroup Condition="'$(DesignTimeBuild)' != 'true'">
<Content Remove="wwwroot\service-worker.js" />
<Content Update="wwwroot\service-worker.published.js" Link="wwwroot\service-worker.js" />
</ItemGroup>
<!--#endif -->

View File

@ -71,6 +71,8 @@ namespace ComponentsWebAssembly_CSharp.Server
services.AddRazorPages();
#endif
services.AddWebAssemblyStaticFilesConfiguration();
services.AddResponseCompression(opts =>
{
opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
@ -105,7 +107,6 @@ namespace ComponentsWebAssembly_CSharp.Server
#endif
app.UseStaticFiles();
app.UseClientSideBlazorFiles<Client.Program>();
app.UseRouting();
@ -126,7 +127,7 @@ namespace ComponentsWebAssembly_CSharp.Server
#endif
endpoints.MapControllers();
endpoints.MapFallbackToClientSideBlazor<Client.Program>("index.html");
endpoints.MapFallbackToFile("index.html");
});
}
}

View File

@ -56,7 +56,7 @@ namespace Templates.Test
private ProcessEx RunPublishedStandaloneBlazorProject(Project project)
{
var publishDir = Path.Combine(project.TemplatePublishDir, project.ProjectName, "dist");
var publishDir = Path.Combine(project.TemplatePublishDir, "wwwroot");
AspNetProcess.EnsureDevelopmentCertificates();
Output.WriteLine("Running dotnet serve on published output...");
@ -123,7 +123,7 @@ namespace Templates.Test
await BuildAndRunTest(project.ProjectName, project);
var publishDir = Path.Combine(project.TemplatePublishDir, project.ProjectName, "dist");
var publishDir = Path.Combine(project.TemplatePublishDir, "wwwroot");
// When publishing the PWA template, we generate an assets manifest
// and move service-worker.published.js to overwrite service-worker.js