The accepted answer is great, I am just adding some details.
I created Directory.Build.props
file at the root of the of the repository and added it to the solution as a Solution Item. This is the content of the file:
<Project>
<PropertyGroup>
<LangVersion>7.3</LangVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
</Project>
Note 1:
If you modify these setting, you need to restart Visual Studio for the changes to take effect.
Note 2:
You would require MSBuild version 15 or higher in order to use Directory.Build.props
. To check MSBuild version, open your project file in a text editor and look for the following:
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Here, 15.0
indicates your MSBuild version, see this document if you require to upgrade your MSBuild version.