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

Storm Energy 5 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

Developer technologies | ASP.NET | ASP.NET Core
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Storm Energy 5 Reputation points
    2024-05-13T07:23:00.6733333+00:00
    1 person found this answer helpful.
    0 comments No comments

  2. Bruce (SqlWork.com) 77,926 Reputation points Volunteer Moderator
    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.