Mike Chambers
07/26/2024, 8:31 AMstaticwebassets
in a razor class library
support overriding the embedded static asset with a local physical file or is it just razor files that are supported?
I did find https://learn.microsoft.com/en-us/aspnet/core/razor-pages/ui-class?view=aspnetcore-8.0&tabs=visual-studio#override-views-partial-views-and-pages
When a view, partial view, or Razor Page is found in both the web app and the RCL, the Razor markup (.cshtml file) in the web app takes precedence.
If static assets can also be overridden then I'm struggling to get it to work by having a file in App_Plugins\{PACKAGENAME}\Views\{FILENAME}.html
I've checked the Microsoft.AspNetCore.StaticWebAssets.Props
file in the nuget package and the <BasePath>App_Plugins/{PACKAGENAME}</BasePath>
is correct and the asset is in the staticwebassets/Views/{FILENAME}.html
in the package but don't seem to be able to override with the corresponding physical file on disk?
Cheers all.Warren Buckley
07/26/2024, 9:02 AMMike Chambers
07/26/2024, 9:03 AMMike Chambers
07/26/2024, 9:04 AMMike Chambers
07/26/2024, 9:06 AM<EmbeddedResource Remove="App_Plugins\{PACKAGENAME}\Views\{FILENAME}.html" />
in the csproj to drop the file I want to change.Mike Chambers
07/26/2024, 9:15 AMwwwroot/App_Plugins
folder 🤔
https://cdn.discordapp.com/attachments/1266311941996154982/1266322872008441856/image.png?ex=66a4ba93&is=66a36913&hm=113dce7dc202db01aeb974d1c651e5146552b2ffe890511646cacd409c37a1ee&Mike Chambers
07/26/2024, 9:35 AMXML
<Target Name="TSD_AfterCopyFilesMarkedCopyLocal" AfterTargets="_CopyFilesMarkedCopyLocal" Condition="Exists('$(Projectdir)..\ExternalDependencies\App_Plugins')">
<!-- set at the same filepath in ..\ExternalDependencies\App_Plugins to copy over -->
<!-- for published -->
<ItemGroup>
<TSDAppPluginOverrideFiles Include="$(TsdAppPluginOverrideFilesPath)" />
</ItemGroup>
<Message Text="Copying MY App_Plugin Overrides: $(TsdAppPluginOverrideFilesPath) - #@(TSDAppPluginOverrideFiles->Count()) files to $(publishDir)App_Plugins" Importance="high" />
<Copy SourceFiles="@(TSDAppPluginOverrideFiles)" DestinationFiles="@(TSDAppPluginOverrideFiles->'$(PublishDir)\wwwroot\App_Plugins\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
remembering to also add to avoid Conflicting assets with the same target path
xml
<ItemGroup>
<Content Remove="Smidge\**" />
<Content Remove="wwwroot\App_Plugins\DocTypeGridEditor\**" />
<Content Remove="wwwroot\App_Plugins\UmbracoForms\**" />
<EmbeddedResource Remove="Smidge\**" />
<EmbeddedResource Remove="wwwroot\App_Plugins\DocTypeGridEditor\**" />
<EmbeddedResource Remove="wwwroot\App_Plugins\UmbracoForms\**" />
<None Remove="Smidge\**" />
<None Remove="wwwroot\App_Plugins\DocTypeGridEditor\**" />
<None Remove="wwwroot\App_Plugins\UmbracoForms\**" />
</ItemGroup>
Though not sure how to do in a dev environment commenting //webBuilder.UseStaticWebAssets();
in program.cs
doesn't result in physical files appearing.Mike Chambers
07/26/2024, 9:44 AM<StaticWebAssetsEnabled>false</StaticWebAssetsEnabled>
in the csproj kills the backoffice.
@Warren Buckley @huwred thanks for looking.. going to park this now.. more pressing things to look at.Mike Chambers
07/26/2024, 9:48 AMJemayn
07/26/2024, 9:53 AMWarren Buckley
07/26/2024, 10:01 AMMike Chambers
07/26/2024, 10:22 AMJason
07/29/2024, 9:55 PMMike Chambers
07/29/2024, 10:00 PMJason
07/29/2024, 10:00 PMMike Chambers
07/29/2024, 10:02 PMJason
07/29/2024, 10:02 PMJason
07/29/2024, 10:02 PMMike Chambers
07/29/2024, 10:02 PMMike Chambers
07/29/2024, 10:03 PMMike Chambers
07/29/2024, 10:03 PMJason
07/29/2024, 10:14 PMJason
07/29/2024, 10:14 PMMike Chambers
07/29/2024, 10:15 PMstaticWebAssets
😦Jason
07/29/2024, 10:16 PMJason
07/29/2024, 10:16 PMJason
07/29/2024, 10:16 PMJason
07/29/2024, 10:17 PMMike Chambers
07/29/2024, 10:19 PM_content/{id}/
with the namespace as the umb (nuget) package name?Mike Chambers
07/29/2024, 10:19 PMWhen the app is published, the companion assets from all referenced projects and packages are copied into the wwwroot folder of the published app under _content/{PACKAGE ID}/. When producing a NuGet package and the assembly name isn't the same as the package ID (<PackageId> in the library's project file), use the package ID as specified in the project file for {PACKAGE ID} when examining the wwwroot folder for the published assets.
so we're only really replacing _content
with app_plugins
??Jason
07/29/2024, 10:23 PMJason
07/29/2024, 10:23 PMJason
07/29/2024, 10:23 PMMike Chambers
07/29/2024, 10:24 PMMike Chambers
07/29/2024, 10:25 PM.UseStaticWebAssets();
is doing the magic.. nada...Jason
07/29/2024, 10:25 PMMike Chambers
07/29/2024, 10:26 PMJason
07/29/2024, 10:27 PMMike Chambers
07/29/2024, 10:28 PMMike Chambers
07/29/2024, 10:28 PMMike Chambers
07/29/2024, 10:28 PMMike Chambers
07/29/2024, 10:29 PMMike Chambers
07/29/2024, 10:29 PMJason
07/29/2024, 10:31 PMJason
07/29/2024, 10:31 PMMike Chambers
07/29/2024, 10:35 PMC:\\Users\\mike\\.nuget\\packages\\our.umbraco.umbnav.web\\3.0.1\\staticwebassets\\
can't really be overriding in there?Jason
07/29/2024, 10:36 PMMike Chambers
07/29/2024, 10:37 PMMike Chambers
07/29/2024, 10:40 PMJason
07/29/2024, 10:44 PMJason
07/29/2024, 10:48 PMJason
07/29/2024, 10:52 PMJason
07/29/2024, 10:52 PMcsharp
app.Use(async (context, next) =>
{
if (context.Request.Path.ToString().StartsWith("/App_Plugins/Umbraco.BlockGridEditor.DefaultCustomViews/umbBlockGridDemoHeadlineBlock.html"))
{
await context.Response.WriteAsync("Boom!");
return;
}
await next.Invoke();
});