Improve reliability of WarningsAsErrors replacement (#72070)
authorLevi Broderick <GrabYourPitchforks@users.noreply.github.com>
Sat, 23 Jul 2022 07:50:02 +0000 (00:50 -0700)
committerGitHub <noreply@github.com>
Sat, 23 Jul 2022 07:50:02 +0000 (09:50 +0200)
* Improve reliability of WarningsAsErrors replacement

* PR feedback

Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
src/libraries/Directory.Build.targets

index 090f6d3..9869891 100644 (file)
          SYSLIB0036: Regex.CompileToAssembly
     -->
     <NoWarn Condition="'$(IsPartialFacadeAssembly)' == 'true'">$(NoWarn);SYSLIB0003;SYSLIB0004;SYSLIB0015;SYSLIB0017;SYSLIB0021;SYSLIB0022;SYSLIB0023;SYSLIB0025;SYSLIB0032;SYSLIB0036</NoWarn>
-    <!-- Reset these properties back to blank, since they are defaulted by Microsoft.NET.Sdk -->
-    <WarningsAsErrors Condition="'$(WarningsAsErrors)' == 'NU1605'" />
+    <!-- Microsoft.NET.Sdk enables some warnings as errors out of the box.
+         We want to remove some items from this list so they don't fail the build.
+         Can't use 'WarningsNotAsErrors' element because vbproj doesn't honor it.
+         Items to remove:
+         NU1605: Package downgrade detected
+    -->
+    <WarningsAsErrors>$(WarningsAsErrors.Replace('NU1605', ''))</WarningsAsErrors>
 
     <IsRuntimeAndReferenceAssembly Condition="'$(IsRuntimeAndReferenceAssembly)' == '' and
                                               '$(IsSourceProject)' == 'true' and