I had this issue and for me, it was because my bin folder was included in my project in Visual Studio. I removed all references to <Content Include="bin\..."/> in my .csproj file and the publish started working after that.