.net-6.0release-builds

images folder is not included in the release build


This may be another simple question. I did my research and I couldn't find a way to resolve the issue. I have .net 6 web api project. the project folder does not have a wwwroot folder. I placed images folder within the project root. i.e. src\WebUI\images\ where src\WebUI\WebUI.csproj exists. these images are being used only for email templates.

I had no issues with the development environment. but when I try to deploy files to the server, I noticed that the image folder was not included in the release build.

I have following middleware in program.cs

app.UseStaticFiles(new StaticFileOptions()
{
    FileProvider = new PhysicalFileProvider(Path.Combine(app.Environment.ContentRootPath, "images")),
    RequestPath = "/images"
});

Could someone please tell me what am I missing here?


Solution

  • I've just realized after posting the question that I need to add following to my src\WebUI\WebUI.csproj

    <ItemGroup>
      <Content Include="images\*">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </Content>
    </ItemGroup>