有没有一种方法可以用.NET核心在特定的子目录中抑制MSBUILD警告?
我会从编译我的ASP.NET 6剃须刀项目中获取警告,这些错误主要链接到我的迁移文件夹中缺乏<摘要>
注释。
我尝试将以下directory.build.props
文件添加到我的。\ data \迁移
文件夹,因为我发现某个地方可以抑制该文件夹中的警告。
<Project>
<PropertyGroup>
<DisabledWarnings>CS1591;IDE0161</DisabledWarnings>
</PropertyGroup>
</Project>
但是,我一直遇到相同的错误:
1591: Missing XML comment for publicly visible type or member 'CorrectedSpellingOf2FAEnabled' [<redacted>\3moons.csproj]
<redacted>\Data\Migrations\20220526151631_CorrectedSpellingOf2FAEnabled.cs(9,33): warning CS
1591: Missing XML comment for publicly visible type or member 'CorrectedSpellingOf2FAEnabled.Up(MigrationBuilder)' [<redacted>\3moons.csproj]
...
我也试图编辑警告标签:
<PropertyGroup>
<DisabledWarnings>1591;161</DisabledWarnings>
</PropertyGroup>
a,这是行不通的。警告仍然存在。
作为参考,我的.csproj
文件如下:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Minustar.Website</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.5" />
<PackageReference Include="Westwind.AspNetCore.Markdown" Version="3.8.0" />
</ItemGroup>
</Project>
我的直觉是,可以直接从.csproj
文件中抑制这些警告或任何其他警告,但我不确定如何和何处。
提前,谢谢。
PS:
我还尝试了@Ryan Wilson的建议,以在警告抑制页面上阅读。
[assembly: SuppressMessage("Compiler", "CS1591", Target="N:Minustar.Website.Data:migrations", Scope="namespaceanddescendants")]
毫无用处,我仍然在编译器输出中获取消息,VSCODE和VS2022仍然将问题列为警告。但是,它似乎确实适用于[puspressMessage(“编译器”,“ IDE0161”)]
(这建议使用文件窃取的命名空间声明,而不是EF核心迁移工具emmits。)
我是我AM仍然坚信,可以说,可以在没有任何第三方工具的情况下实现预期的结果。但是,解决方案完全逃避了我。
I am gettings warnings from compiling my ASP.Net 6 Razor project, errors that are mainly linked to the lack of <summary>
comments in my migrations folder.
I have tried to add the following Directory.Build.props
file to my .\Data\Migrations
folder as I had found somewhere that I could suppress warnings in that folder.
<Project>
<PropertyGroup>
<DisabledWarnings>CS1591;IDE0161</DisabledWarnings>
</PropertyGroup>
</Project>
Yet, I keep getting the same errors:
1591: Missing XML comment for publicly visible type or member 'CorrectedSpellingOf2FAEnabled' [<redacted>\3moons.csproj]
<redacted>\Data\Migrations\20220526151631_CorrectedSpellingOf2FAEnabled.cs(9,33): warning CS
1591: Missing XML comment for publicly visible type or member 'CorrectedSpellingOf2FAEnabled.Up(MigrationBuilder)' [<redacted>\3moons.csproj]
...
I have also tried to redact the warning labels:
<PropertyGroup>
<DisabledWarnings>1591;161</DisabledWarnings>
</PropertyGroup>
Alas, this doesn't work. The warnings are still present.
For reference my .csproj
file is as follows:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Minustar.Website</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.5" />
<PackageReference Include="Westwind.AspNetCore.Markdown" Version="3.8.0" />
</ItemGroup>
</Project>
My intuition is that there could be a way to suppress those warning, or any other, directly from the .csproj
file but I am unsure how and where.
In advance, thank you.
PS:
I have also tried this, on @Ryan Wilson's suggestion, to read on the warning suppression page.
[assembly: SuppressMessage("Compiler", "CS1591", Target="N:Minustar.Website.Data:migrations", Scope="namespaceanddescendants")]
To no avail, I still get the messages in the compiler output, and both VSCode and VS2022 still list the issues as a warning. It did however seem to work for [SuppressMessage("Compiler", "IDE0161")]
(this one suggests the use file-scoped namespace declaration instead of what the EF Core migrations tool emmits.)
I am still convinced that it is possible to achieve the desired result out-of-the box, so to speak, without any 3rd party tools; however, the solution evades me entirely. ????
PPS: Disabling the GenerateDocumenationFile
option is preferably not an option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论