I figured this out myself. To anyone reading this, the problem was that the Nuget package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
(which also contains the CodeAnalysis package) was the wrong version. I created a new webproject, updated the offending Nuget package right away, and the problem was solved.