From 849e4b8e01691f784a9a74385a225ec82c5e8068 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 4 Feb 2022 15:25:48 -0700 Subject: [PATCH] Simplify Join-Path expressions --- azure-pipelines/Get-ArtifactsStagingDirectory.ps1 | 2 +- azure-pipelines/artifacts/Variables.ps1 | 8 ++++---- azure-pipelines/artifacts/_stage_all.ps1 | 3 +-- azure-pipelines/dotnet-test-cloud.ps1 | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 b/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 index d96b1610..723574f5 100644 --- a/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 +++ b/azure-pipelines/Get-ArtifactsStagingDirectory.ps1 @@ -4,7 +4,7 @@ Param( if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) { $ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY } else { - $ArtifactStagingFolder = Join-Path (Resolve-Path $PSScriptRoot/..) (Join-Path obj _artifacts) + $ArtifactStagingFolder = [System.IO.Path]::GetFullPath("$PSScriptRoot/../obj/_artifacts") if ($CleanIfLocal -and (Test-Path $ArtifactStagingFolder)) { Remove-Item $ArtifactStagingFolder -Recurse -Force } diff --git a/azure-pipelines/artifacts/Variables.ps1 b/azure-pipelines/artifacts/Variables.ps1 index c6330cd3..4bc6d216 100644 --- a/azure-pipelines/artifacts/Variables.ps1 +++ b/azure-pipelines/artifacts/Variables.ps1 @@ -2,13 +2,13 @@ # It "snaps" the values of these variables where we can compute them during the build, # and otherwise captures the scripts to run later during an Azure Pipelines environment release. -$RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot (Join-Path .. ..))) -$ArtifactBasePath = Join-Path $RepoRoot (Join-Path obj _artifacts) +$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot/../..") +$ArtifactBasePath = "$RepoRoot/obj/_artifacts" $VariablesArtifactPath = Join-Path $ArtifactBasePath variables if (-not (Test-Path $VariablesArtifactPath)) { New-Item -ItemType Directory -Path $VariablesArtifactPath | Out-Null } # Copy variables, either by value if the value is calculable now, or by script -Get-ChildItem -Path (Join-Path $PSScriptRoot (Join-Path .. variables)) |% { +Get-ChildItem "$PSScriptRoot/../variables" |% { $value = $null if (-not $_.BaseName.StartsWith('_')) { # Skip trying to interpret special scripts # First check the environment variables in case the variable was set in a queued build @@ -35,7 +35,7 @@ Get-ChildItem -Path (Join-Path $PSScriptRoot (Join-Path .. variables)) |% { $value = Get-Content -Path $_.FullName } - Set-Content -Path (Join-Path $VariablesArtifactPath $_.Name) -Value $value + Set-Content -Path "$VariablesArtifactPath/$($_.Name)" -Value $value } @{ diff --git a/azure-pipelines/artifacts/_stage_all.ps1 b/azure-pipelines/artifacts/_stage_all.ps1 index af398a2e..87421d56 100644 --- a/azure-pipelines/artifacts/_stage_all.ps1 +++ b/azure-pipelines/artifacts/_stage_all.ps1 @@ -6,7 +6,6 @@ param ( [string]$ArtifactNameSuffix ) -$RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot (Join-Path .. ..))) $ArtifactStagingFolder = & "$PSScriptRoot/../Get-ArtifactsStagingDirectory.ps1" -CleanIfLocal function Create-SymbolicLink { @@ -33,7 +32,7 @@ function Create-SymbolicLink { # Stage all artifacts $Artifacts = & "$PSScriptRoot\_all.ps1" -ArtifactNameSuffix $ArtifactNameSuffix $Artifacts |% { - $DestinationFolder = (Join-Path (Join-Path $ArtifactStagingFolder "$($_.ArtifactName)$ArtifactNameSuffix") $_.ContainerFolder).TrimEnd('\') + $DestinationFolder = [System.IO.Path]::GetFullPath("$ArtifactStagingFolder/$($_.ArtifactName)$ArtifactNameSuffix/$($_.ContainerFolder)").TrimEnd('\') $Name = "$(Split-Path $_.Source -Leaf)" #Write-Host "$($_.Source) -> $($_.ArtifactName)\$($_.ContainerFolder)" -ForegroundColor Yellow diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index c8642453..a7a63a02 100644 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -4,7 +4,7 @@ Param( [switch]$PublishResults ) -$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..') +$RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path $ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1" dotnet test $RepoRoot `