From d7d154d7e25b5a4472b75c963b0a73dc23f5fb9b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Strehovsk=C3=BD?= Date: Wed, 1 Feb 2023 01:25:08 +0900 Subject: [PATCH] Allow overriding WarningsAsErrors policy with an env variable (#81402) * Allow overriding WarningsAsErrors policy with an env variable Placing `WarningsAsErrors=false` in an environment variable will disable the repo policy to waste people's time with frivolous warnings in their inner dev loop. * Update build.sh --- Directory.Build.props | 2 +- eng/build.ps1 | 4 ++++ eng/build.sh | 4 ++++ src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj | 1 - src/coreclr/nativeaot/Directory.Build.props | 1 - src/coreclr/tools/aot/ILCompiler/repro/repro.csproj | 1 - src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj | 1 - 7 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index f3f56ce..9e8b408 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -318,7 +318,7 @@ latest strict;nullablePublicOnly - true + true $(NoWarn),CS8969 diff --git a/eng/build.ps1 b/eng/build.ps1 index a6a3941..aed36f5 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -267,6 +267,10 @@ foreach ($argument in $PSBoundParameters.Keys) } } +if ($env:TreatWarningsAsErrors -eq 'false') { + $arguments += " -warnAsError 0" +} + # Disable targeting pack caching as we reference a partially constructed targeting pack and update it later. # The later changes are ignored when using the cache. $env:DOTNETSDK_ALLOW_TARGETING_PACK_CACHING=0 diff --git a/eng/build.sh b/eng/build.sh index 215d93f..1147ec2 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -512,6 +512,10 @@ if [[ "$os" == "wasi" ]]; then arch=wasm fi +if [[ "${TreatWarningsAsErrors:-}" == "false" ]]; then + arguments="$arguments -warnAsError 0" +fi + initDistroRid $os $arch $crossBuild $portableBuild # Disable targeting pack caching as we reference a partially constructed targeting pack and update it later. diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj index 1671023..5ee434a 100644 --- a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -46,7 +46,6 @@ $(ProductVersion) $(ProductVersion) - true $(NoWarn),0419,0649,CA2249,CA1830 enable diff --git a/src/coreclr/nativeaot/Directory.Build.props b/src/coreclr/nativeaot/Directory.Build.props index 94ee136..275f039 100644 --- a/src/coreclr/nativeaot/Directory.Build.props +++ b/src/coreclr/nativeaot/Directory.Build.props @@ -25,7 +25,6 @@ false v4.0.30319 - true $(NoWarn),0419,0649,CA2249,CA1830 diff --git a/src/coreclr/tools/aot/ILCompiler/repro/repro.csproj b/src/coreclr/tools/aot/ILCompiler/repro/repro.csproj index f2d7f5c..48b2709 100644 --- a/src/coreclr/tools/aot/ILCompiler/repro/repro.csproj +++ b/src/coreclr/tools/aot/ILCompiler/repro/repro.csproj @@ -9,7 +9,6 @@ linux-x64;win-x64;osx-x64;freebsd-x64 Debug;Release;Checked true - false false diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index fd6ada4..db2a7d2 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -33,7 +33,6 @@ $(ProductVersion) $(ProductVersion) - true $(NoWarn),0419,0649 enable -- 2.7.4