WebWindow
WebWindow copied to clipboard
How to include static assets from RazorLib?
Hi I'm trying to use MatBlazor library but I can't seem to figure out how to include the js and css files for MatBlazor
@SteveSandersonMS
Thanks!
I tried this but it doesn't seem to work
<link href="/_content/RazorClassLibrary1/styles.css" rel="stylesheet" />
<script src="/_content/RazorClassLibrary1/exampleJsInterop.js"></script>
I did some testing of loading assets from "_content" with Version="0.1.0-20191120.6"
- No - VS debug
- No - dotnet run
- Yes - Publish - Self-Contained
- Yes - Publish - Framework Dependent
- No - Publish - Self-Contained + Produce single file
- No - Publish - Framework Dependent + Produce single file
Unfortunately this is a common issue of any ASP .NET Core application: "Produce single file" option does not generate _content folder with RazorLib assets which should lead to improper work of many Blazor apps.
Bumping this issue, since I am running into iit myself.
What is the cause of the _content folder not generating when using "Produce single file"?
Is there any workaround for VS debug mode? Even an ugly hack would help!
Even if I have to change the source code, just point me in the right direction, thank you!
@Jinjinov I haven't tried to implement it myself, but the MSBuild logic needed to copy static web assets into the build output is this: https://github.com/dotnet/aspnetcore/blob/blazor-wasm/src/Components/WebAssembly/Build/src/targets/StaticWebAssets.targets#L37-L72
If you find you're able to make this work and want to submit a PR here, that would be great!
Making the assets as embedded worked for me (on the wwwroot folder)
This guide helped https://codeopinion.com/asp-net-core-csproj-embedded-resources/
I'm really new to blazor, any way to use middleware and fileprovider to _content/resoruce