Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor Server running in docker container cant access static web assets #82

Closed
whentotrade opened this issue Sep 8, 2019 · 5 comments
Closed
Labels
external External package or product problem packaging Problems concerning the nuget package

Comments

@whentotrade
Copy link

whentotrade commented Sep 8, 2019

Describe the bug
Building an blazor app server-side with FileReader works without any problem. When deploying as docker container, startup fails as it wants to access "/root/.nuget/packages/tewr.blazor.filereader/0.15.0.19248/staticwebassets" during first run, which is not mounted as a volume.

Error message

Unhandled exception. System.IO.DirectoryNotFoundException: /root/.nuget/packages/tewr.blazor.filereader/0.15.0.19248/staticwebassets/
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters)
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root)
   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsFileProvider..ctor(String pathPrefix, String contentRoot)
   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.<>c.<UseStaticWebAssetsCore>b__2_0(ContentRootMapping cr)
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.OfTypeIterator[TResult](IEnumerable source)+MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssetsCore(IWebHostEnvironment environment, Stream manifest)
   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssets(IWebHostEnvironment environment, IConfiguration configuration)
   at Microsoft.AspNetCore.WebHost.<>c.<ConfigureWebDefaults>b__9_0(WebHostBuilderContext ctx, IConfigurationBuilder cb)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass8_0.<ConfigureAppConfiguration>b__0(HostBuilderContext context, IConfigurationBuilder builder)
   at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()

Project type
Server-side

Environment

  • Visual Studio Preview 16.3
  • Blazor.FileReader Preview 9 / 0.15.0.19248
  • .net core 3 preview 9

What might be a solution to avoid this error and to avoid mounting as a volume as this is not available on client environments? Should I include the static assets directly in the source folder?

@Tewr
Copy link
Owner

Tewr commented Sep 8, 2019

Hello,

I'm sorry but I am really a docker novice so I'm of little help. Try reading this thread to see if you can get something out of it.

That said, staticwebassets are not needed for the component to run server-side if you use the initializeonfirstcall=true option, so if you could just get rid of it somehow that could be a workaround

@Tewr Tewr added the help wanted Extra attention is needed label Sep 8, 2019
@Tewr
Copy link
Owner

Tewr commented Sep 8, 2019

Are you using any other package that has staticwebassets that works? That could help me compare in case my packaging setup has some kind of issue.

@Tewr
Copy link
Owner

Tewr commented Sep 8, 2019

Quote from https://docs.microsoft.com/en-us/aspnet/core/razor-pages/ui-class?view=aspnetcore-3.0&tabs=visual-studio#create-an-rcl-with-static-assets:

When 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/{LIBRARY NAME}/.

Is this not happening for you?

@Tewr Tewr added the question Further information is requested label Sep 9, 2019
@whentotrade
Copy link
Author

The assets are there in the container. All fine.

It looks like this is only related if the docker container is started via visual studio. If the created container is manually started via docker run, all is working. So the error can be scoped to the visual studio starting/debugging experience which is not working. The package in general is working when container is started manually.

Thanks for you great work! I think this can be closed as it is related to visual studio and container debugging only.

@Tewr Tewr added external External package or product problem packaging Problems concerning the nuget package and removed help wanted Extra attention is needed question Further information is requested labels Sep 9, 2019
@Tewr
Copy link
Owner

Tewr commented Sep 9, 2019

OK thanks for the feedback, closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external External package or product problem packaging Problems concerning the nuget package
Projects
None yet
Development

No branches or pull requests

2 participants