Quick and easy fix for MSBuild errors.
This error had me stumped for a while. The first thing I did was to update the Microsoft.Net.Compilers through NuGet, which didn’t fix the problem. If you double click on the error message, it will open Microsoft.Net.Compilers.props. In this file you will find
<Error Text="Microsoft.Net.Compilers is only supported on MSBuild v16.3 and above"
Condition="'$(MSBuildToolsVersion)' < '16.3'">
Comment out this section with <!-- at the start and --> and the end. Your code will now compile without any problems.