You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JetBrains Rider因代码风格问题无法构建C#项目,如何解决?

问题

在JetBrains Rider中维护一个C#项目,尝试运行项目或执行测试时,出现如下编译错误:

/System.Runtime.InteropServices.RuntimeInformation.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Runtime.Intrinsics.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Runtime.Loader.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Runtime.Numerics.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Runtime.Serialization.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Runtime.Serialization.Formatters.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Runtime.Serialization.Json.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Runtime.Serialization.Primitives.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Runtime.Serialization.Xml.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Security.AccessControl.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Security.Claims.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Security.Cryptography.Algorithms.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Security.Cryptography.Cng.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Security.Cryptography.Csp.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Security.Cryptography.Encoding.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Security.Cryptography.OpenSsl.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Security.Cryptography.Primitives.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Security.Cryptography.X509Certificates.dll /reference:/home/john/.nuget/packages/microsoft.aspnetcore.app.ref/6.0.21/ref/net6.0/System.Security.Cryptography.Xml.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Security.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Security.Principal.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Security.Principal.Windows.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Security.SecureString.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.ServiceModel.Web.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.ServiceProcess.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Text.Encoding.CodePages.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Text.Encoding.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Text.Encoding.Extensions.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Text.Encodings.Web.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Text.Json.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Text.RegularExpressions.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Threading.Channels.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Threading.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Threading.Overlapped.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Threading.Tasks.Dataflow.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Threading.Tasks.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Threading.Tasks.Extensions.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Threading.Tasks.Parallel.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Threading.Thread.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Threading.ThreadPool.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Threading.Timer.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Transactions.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Transactions.Local.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.ValueTuple.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Web.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Web.HttpUtility.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Windows.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Xml.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Xml.Linq.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Xml.ReaderWriter.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Xml.Serialization.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Xml.XDocument.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Xml.XmlDocument.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Xml.XmlSerializer.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Xml.XPath.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/System.Xml.XPath.XDocument.dll /reference:/home/john/.nuget/packages/microsoft.testplatform.testhost/17.8.0-preview-23424-02/lib/netcoreapp3.1/testhost.dll /reference:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/ref/net6.0/WindowsBase.dll /reference:/home/john/.nuget/packages/xunit.abstractions/2.0.3/lib/netstandard2.0/xunit.abstractions.dll /reference:/home/john/.nuget/packages/xunit.assert/2.5.1-pre.20/lib/netstandard1.1/xunit.assert.dll /reference:/home/john/.nuget/packages/xunit.extensibility.core/2.5.1-pre.20/lib/netstandard1.1/xunit.core.dll /reference:/home/john/.nuget/packages/xunit.extensibility.execution/2.5.1-pre.20/lib/netstandard1.1/xunit.execution.dotnet.dll /debug+ /debug:portable /filealign:512 /optimize- /out:obj/Debug/net6.0/Jellyfin.Plugin.Template.dll /refout:obj/Debug/net6.0/refint/Jellyfin.Plugin.Template.dll /ruleset:../jellyfin.ruleset /resource:Configuration/configPage.html,Jellyfin.Plugin.Template.Configuration.configPage.html /target:exe /warnaserror+ /utf8output /deterministic+ /langversion:10.0 /analyzerconfig:/home/john/Projects/jellyfin-plugin-audiobook-metadata/.editorconfig /analyzerconfig:obj/Debug/net6.0/Jellyfin.Plugin.Template.GeneratedMSBuildEditorConfig.editorconfig /analyzerconfig:/usr/share/dotnet/sdk/7.0.110/Sdks/Microsoft.NET.Sdk/analyzers/build/config/analysislevel_6_all.editorconfig /analyzer:/usr/share/dotnet/sdk/7.0.110/Sdks/Microsoft.NET.Sdk/targets/../analyzers/Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll /analyzer:/usr/share/dotnet/sdk/7.0.110/Sdks/Microsoft.NET.Sdk/targets/../analyzers/Microsoft.CodeAnalysis.NetAnalyzers.dll /analyzer:/home/john/.nuget/packages/seriloganalyzer/0.15.0/analyzers/dotnet/cs/SerilogAnalyzer.dll /analyzer:/home/john/.nuget/packages/smartanalyzers.multithreadinganalyzer/1.1.31/analyzers/dotnet/cs/SmartAnalyzers.MultithreadingAnalyzer.dll /analyzer:/home/john/.nuget/packages/stylecop.analyzers.unstable/1.2.0.507/analyzers/dotnet/cs/StyleCop.Analyzers.CodeFixes.dll /analyzer:/home/john/.nuget/packages/stylecop.analyzers.unstable/1.2.0.507/analyzers/dotnet/cs/StyleCop.Analyzers.dll /analyzer:/home/john/.nuget/packages/xunit.analyzers/1.3.0-pre.13/analyzers/dotnet/cs/xunit.analyzers.dll /analyzer:/home/john/.nuget/packages/xunit.analyzers/1.3.0-pre.13/analyzers/dotnet/cs/xunit.analyzers.fixes.dll /analyzer:/home/john/.nuget/packages/microsoft.netcore.app.ref/6.0.21/analyzers/dotnet/cs/System.Text.Json.SourceGeneration.dll /analyzer:/home/john/.nuget/packages/microsoft.aspnetcore.app.ref/6.0.21/analyzers/dotnet/cs/Microsoft.AspNetCore.App.Analyzers.dll /analyzer:/home/john/.nuget/packages/microsoft.aspnetcore.app.ref/6.0.21/analyzers/dotnet/cs/Microsoft.AspNetCore.App.CodeFixes.dll /analyzer:/home/john/.nuget/packages/microsoft.aspnetcore.app.ref/6.0.21/analyzers/dotnet/roslyn4.0/cs/Microsoft.Extensions.Logging.Generators.dll AudioBookMetadata.cs Configuration/PluginConfiguration.cs MetadataSources/AudibleMetadataFetcher.cs Plugin.cs Tests/AudibleMetadataFetcherTests.cs /home/john/.nuget/packages/microsoft.net.test.sdk/17.8.0-preview-23424-02/build/netcoreapp3.1/Microsoft.NET.Test.Sdk.Program.cs "obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs" obj/Debug/net6.0/Jellyfin.Plugin.Template.AssemblyInfo.cs /warnaserror+:NU1605
0>AudibleMetadataFetcher.cs(11,14): Error CA1052 : Type 'AudibleMetadataFetcher' is a static holder type but is neither static nor NotInheritable
0>AudioBookMetadata.cs(62,12): Error SA1201 : A constructor should not follow a property
0>AudioBookMetadata.cs(48,21): Error CA1819 : Properties should not return arrays
0>MetadataFetcher.cs(21,61): Error SA1501 : Statement should not be on a single line
0>MetadataFetcher.cs(24,19): Error CA2201 : Exception type System.Exception is not sufficiently specific
0>MetadataFetcher.cs(28,19): Error CA2201 : Exception type System.Exception is not sufficiently specific
0>MetadataFetcher.cs(58,46): Error SA1503 : Braces should not be omitted
0>MetadataFetcher.cs(66,44): Error SA1503 : Braces should not be omitted
0>MetadataFetcher.cs(82,46): Error SA1501 : Statement should not be on a single line
0>MetadataFetcher.cs(73,52): Error SA1121 : Use built-in type alias
0>MetadataFetcher.cs(74,22): Error CA1305 : The behavior of 'float.Parse(string, NumberStyles)' could vary based on the current user's locale settings. Replace this call in 'MetadataFetcher.GetCommunityRating(HtmlDocument)' with a call to 'float.Parse(string, NumberStyles, IFormatProvider)'.
0>MetadataFetcher.cs(73,18): Error CA1307 : 'string.Replace(string, string?)' has a method overload that takes a 'StringComparison' parameter. Replace this call in 'Jellyfin.Plugin.Template.MetadataSources.AudibleMetadataFetcher.GetCommunityRating(HtmlAgilityPack.HtmlDocument)' with a call to 'string.Replace(string, string?, System.StringComparison)' for clarity of intent.
0>MetadataFetcher.cs(104,9): Error SA1111 : Closing parenthesis should be on line of last parameter
0>MetadataFetcher.cs(107,20): Error SA1121 : Use built-in type alias
0>MetadataFetcher.cs(107,40): Error SA1121 : Use built-in type alias
0>MetadataFetcher.cs(120,19): Error CA2201 : Exception type System.Exception is not sufficiently specific
0>AudibleMetadataFetcher.cs(109,38): Error CA1307 : 'string.Replace(string, string?)' has a method overload that takes a 'StringComparison' parameter. Replace this call in 'Jellyfin.Plugin.Template.MetadataSources.AudibleMetadataFetcher.GetIdByTitle(string)' with a call to 'string.Replace(string, string?, System.StringComparison)' for clarity of intent.
CompilerServer: server - server processed compilation - e52697c2-a65b-435f-a96f-9252973142d1
0>------- Finished building project: Jellyfin.Plugin.Template. Succeeded: False. Errors: 17. Warnings: 0
Build completed in 00:00:01.913

这些均为代码风格检测类错误,不影响功能,需设置JetBrains Rider忽略此类检测以完成项目构建。

解决方法

方法一:临时禁用编译时的警告转错误

  • 打开Rider顶部菜单栏的Run -> Edit Configurations
  • 选择目标项目或测试配置,切换到右侧Build选项卡
  • 在Before launch列表中选中Build项,点击编辑按钮(铅笔图标)
  • 取消勾选Treat warnings as errors选项,保存后重新运行项目,代码风格警告将不再阻止编译

方法二:全局调整代码分析规则级别

  • 打开Rider设置:快捷键Ctrl+Alt+S(Windows/Linux)或Cmd+,(Mac)
  • 导航到Build, Execution, Deployment -> Compiler -> C# -> Code Analysis
  • 在右侧Severity列表中,找到对应的代码风格规则(如SA开头的StyleCop规则、CA开头的微软代码分析规则)
  • 将这些规则的严重级别从Error改为`Warning
相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 09:16:59