Skip to content

Commit

Permalink
Merge pull request #139 from AArnott/simplifyJoinPath
Browse files Browse the repository at this point in the history
Simplify Join-Path expressions
  • Loading branch information
AArnott authored Feb 4, 2022
2 parents f9f2c97 + 849e4b8 commit 2ed469f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines/Get-ArtifactsStagingDirectory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions azure-pipelines/artifacts/Variables.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

@{
Expand Down
3 changes: 1 addition & 2 deletions azure-pipelines/artifacts/_stage_all.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines/dotnet-test-cloud.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 `
Expand Down

0 comments on commit 2ed469f

Please sign in to comment.