We have a custom folder under wwwroot named Contents with some inner folders shaping a structure for organizing later uploadable files, in the publish mode it is not deployed (On local or server)
Here is part of our code which you may be interested about:
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "Contents")),
RequestPath = "/Contents"
});
Any suggestions and solutions? Any idea why it is not deployed?
Update:
In .csProj we have this:
<ItemGroup>
<Folder Include="Contents\H2X\" />
<Folder Include="ServerContent\H123\" />
</ItemGroup>
We have H2X.publishSettings file, which is generated by the server and contains some of our credentials.
msdeploySite="213"
destinationAppUrl="123"
profileName="Default Settings"
publishMethod="MSDeploy" userName="123"
AllowUntrustedCertificate="True"
Is there anything missed?
I was a bit away from development for a while, now my developer seems stuck with it, wanted to help him.
If the Contents folder inside the wwwroot then add
<Content Include="wwwroot\**\*" CopyToPublishDirectory="PreserveNewest" />
and you no need to configure the Contents folder as static file provider in Startup.cs, above line will include all sub folders and files inside wwwroot.
And if the Contents folder outside of wwwroot then add
<Content Include="Contents\**\*" CopyToPublishDirectory="PreserveNewest" />
and you need to configure the Contents folder as static file provider in Startup.cs