Kiruahxh
Kiruahxh

Reputation: 2035

Hide dotnet linker warning

I have updated a linux C# project to use .NET6, however Oracle package has not been updated yet and generates warnings when I publish the project:

dotnet publish worker -c Release --runtime linux-x64 --self-contained -p:PublishTrimmed=true -p:SuppressTrimAnalysisWarnings=true -p:PublishSingleFile=true /p:DebugType=None /p:DebugSymbols=false -o bin
...
ILLink : warning IL2105: System.String Oracle.ManagedDataAccess.Client.OracleConnection::ConnectionString(): Type 'System.Drawing.Design.UITypeEditor' was not found in the caller assembly nor in the base library. Type name strings used for dynamically accessing a type should be assembly qualified. [/tmp/worker/worker.csproj]

I didn't find a way to disable these annoying warnings (for now I don't care if Oracle connections don't work, but I don't want to remove Oracle library references if it builds fine).

Upvotes: 1

Views: 312

Answers (1)

Simon Mattes
Simon Mattes

Reputation: 5234

In your .csproj file in a <PropertyGroup>, insert <ILLinkWarningLevel>4</ILLinkWarningLevel> and compile. Setting it to a higher warning level (such as 5) restores the warnings.

Sources: Trimming options and C# Compiler Options

Upvotes: 2

Related Questions