[英]Removing the default c# console application template code in visual studio 2022
在 Visual Studio 中為 .net 6.0 c# 創建控制台應用程序項目時,它會生成以下代碼:
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
與以前的 c# 版本相反,項目模板創建了一些有用的樣板文件,但這些都沒有任何幫助。
是否可以配置 Visual Studio 2022,以便在 .net 6.0 中為 c# 創建控制台應用程序時,文件將完全為空?
顯然,在創建新解決方案時,必須在解決方案創建的最后一步選擇 .Net 版本時選中“不使用頂級語句”復選框。 不完全是默認設置,但至少有這個選項。
來自官方文檔:創建 .NET 5 項目,然后通過編輯項目文件將框架更改為 .NET 6
https://docs.microsoft.com/nl-nl/dotnet/core/tutorials/top-level-templates#use-the-old-program-style
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFramework>net5.0</TargetFramework>
+ <TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
</PropertyGroup>
</Project>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.