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.
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>
It's working for me
<ItemGroup>
<None Include="wwwroot\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.