I am using ASP.NET Core 2.0 in Visual Studio 2017.
My site works fine when I hit debug in IIS Express. But when deploying the site to IIS server, not all the folders and files in wwwroot are deployed. I have looked at the .csproj file, but I don't know how to make sure it deploys all files and folders.
Adding wwwroot (webroot) folder in ASP.NET Core: In order to add the wwwroot folder, right-click on the project and then select add => new folder option and then provide the folder name as wwwroot.
The path of the wwwroot folder is accessed using the interfaces IHostingEnvironment (. Net Core 2.0) and IWebHostEnvironment (. Net Core 3.0) in ASP.Net Core. The IHostingEnvironment is an interface for .
The wwwroot folder is new in ASP.NET 5 to store all of the static files in your project. Any files including HTML files, CSS files, image files, and JavaScript files which are sent to the user's browser should be stored inside this folder.
Right-click the Web application you want more information about, such as SharePoint (80), and then click Properties. In the Default Web Site Properties window, click the Home Directory tab. The Local Path field in this tab shows the Web application root folder.
I solved the issue. The solution is to edit the .csproj file.
Remove all the ItemGroup
tags related to wwwroot and then add this one:
<ItemGroup>
<None Include="wwwroot\*" />
</ItemGroup>
The asterisk will include all the subfolders and files.
<PropertyGroup>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
</PropertyGroup>
<ItemGroup>
<Content Include="wwwroot\**\*">
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</Content>
</ItemGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With