Skip to content

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

Discussion options

You must be logged in to vote

Yes, you can do this 😀 Here is how:

In your *.csproj:

<PropertyGroup>
   <!-- all the usual stuff -->

   <PublishSingleFile>true</PublishSingleFile>
   <SelfContained>true</SelfContained>
   <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
   <GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
</PropertyGroup>

<ItemGroup>
   <EmbeddedResource Include="wwwroot\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
      <PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.4" />
      <!-- all your other dependencies -->
</ItemGroup>

Next, in your Program.cs:

// all the usual stuff

var builder 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@stormenergy91
Comment options

Answer selected by stormenergy91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants