I searched a lot, read about MsBuild, post-build jobs, csproj-config, but did not succeed with this:
Static files (like css or js) sitting in a Blazor component lib are not copied to the final app's wwwroot folder
What I have:
- A Blazor webassembly (.Net6, client-side) project as consumer.
- a Razor-Lib-project as library for reusable controls such as notifications
- some more, but irrelevant here
The lib has its own wwwroot
with css and scripts.
During build the files are finally found in TheConsumerProject\bin\Debug\net6.0\wwwroot
. But when debugging with IIS Express (directly from VS) the files should be loaded from TheConsumerProject\wwwroot
. That fails... When I copied the files manually it worked.
The goal: Any consumer should not need to configure anything special. Just reference the lib and get all in place.
I found
<StaticWebAssetBasePath>
to be specified in the lib's csproj but did not manage to get any further with this.- hints to
<Target>
with copy jobs using$(MsBuildVariable)
. This actually worked, the files were copied to a specified destination, but I did not find a variable pointing to the final app'swwwroot
. - Some tweaks with
<ItemGroup>
but nothing worked.
I do NOT want to use any project specific data, like relative paths. This should work with any project structure if possible.
Any ideas?