Skip to content

Commit a419173

Browse files
authored
Normalize RepoRoot to include trailing slash (#7498)
* 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.
1 parent e81d8c9 commit a419173

File tree

6 files changed

+18
-17
lines changed

6 files changed

+18
-17
lines changed

eng/common/dotnet-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ case $cpuname in
7070
;;
7171
esac
7272

73-
dotnetRoot="$repo_root/.dotnet"
73+
dotnetRoot="${repo_root}.dotnet"
7474
if [[ $architecture != "" ]] && [[ $architecture != $buildarch ]]; then
7575
dotnetRoot="$dotnetRoot/$architecture"
7676
fi

eng/common/internal-feed-operations.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ function SetupCredProvider {
4545
# Then, we set the 'VSS_NUGET_EXTERNAL_FEED_ENDPOINTS' environment variable to restore from the stable
4646
# feeds successfully
4747

48-
$nugetConfigPath = "$RepoRoot\NuGet.config"
48+
$nugetConfigPath = Join-Path $RepoRoot "NuGet.config"
4949

5050
if (-Not (Test-Path -Path $nugetConfigPath)) {
5151
Write-PipelineTelemetryError -Category 'Build' -Message 'NuGet.config file not found in repo root!'
52-
ExitWithExitCode 1
52+
ExitWithExitCode 1
5353
}
5454

5555
$endpoints = New-Object System.Collections.ArrayList
@@ -85,7 +85,7 @@ function SetupCredProvider {
8585

8686
#Workaround for https://github.com/microsoft/msbuild/issues/4430
8787
function InstallDotNetSdkAndRestoreArcade {
88-
$dotnetTempDir = "$RepoRoot\dotnet"
88+
$dotnetTempDir = Join-Path $RepoRoot "dotnet"
8989
$dotnetSdkVersion="2.1.507" # After experimentation we know this version works when restoring the SDK (compared to 3.0.*)
9090
$dotnet = "$dotnetTempDir\dotnet.exe"
9191
$restoreProjPath = "$PSScriptRoot\restore.proj"

eng/common/internal-feed-operations.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function SetupCredProvider {
3939
# Then, we set the 'VSS_NUGET_EXTERNAL_FEED_ENDPOINTS' environment variable to restore from the stable
4040
# feeds successfully
4141

42-
local nugetConfigPath="$repo_root/NuGet.config"
42+
local nugetConfigPath="{$repo_root}NuGet.config"
4343

4444
if [ ! "$nugetConfigPath" ]; then
4545
Write-PipelineTelemetryError -category 'Build' "NuGet.config file not found in repo's root!"

eng/common/tools.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,10 @@ function MSBuild-Core() {
702702
}
703703

704704
foreach ($arg in $args) {
705-
if ($arg -ne $null -and $arg.Trim() -ne "") {
705+
if ($null -ne $arg -and $arg.Trim() -ne "") {
706+
if ($arg.EndsWith('\')) {
707+
$arg = $arg + "\"
708+
}
706709
$cmdArgs += " `"$arg`""
707710
}
708711
}
@@ -774,7 +777,7 @@ function Get-Darc($version) {
774777

775778
. $PSScriptRoot\pipeline-logging-functions.ps1
776779

777-
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..\..')
780+
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..\..\')
778781
$EngRoot = Resolve-Path (Join-Path $PSScriptRoot '..')
779782
$ArtifactsDir = Join-Path $RepoRoot 'artifacts'
780783
$ToolsetDir = Join-Path $ArtifactsDir 'toolset'

eng/common/tools.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,13 +485,14 @@ _script_dir=`dirname "$_ResolvePath"`
485485

486486
eng_root=`cd -P "$_script_dir/.." && pwd`
487487
repo_root=`cd -P "$_script_dir/../.." && pwd`
488-
artifacts_dir="$repo_root/artifacts"
488+
repo_root="${repo_root}/"
489+
artifacts_dir="${repo_root}artifacts"
489490
toolset_dir="$artifacts_dir/toolset"
490-
tools_dir="$repo_root/.tools"
491+
tools_dir="${repo_root}.tools"
491492
log_dir="$artifacts_dir/log/$configuration"
492493
temp_dir="$artifacts_dir/tmp/$configuration"
493494

494-
global_json_file="$repo_root/global.json"
495+
global_json_file="${repo_root}global.json"
495496
# determine if global.json contains a "runtimes" entry
496497
global_json_has_runtimes=false
497498
if command -v jq &> /dev/null; then
@@ -504,7 +505,7 @@ fi
504505

505506
# HOME may not be defined in some scenarios, but it is required by NuGet
506507
if [[ -z $HOME ]]; then
507-
export HOME="$repo_root/artifacts/.home/"
508+
export HOME="${repo_root}artifacts/.home/"
508509
mkdir -p "$HOME"
509510
fi
510511

src/Microsoft.DotNet.Arcade.Sdk/tools/Build.proj

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
2-
<Project DefaultTargets="Execute" TreatAsLocalProperty="RepoRoot">
2+
<Project DefaultTargets="Execute">
33
<!--
44
55
Required parameters:
@@ -33,9 +33,6 @@
3333
-->
3434

3535
<PropertyGroup>
36-
<_RepoRootOriginal>$(RepoRoot)</_RepoRootOriginal>
37-
<RepoRoot>$([System.IO.Path]::GetFullPath('$(RepoRoot)/'))</RepoRoot>
38-
3936
<_OriginalProjectsValue>$(Projects)</_OriginalProjectsValue>
4037
</PropertyGroup>
4138

@@ -80,8 +77,8 @@
8077

8178
<Target Name="Execute">
8279
<Error Text="No projects were found to build. Either the 'Projects' property or 'ProjectToBuild' item group must be specified." Condition="'@(ProjectToBuild)' == ''"/>
83-
<Error Text="Property 'RepoRoot' must be specified" Condition="'$(_RepoRootOriginal)' == ''"/>
84-
<Error Text="File 'global.json' must exist in directory specified by RepoRoot: '$(_RepoRootOriginal)'" Condition="'$(_RepoRootOriginal)' != '' and !Exists('$(RepoRoot)global.json')"/>
80+
<Error Text="Property 'RepoRoot' must be specified" Condition="'$(RepoRoot)' == ''"/>
81+
<Error Text="File 'global.json' must exist in directory specified by RepoRoot: '$(RepoRoot)'" Condition="'$(RepoRoot)' != '' and !Exists('$(RepoRoot)global.json')"/>
8582

8683
<PropertyGroup>
8784
<!-- 'IsRunningFromVisualStudio' may be true even when running msbuild.exe from command line. This generally means that MSBuild is from a Visual Studio installation and therefore we need to find NuGet.targets in a different location. -->

0 commit comments

Comments
 (0)