How to change C# Language Version for all of the projects in my solution in one place?(如何在一处更改我的解决方案中所有项目的 C# 语言版本?)
问题描述
我有一个包含 20 个项目的解决方案,我想将所有项目的 C# 版本更改为 C# 7.3
I have a solution with 20 projects, I want to change the C# version for all of them to C# 7.3
有没有一种方法可以一次更改所有项目的版本?我知道我可以从 Project 的 Properties 更改 Language Version,但我不想重复 20 次.
Is there a way that I could change all project's version at one go? I know I can change the Language Version from Project's Properties, but I don't want to repeat this 20 times.
推荐答案
要一次为所有项目设置版本,您可以创建一个名为 Directory.Build.props 的文件(区分大小写在 Linux 上)位于存储库的根目录.此文件包含项目的常见属性列表:
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
这篇关于如何在一处更改我的解决方案中所有项目的 C# 语言版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在一处更改我的解决方案中所有项目的 C# 语言版本?
基础教程推荐
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
