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

15,072

Solution 1

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.

Solution 2

<PropertyGroup>

<EnableDefaultContentItems>false</EnableDefaultContentItems>
</PropertyGroup>
<ItemGroup>
    <Content Include="wwwroot\**\*">
      <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </Content>
</ItemGroup>

Solution 3

It's working for me

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

Solution 4

Notice to myself:

when you stumble over this issue again (like it happened twice already), double check whether the wwwroot content is really committed to git, and the build agent has the files to publish, or if there is an exclusion of wwwroot in (any) .gitignore

:facepalm:

Share:
15,072

Related videos on Youtube

kudzai zishumba
Author by

kudzai zishumba

Updated on February 26, 2022

Comments

  • kudzai zishumba
    kudzai zishumba about 2 years

    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.

    • rene
      rene almost 6 years
      are the file and folders you need part of the .csproj?
    • Marcus Höglund
      Marcus Höglund almost 6 years
      How do you deploy?
  • kudzai zishumba
    kudzai zishumba almost 6 years
    all the files in the wwwroot folder will be included except for empty files
  • Dan Gifford
    Dan Gifford over 4 years
    If you remove all the other itemgroup tags, won't other items that were meant to be included end up NOT in the build?
  • A X
    A X about 4 years
    Why is the element named "None" and not "Content"?