Skip to content

Commit 3f2ca05

Browse files
authored
Update InsertJsonValues to handle folders (#391)
* Update InsertJsonValues to handle folders If the VSMan is in a nested folder, then the folder becomes part of the upload. Updated the InsertJsonValues to handle that. * Move BasePath Resolve-Path inside the test-path * Update comments and logic to make it cleaner
1 parent 479a191 commit 3f2ca05

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tools/variables/InsertJsonValues.ps1

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,25 @@ $BasePath = "$PSScriptRoot\..\..\bin\Packages\$BuildConfiguration\Vsix"
88

99
if (Test-Path $BasePath) {
1010
$vsmanFiles = @()
11-
Get-ChildItem $BasePath *.vsman -Recurse -File |% {
11+
Get-ChildItem $BasePath *.vsman -Recurse -File | % {
1212
$version = (Get-Content $_.FullName | ConvertFrom-Json).info.buildVersion
13+
$fullPath = (Resolve-Path $_.FullName).Path
14+
$basePath = (Resolve-Path $BasePath).Path
15+
# Cannot use RelativePath or GetRelativePath due to Powershell Core v2.0 limitation
16+
if ($fullPath.StartsWith($basePath, [StringComparison]::OrdinalIgnoreCase)) {
17+
# Get the relative paths then make sure the directory separators match URL format.
18+
$rfn = $fullPath.Substring($basePath.Length).TrimStart('\', '/').Replace('\', '/')
19+
}
20+
else {
21+
$rfn = $fullPath # fallback to full path if it doesn't start with base path
22+
}
23+
1324
$fn = $_.Name
14-
$vsmanFiles += "$fn{$version}=https://vsdrop.corp.microsoft.com/file/v1/$vstsDropNames;$fn"
25+
26+
# The left side is filename followed by the version and the right side is the drop url and the relative filename
27+
$thisVsManFile = "$fn{$version}=https://vsdrop.corp.microsoft.com/file/v1/$vstsDropNames;$rfn"
28+
$vsmanFiles += $thisVsManFile
1529
}
1630

17-
[string]::join(',',$vsmanFiles)
31+
[string]::join(',', $vsmanFiles)
1832
}

0 commit comments

Comments
 (0)