kudzai zishumba
kudzai zishumba

Reputation: 732

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.

Upvotes: 34

Views: 39171

Answers (4)

Marc Wittke
Marc Wittke

Reputation: 3154

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:

Upvotes: 5

Surbowl
Surbowl

Reputation: 249

It's working for me

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

Upvotes: 24

user3307
user3307

Reputation: 173

<PropertyGroup>

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

Upvotes: 16

kudzai zishumba
kudzai zishumba

Reputation: 732

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.

Upvotes: 19

Related Questions