dotnet publish fails due to a build error that doesn't happen when I run just dotnet build - C#