You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to load js files from an external component package (mudblazor) . The web app is initialized from a calling application, a console application.
I discovered some issues related to the .StaticWebAssets.xml not being copied when the main project was built or run using F5. A post-build step now always copies this file.
I discovered that I needed to add this to the CreateHostBuilder method in the Program file
webBuilder.ConfigureAppConfiguration((ctx, cb) =>
{
if (!ctx.HostingEnvironment.IsDevelopment()){
StaticWebAssetsLoader.UseStaticWebAssets(
ctx.HostingEnvironment,
ctx.Configuration);
}
});
With these changes it all works fine, both in debug and release
One item I can't understand is that the StaticWebAssets.xml links back to the install directory of the nuget package. I tried various different ways of linking to the js file (MudBlazor.min.js) which I set to be copied as both content and an embedded resource. However no other method of loading the file worked as it resulted in a JSInterop error
So it appears the only way is to link using the StaticWebAssets file.
This works on a local machine however it would appear that for deployments the staticassets folder from the nuget install folder needs to be distributed and the StaticWebAssets.xml file updated to point at the deployed folder
This does not seem correct. It is a workaround and sustainable moving forward.
What am I missing? Any pointers would be gratefully accepted.
Thanks in advance
Kieran
The text was updated successfully, but these errors were encountered:
Hi
I am attempting to load js files from an external component package (mudblazor) . The web app is initialized from a calling application, a console application.
Framework: netcoreapp3.1
_Host.cshtml
I discovered some issues related to the .StaticWebAssets.xml not being copied when the main project was built or run using F5. A post-build step now always copies this file.
I discovered that I needed to add this to the CreateHostBuilder method in the Program file
webBuilder.ConfigureAppConfiguration((ctx, cb) =>
{
if (!ctx.HostingEnvironment.IsDevelopment()){
StaticWebAssetsLoader.UseStaticWebAssets(
ctx.HostingEnvironment,
ctx.Configuration);
}
});
With these changes it all works fine, both in debug and release
One item I can't understand is that the StaticWebAssets.xml links back to the install directory of the nuget package. I tried various different ways of linking to the js file (MudBlazor.min.js) which I set to be copied as both content and an embedded resource. However no other method of loading the file worked as it resulted in a JSInterop error
Microsoft.JSInterop.JSException: Could not find 'domService' in 'window'.
Error: Could not find 'domService' in 'window'.
at http://localhost:5006/_framework/blazor.server.js:8:35211
at Array.forEach ()
at p (http://localhost:5006/_framework/blazor.server.js:8:35171)
at http://localhost:5006/_framework/blazor.server.js:8:35881
at new Promise ()
at e.beginInvokeJSFromDotNet (http://localhost:5006/_framework/blazor.server.js:8:35854)
at http://localhost:5006/_framework/blazor.server.js:1:20247
at Array.forEach ()
at e.invokeClientMethod (http://localhost:5006/_framework/blazor.server.js:1:20217)
at e.processIncomingData (http://localhost:5006/_framework/blazor.server.js:1:18028)
at Microsoft.JSInterop.JSRuntime.InvokeWithDefaultCancellation[T](String identifier, Object[] args)
at MudBlazor.MudDrawer.UpdateHeight()
at MudBlazor.MudDrawer.OnAfterRenderAsync(Boolean firstRender)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit 'ZwuqTd7cgtzxRSfhWvHSMqEazFgFlRSPmKJ1lzNwXBY'.
So it appears the only way is to link using the StaticWebAssets file.
This works on a local machine however it would appear that for deployments the staticassets folder from the nuget install folder needs to be distributed and the StaticWebAssets.xml file updated to point at the deployed folder
This does not seem correct. It is a workaround and sustainable moving forward.
What am I missing? Any pointers would be gratefully accepted.
Thanks in advance
Kieran
The text was updated successfully, but these errors were encountered: