Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Some files in "wwwroot" folder are not published in ASP.NET Core web deploy

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.

like image 794
kudzai zishumba Avatar asked Jul 14 '18 17:07

kudzai zishumba


People also ask

How can add wwwroot folder in asp net core API?

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.

Where is the Wwwroot folder in asp net core?

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 .

What file types should be placed in the wwwroot folder?

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.

Where can I find wwwroot 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.


2 Answers

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.

like image 194
kudzai zishumba Avatar answered Sep 19 '22 19:09

kudzai zishumba


<PropertyGroup>

<EnableDefaultContentItems>false</EnableDefaultContentItems>
</PropertyGroup>
<ItemGroup>
    <Content Include="wwwroot\**\*">
      <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </Content>
</ItemGroup>
like image 36
user3307 Avatar answered Sep 21 '22 19:09

user3307