We have an issue with Visual Studio 2019 found when trying to pre-compile our ASP.Net project during publish. We got errors such as:
error CS1056: Unexpected character '$'
When I look at the view, it is using string interpolation.
All the projects in this solution are set to target full .Net Framework 4.6.1. From what I read, that should default to C# 7.3 compiler.
I have updated the DomCompiler and Compiler packages to version 3.6.0. In the web.config I tried to set c# version to both default and 7 specifically. The error occurs no matter which one is used.
I also tried to add LangVersion to the .csproj file and specify 7, but that didn't work either.
If we deploy not pre-compiled these views work, so the run time on the server is usually the correct c# compiler version. This is only a dev time and build time issue.

Visual Studio 2019
Visual Studio 2019 chooses the language version by default:
If you want to override the language version you have 3 options:
The first option seems to achieve your goal, open the project file in your favorite text editor and add the language version, e.g:
MyProject.csproj
Visual Studio 2017
Change language version for all of the projects at one go
If you have several projects in your solution and you want to create a configuration to change the language version for all the projects at one go, then you need to create a file name
Directory.Build.propsat the root of your repository. You can configure the language version in this file, for example:Directory.Build.props
See this question for detailed explanation.