Gitlab CI 由于编译警告而失败

问题描述 投票:0回答:1

我使用 Nuke 创建了一个 CI 管道来构建我的项目。在此阶段,项目会抛出一些我想忽略的警告,但 CI 将它们视为错误并失败。我想抑制这种行为。我怎样才能做到这一点?这是我的日志。

2:54:47 [INF] > /usr/bin/dotnet build Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj --configuration Release
12:54:47 [DBG] MSBuild version 17.9.8+b34f75857 for .NET
12:54:47 [DBG]   Determining projects to restore...
12:54:48 [DBG]   All projects are up-to-date for restore.
12:54:50 [DBG]   Hlc.Contracts.Core -> /builds/hlc/core/Contracts/Hlc.Contracts.Core/bin/Release/net6.0/Hlc.Contracts.Core.dll
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/Client/AsyncTcpClient.cs(34,40): error CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/LlcTcp/LlcTcpClientDev.cs(91,23): error CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/LlcTcp/LlcTcpClientDev.cs(44,43): error CS8618: Non-nullable field '_handler' must contain a non-null value when exiting constructor. Consider declaring the field as nullable. [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/LlcTcp/LlcTcpClientDev.cs(62,19): error CS8618: Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/LlcTcp/LlcTcpClientDev.cs(63,23): error CS8618: Non-nullable property 'RemoteEndpoint' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/LlcTcp/LlcTcpClientDev.cs(44,43): error CS0649: Field 'LlcTcpClient._handler' is never assigned to, and will always have its default value null [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/LlcTcp/LlcTcpClientDev.cs(58,17): error CS0414: The field 'LlcTcpClient._reconnectionAttempts' is assigned but its value is never used [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [DBG] 
12:54:50 [DBG] Build FAILED.
12:54:50 [DBG] 
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/Client/AsyncTcpClient.cs(34,40): error CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/LlcTcp/LlcTcpClientDev.cs(91,23): error CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/LlcTcp/LlcTcpClientDev.cs(44,43): error CS8618: Non-nullable field '_handler' must contain a non-null value when exiting constructor. Consider declaring the field as nullable. [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/LlcTcp/LlcTcpClientDev.cs(62,19): error CS8618: Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/LlcTcp/LlcTcpClientDev.cs(63,23): error CS8618: Non-nullable property 'RemoteEndpoint' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/LlcTcp/LlcTcpClientDev.cs(44,43): error CS0649: Field 'LlcTcpClient._handler' is never assigned to, and will always have its default value null [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [ERR] /builds/hlc/core/Contracts/Hlc.Contracts.Tools/Tcp/LlcTcp/LlcTcpClientDev.cs(58,17): error CS0414: The field 'LlcTcpClient._reconnectionAttempts' is assigned but its value is never used [/builds/hlc/core/Contracts/Hlc.Contracts.Tools/Hlc.Contracts.Tools.csproj]
12:54:50 [DBG]     0 Warning(s)
12:54:50 [DBG]     7 Error(s)
12:54:50 [DBG] 
12:54:50 [DBG] Time Elapsed 00:00:03.38
12:54:50 [ERR] Target Compile has thrown an exception
c# gitlab continuous-integration dotnetnuke
1个回答
0
投票

您需要将 Directory.Build.props 文件中的标记更改为 false,然后一切都会正常工作。此错误是 Nuke 特有的。

© www.soinside.com 2019 - 2024. All rights reserved.