From 4420a7d262edc5211643b2e93a6a9d2e672f3982 Mon Sep 17 00:00:00 2001
From: Doug Bunting <6431421+dougbu@users.noreply.github.com>
Date: Tue, 19 May 2020 15:51:34 -0700
Subject: [PATCH] Small fixes (#21982)

* Restore default "/bl" setting if `$BinaryLog`

nits:
- remove extra configure-toolset.ps1|sh imports
- remove duplicate `/v:$verbosity` addition to `msbuild` command line from build.sh

* Correct the feeds to match latest recommendations
---
 NuGet.config |  4 +---
 build.ps1    | 20 ++++++++++----------
 build.sh     | 26 ++++++++++++++++----------
 3 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/NuGet.config b/NuGet.config
index d12badea786..94e12ce1b49 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -2,14 +2,12 @@
 <configuration>
   <packageSources>
     <clear />
-    <add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
     <add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
+    <add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
     <add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
     <add key="dotnet5-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5-transport/nuget/v3/index.json" />
     <add key="roslyn" value="https://dotnet.myget.org/F/roslyn/api/v3/index.json" />
     <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
-    <add key="aspnetcore-dev" value="https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json" />
-    <add key="aspnetcore-tools" value="https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json" />
     <add key="roslyn-tools" value="https://dotnet.myget.org/F/roslyn-tools/api/v3/index.json" />
     <!-- Used for the SiteExtension 3.1 bits that are included in the 5.0 build -->
     <add key="dotnet31-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet3.1-transport/nuget/v3/index.json" />
diff --git a/build.ps1 b/build.ps1
index 0ac6c0627a0..37f57517bf0 100644
--- a/build.ps1
+++ b/build.ps1
@@ -253,9 +253,7 @@ $RunRestore = if ($NoRestore) { $false }
 # Target selection
 $MSBuildArguments += "/p:Restore=$RunRestore"
 $MSBuildArguments += "/p:Build=$RunBuild"
-if (-not $RunBuild) {
-    $MSBuildArguments += "/p:NoBuild=true"
-}
+if (-not $RunBuild) { $MSBuildArguments += "/p:NoBuild=true" }
 $MSBuildArguments += "/p:Pack=$Pack"
 $MSBuildArguments += "/p:Test=$Test"
 $MSBuildArguments += "/p:Sign=$Sign"
@@ -364,18 +362,20 @@ Remove-Item variable:global:_MSBuildExe -ea Ignore
 # Import Arcade
 . "$PSScriptRoot/eng/common/tools.ps1"
 
+# Add default .binlog location if not already on the command line. tools.ps1 does not handle this; it just checks
+# $BinaryLog, $CI and $ExcludeCIBinarylog values for an error case. But tools.ps1 provides a nice function to help.
+if ($BinaryLog) {
+    $bl = GetMSBuildBinaryLogCommandLineArgument($MSBuildArguments)
+    if (-not $bl) {
+        $MSBuildArguments += "/bl:" + (Join-Path $LogDir "Build.binlog")
+    }
+}
+
 # Capture MSBuild crash logs
 $env:MSBUILDDEBUGPATH = $LogDir
 
 $local:exit_code = $null
 try {
-    # Import custom tools configuration, if present in the repo.
-    # Note: Import in global scope so that the script set top-level variables without qualification.
-    $configureToolsetScript = Join-Path $EngRoot "configure-toolset.ps1"
-    if (Test-Path $configureToolsetScript) {
-      . $configureToolsetScript
-    }
-
     # Set this global property so Arcade will always initialize the toolset. The error message you get when you build on a clean machine
     # with -norestore is not obvious about what to do to fix it. As initialization takes very little time, we think always initializing
     # the toolset is a better default behavior.
diff --git a/build.sh b/build.sh
index 97c3750bc76..cdc6ad31884 100755
--- a/build.sh
+++ b/build.sh
@@ -288,10 +288,6 @@ if [ -z "$configuration" ]; then
 fi
 msbuild_args[${#msbuild_args[*]}]="-p:Configuration=$configuration"
 
-# Set verbosity
-echo "Setting msbuild verbosity to $verbosity"
-msbuild_args[${#msbuild_args[*]}]="-verbosity:$verbosity"
-
 # Set up additional runtime args
 toolset_build_args=()
 if [ ! -z "$dotnet_runtime_source_feed$dotnet_runtime_source_feed_key" ]; then
@@ -328,15 +324,25 @@ fi
 # Import Arcade
 . "$DIR/eng/common/tools.sh"
 
+# Add default .binlog location if not already on the command line. tools.sh does not handle this; it just checks
+# $binary_log, $ci and $exclude_ci_binary_log values for an error case.
+if [[ "$binary_log" == true ]]; then
+    found=false
+    for arg in "${msbuild_args[@]}"; do
+        opt="$(echo "${arg/#--/-}" | awk '{print tolower($0)}')"
+        if [[ "$opt" == [-/]bl:* || "$opt" == [-/]binarylogger:* ]]; then
+            found=true
+            break
+        fi
+    done
+    if [[ "$found" == false ]]; then
+        msbuild_args[${#msbuild_args[*]}]="/bl:$log_dir/Build.binlog"
+    fi
+fi
+
 # Capture MSBuild crash logs
 export MSBUILDDEBUGPATH="$log_dir"
 
-# Import custom tools configuration, if present in the repo.
-configure_toolset_script="$eng_root/configure-toolset.sh"
-if [[ -a "$configure_toolset_script" ]]; then
-  . "$configure_toolset_script"
-fi
-
 # Set this global property so Arcade will always initialize the toolset. The error message you get when you build on a clean machine
 # with -norestore is not obvious about what to do to fix it. As initialization takes very little time, we think always initializing
 # the toolset is a better default behavior.
-- 
GitLab