From f8a9d69606c8f59ec02adccaab97526f7d968f5b Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 10 Jun 2021 09:54:56 +0200 Subject: [PATCH 01/11] Normalize RepoRoot to include trailing slash The Arcade SDK defines the RepoRoot repository [with a trailing slash](https://github.com/dotnet/arcade/blob/e81d8c9bdc1de22623657afb23fab210dd04ca82/src/Microsoft.DotNet.Arcade.Sdk/tools/RepoLayout.props#L23) but the build scripts (build.ps1 and build.sh) pass in the property without a trailing slash which makes the use of it inconsistent and led to this source build patch: https://github.com/dotnet/runtime/blob/23e4735e5cc9956d3f3b351a252f0b1622a14cec/eng/source-build-patches/0004-Add-trailing-path-separator-to-repo_root.patch. Normalizing the variable in the build scripts so that the property always contains the trailing slash. --- eng/common/tools.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index bc4eabe5211..0a125266a7c 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -774,7 +774,7 @@ function Get-Darc($version) { . $PSScriptRoot\pipeline-logging-functions.ps1 -$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..\..') +$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..\..\') $EngRoot = Resolve-Path (Join-Path $PSScriptRoot '..') $ArtifactsDir = Join-Path $RepoRoot 'artifacts' $ToolsetDir = Join-Path $ArtifactsDir 'toolset' From 5684d9c98de4385626cd04e5f78b431d02209aa8 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 10 Jun 2021 10:04:27 +0200 Subject: [PATCH 02/11] Create tools.sh --- eng/common/tools.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eng/common/tools.sh b/eng/common/tools.sh index 5fad1846e5a..c0c62d92465 100755 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -484,14 +484,14 @@ _script_dir=`dirname "$_ResolvePath"` . "$_script_dir/pipeline-logging-functions.sh" eng_root=`cd -P "$_script_dir/.." && pwd` -repo_root=`cd -P "$_script_dir/../.." && pwd` -artifacts_dir="$repo_root/artifacts" +repo_root=`cd -P "$_script_dir/../../" && pwd` +artifacts_dir="${repo_root}artifacts" toolset_dir="$artifacts_dir/toolset" -tools_dir="$repo_root/.tools" +tools_dir="${repo_root}.tools" log_dir="$artifacts_dir/log/$configuration" temp_dir="$artifacts_dir/tmp/$configuration" -global_json_file="$repo_root/global.json" +global_json_file="${repo_root}global.json" # determine if global.json contains a "runtimes" entry global_json_has_runtimes=false if command -v jq &> /dev/null; then @@ -504,7 +504,7 @@ fi # HOME may not be defined in some scenarios, but it is required by NuGet if [[ -z $HOME ]]; then - export HOME="$repo_root/artifacts/.home/" + export HOME="${repo_root}artifacts/.home/" mkdir -p "$HOME" fi From 361065b9f86c60662c5c0bb34bc6f09ed307d0b9 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 10 Jun 2021 10:05:29 +0200 Subject: [PATCH 03/11] Update dotnet-install.sh --- eng/common/dotnet-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/dotnet-install.sh b/eng/common/dotnet-install.sh index d6efeb44340..fdfeea66e7d 100755 --- a/eng/common/dotnet-install.sh +++ b/eng/common/dotnet-install.sh @@ -70,7 +70,7 @@ case $cpuname in ;; esac -dotnetRoot="$repo_root/.dotnet" +dotnetRoot="${repo_root}.dotnet" if [[ $architecture != "" ]] && [[ $architecture != $buildarch ]]; then dotnetRoot="$dotnetRoot/$architecture" fi From d620c0a170496231f89dfaf45c39076ceb1b903d Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 10 Jun 2021 10:06:01 +0200 Subject: [PATCH 04/11] Update internal-feed-operations.sh --- eng/common/internal-feed-operations.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/internal-feed-operations.sh b/eng/common/internal-feed-operations.sh index e2233e78122..9378223ba09 100755 --- a/eng/common/internal-feed-operations.sh +++ b/eng/common/internal-feed-operations.sh @@ -39,7 +39,7 @@ function SetupCredProvider { # Then, we set the 'VSS_NUGET_EXTERNAL_FEED_ENDPOINTS' environment variable to restore from the stable # feeds successfully - local nugetConfigPath="$repo_root/NuGet.config" + local nugetConfigPath="{$repo_root}NuGet.config" if [ ! "$nugetConfigPath" ]; then Write-PipelineTelemetryError -category 'Build' "NuGet.config file not found in repo's root!" From b8dde6767c1fc134550d4e28632beee524719cf5 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 10 Jun 2021 10:09:38 +0200 Subject: [PATCH 05/11] Update internal-feed-operations.ps1 --- eng/common/internal-feed-operations.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/common/internal-feed-operations.ps1 b/eng/common/internal-feed-operations.ps1 index 418c09930cf..3c10e32bc48 100644 --- a/eng/common/internal-feed-operations.ps1 +++ b/eng/common/internal-feed-operations.ps1 @@ -45,11 +45,11 @@ function SetupCredProvider { # Then, we set the 'VSS_NUGET_EXTERNAL_FEED_ENDPOINTS' environment variable to restore from the stable # feeds successfully - $nugetConfigPath = "$RepoRoot\NuGet.config" + $nugetConfigPath = Join-Path "RepoRoot "NuGet.config" if (-Not (Test-Path -Path $nugetConfigPath)) { Write-PipelineTelemetryError -Category 'Build' -Message 'NuGet.config file not found in repo root!' - ExitWithExitCode 1 + ExitWithExitCode 1 } $endpoints = New-Object System.Collections.ArrayList @@ -85,7 +85,7 @@ function SetupCredProvider { #Workaround for https://github.com/microsoft/msbuild/issues/4430 function InstallDotNetSdkAndRestoreArcade { - $dotnetTempDir = "$RepoRoot\dotnet" + $dotnetTempDir = Join-Path $RepoRoot "dotnet" $dotnetSdkVersion="2.1.507" # After experimentation we know this version works when restoring the SDK (compared to 3.0.*) $dotnet = "$dotnetTempDir\dotnet.exe" $restoreProjPath = "$PSScriptRoot\restore.proj" From 21d7fc76e4036a23d0ed92b7bb9150fd01b46624 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 10 Jun 2021 10:12:07 +0200 Subject: [PATCH 06/11] Update internal-feed-operations.ps1 --- eng/common/internal-feed-operations.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/internal-feed-operations.ps1 b/eng/common/internal-feed-operations.ps1 index 3c10e32bc48..92b77347d99 100644 --- a/eng/common/internal-feed-operations.ps1 +++ b/eng/common/internal-feed-operations.ps1 @@ -45,7 +45,7 @@ function SetupCredProvider { # Then, we set the 'VSS_NUGET_EXTERNAL_FEED_ENDPOINTS' environment variable to restore from the stable # feeds successfully - $nugetConfigPath = Join-Path "RepoRoot "NuGet.config" + $nugetConfigPath = Join-Path $RepoRoot "NuGet.config" if (-Not (Test-Path -Path $nugetConfigPath)) { Write-PipelineTelemetryError -Category 'Build' -Message 'NuGet.config file not found in repo root!' From 67a3ccb25d1b6b4f47ce0a074e51516fd59b836f Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 10 Jun 2021 13:37:06 +0200 Subject: [PATCH 07/11] Update Build.proj --- src/Microsoft.DotNet.Arcade.Sdk/tools/Build.proj | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/Build.proj b/src/Microsoft.DotNet.Arcade.Sdk/tools/Build.proj index 5d67c1c7f62..8c8fa7ef037 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/Build.proj +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/Build.proj @@ -1,5 +1,5 @@ - + - <_RepoRootOriginal>$(RepoRoot) - $([System.IO.Path]::GetFullPath('$(RepoRoot)/')) - <_OriginalProjectsValue>$(Projects) @@ -80,8 +77,8 @@ - - + + From ec55f0eb960471f24032e56d87c527f17d88ce5c Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 10 Jun 2021 13:39:22 +0200 Subject: [PATCH 08/11] Update tools.sh --- eng/common/tools.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/common/tools.sh b/eng/common/tools.sh index c0c62d92465..a6e64058fba 100755 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -484,7 +484,8 @@ _script_dir=`dirname "$_ResolvePath"` . "$_script_dir/pipeline-logging-functions.sh" eng_root=`cd -P "$_script_dir/.." && pwd` -repo_root=`cd -P "$_script_dir/../../" && pwd` +repo_root=`cd -P "$_script_dir/../.." && pwd` +repo_root="{repo_root}/" artifacts_dir="${repo_root}artifacts" toolset_dir="$artifacts_dir/toolset" tools_dir="${repo_root}.tools" From 8195159b7bc2db0b640faf2b49bbf277dcb40043 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 10 Jun 2021 15:20:11 +0200 Subject: [PATCH 09/11] Update tools.sh --- eng/common/tools.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/tools.sh b/eng/common/tools.sh index a6e64058fba..05ca99c6b28 100755 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -485,7 +485,7 @@ _script_dir=`dirname "$_ResolvePath"` eng_root=`cd -P "$_script_dir/.." && pwd` repo_root=`cd -P "$_script_dir/../.." && pwd` -repo_root="{repo_root}/" +repo_root="${repo_root}/" artifacts_dir="${repo_root}artifacts" toolset_dir="$artifacts_dir/toolset" tools_dir="${repo_root}.tools" From da9055fe1727276c3e5d7512cde9aac52cbf5f35 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 10 Jun 2021 15:28:56 +0200 Subject: [PATCH 10/11] Update tools.ps1 --- eng/common/tools.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index 0a125266a7c..4ff99cddb96 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -703,7 +703,7 @@ function MSBuild-Core() { foreach ($arg in $args) { if ($arg -ne $null -and $arg.Trim() -ne "") { - $cmdArgs += " `"$arg`"" + $cmdArgs += " `"`"$arg`"`"" } } From 187e233389ffe12386099669ee77edcf5e15618b Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 10 Jun 2021 16:20:54 +0200 Subject: [PATCH 11/11] Escape arg if path ends with backslash --- eng/common/tools.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index 4ff99cddb96..06871599323 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -702,8 +702,11 @@ function MSBuild-Core() { } foreach ($arg in $args) { - if ($arg -ne $null -and $arg.Trim() -ne "") { - $cmdArgs += " `"`"$arg`"`"" + if ($null -ne $arg -and $arg.Trim() -ne "") { + if ($arg.EndsWith('\')) { + $arg = $arg + "\" + } + $cmdArgs += " `"$arg`"" } }