In my case rather than adding the RuntimeIdentifier, the issue was that the CI/CD pipeline wasn't doing a clean before building so it had old obj folders from previous builds. Turning the clean on first in Azure DevOps was enough to solve it.