To set a version for all your project at once, you can create a file named Directory.Build.props
(case-sensitive on Linux) at the root of your repository. This file contains the list of common properties of your projects:
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<!--<LangVersion>preview</LangVersion>-->
<!--<LangVersion>7.3</LangVersion>-->
</PropertyGroup>
</Project>
https://www.meziantou.net/4-ways-to-enable-the-latest-csharp-features.htm#method-4-using-a-pro
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>
If you modify these setting, you need to restart Visual Studio for the changes to take effect.
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.
I am fairly new to using ASP.Net applications so this is a bit of a newb fix
I got this error when migrating my application from ASP.Net Core Web App to ASP.Net Core Web API .
Moving my class libraries outside the main folder that contains the.sln file fixed this error for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.