From 39f18c0f14f5c38a7a78a78a1f2cec439b317172 Mon Sep 17 00:00:00 2001
From: Pranav K <prkrishn@hotmail.com>
Date: Fri, 7 Aug 2020 15:20:12 -0700
Subject: [PATCH] Use IgnoreStandardErrorWarningFormat more extensively in
 Npm.Common.targets (#24682)

This is a possible fix for the 'Waiting for the other yarn instance to finish' error that appears during our CI builds

This property is configured in [CSharp.Common.props](https://github.com/dotnet/aspnetcore/blob/master/eng/targets/CSharp.Common.props#L57-L61) but not the NPM one.
However it is used in exactly one place in the [targets](https://github.com/dotnet/aspnetcore/blob/master/eng/targets/Npm.Common.targets#L45)

This change updates the target to use it more consistently and to declare it
it in the props file
---
 eng/targets/Npm.Common.props   | 6 ++++++
 eng/targets/Npm.Common.targets | 8 ++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/eng/targets/Npm.Common.props b/eng/targets/Npm.Common.props
index 6caffd7d56d..fc5390a3344 100644
--- a/eng/targets/Npm.Common.props
+++ b/eng/targets/Npm.Common.props
@@ -5,4 +5,10 @@
     <Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
     <PackOnBuild>false</PackOnBuild>
   </PropertyGroup>
+
+  <!-- Properties to control how we handle warnings when using the tasks provided by the Yarn MSBuild SDK -->
+  <PropertyGroup>
+    <IgnoreYarnWarnings>false</IgnoreYarnWarnings>
+    <IgnoreYarnWarnings Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</IgnoreYarnWarnings>
+  </PropertyGroup>
 </Project>
diff --git a/eng/targets/Npm.Common.targets b/eng/targets/Npm.Common.targets
index f216bf5f9c0..10ff37ab61e 100644
--- a/eng/targets/Npm.Common.targets
+++ b/eng/targets/Npm.Common.targets
@@ -76,7 +76,7 @@
     DependsOnTargets="GetBuildInputCacheFile"
     Inputs="@(TSFiles);$(BaseIntermediateOutputPath)tsfiles.cache"
     Outputs="@(BuildOutputFiles)">
-    <Yarn Command="$(NpmBuildArgs)" StandardOutputImportance="High" StandardErrorImportance="High" />
+    <Yarn Command="$(NpmBuildArgs)" StandardOutputImportance="High" StandardErrorImportance="High" IgnoreStandardErrorWarningFormat="$(IgnoreYarnWarnings)" />
     <WriteLinesToFile Overwrite="true" File="$(BaseIntermediateOutputPath)build-sentinel" />
   </Target>
 
@@ -102,9 +102,9 @@
 
     <Copy SourceFiles="$(PackageJson)" DestinationFiles="$(_BackupPackageJson)" />
 
-    <Yarn Command="version --no-git-tag-version --new-version $(PackageVersion)" />
+    <Yarn Command="version --no-git-tag-version --new-version $(PackageVersion)" IgnoreStandardErrorWarningFormat="$(IgnoreYarnWarnings)" />
     <Exec Command="node &quot;$(MSBuildThisFileDirectory)..\scripts\update-packagejson-links.js&quot; &quot;$(PackageJson)&quot; $(PackageVersion)" />
-    <Yarn Command="pack --filename $(PackageFileName)" />
+    <Yarn Command="pack --filename $(PackageFileName)" IgnoreStandardErrorWarningFormat="$(IgnoreYarnWarnings)" />
 
     <Move SourceFiles="$(_PackageTargetPath)" DestinationFolder="$(PackageOutputPath)" />
     <Message Importance="High" Text="$(MSBuildProjectName) -> $(_PackageTargetPath)" />
@@ -122,7 +122,7 @@
   <Target Name="Test" Condition="'$(IsTestProject)' == 'true' AND '$(SkipTests)' != 'true'">
     <Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Test" />
     <Message Importance="High" Text="Running npm tests for $(MSBuildProjectName)" />
-    <Yarn Command="$(NpmTestArgs)" StandardOutputImportance="High" StandardErrorImportance="High" />
+    <Yarn Command="$(NpmTestArgs)" StandardOutputImportance="High" StandardErrorImportance="High" IgnoreStandardErrorWarningFormat="$(IgnoreYarnWarnings)" />
   </Target>
 
 </Project>
-- 
GitLab