[Asp.Net Core MVC] Is posssible to embed the wwwroot directory inside the dist binary?

Storm Energy 0 Reputation points
2024-05-10T13:51:50.54+00:00

I have an Asp Net Core MVC project with my assets in wwwroot. My intent is to have only the binary and the appsettings file so is easy to update the application in production without to lose some updated assets files.

I used this options (https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli) the create the binary but the wwwroot is outside.

There is any way to embed that folder and calling assets embeded files from cshtml? (I have used this tecnics with the GO language).

Thanks

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,237 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 57,886 Reputation points
    2024-05-10T16:09:06.8033333+00:00

    you would need to write a custom static file handler, that used resources instead of files, and make all the files in wwwroot a resource. then the files would be in the bundle.

    https://learn.microsoft.com/en-us/dotnet/core/extensions/create-resource-files

    0 comments No comments

  2. Storm Energy 0 Reputation points
    2024-05-13T07:23:00.6733333+00:00
    0 comments No comments