Skip to content

Commit 654d6cb

Browse files
authored
Merge pull request #2410 from nagilson/nagilson-fix-pme
Fix PME Signing
2 parents a84e85e + e3c1346 commit 654d6cb

File tree

4 files changed

+142
-37
lines changed

4 files changed

+142
-37
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
parameters:
2+
- name: paths
3+
type: object
4+
default:
5+
- path: $(System.DefaultWorkingDirectory)
6+
title: "🏠 SYSTEM DEFAULT WORKING DIRECTORY"
7+
- path: $(Build.ArtifactStagingDirectory)
8+
title: "🎯 BUILD ARTIFACT STAGING DIRECTORY"
9+
- name: displayName
10+
type: string
11+
default: '📋 List All Files Recursively'
12+
13+
steps:
14+
- ${{ each pathConfig in parameters.paths }}:
15+
- pwsh: |
16+
Write-Host "====================== FILE STRUCTURE OVERVIEW ======================"
17+
Write-Host ""
18+
19+
function Show-DirectoryTree {
20+
param(
21+
[string]$Path,
22+
[string]$Title
23+
)
24+
25+
Write-Host "$Title" -ForegroundColor Cyan
26+
Write-Host "Path: $Path" -ForegroundColor Yellow
27+
Write-Host ""
28+
29+
if (Test-Path $Path) {
30+
try {
31+
$items = Get-ChildItem -Path $Path -Recurse -ErrorAction SilentlyContinue | Sort-Object FullName
32+
$totalFiles = ($items | Where-Object { -not $_.PSIsContainer }).Count
33+
$totalDirs = ($items | Where-Object { $_.PSIsContainer }).Count
34+
35+
Write-Host "📊 Summary: $totalDirs directories, $totalFiles files" -ForegroundColor Green
36+
Write-Host ""
37+
38+
if ($items.Count -eq 0) {
39+
Write-Host "📭 Directory is empty" -ForegroundColor Gray
40+
Write-Host ""
41+
return
42+
}
43+
44+
# Group by directory for better structure
45+
$directories = $items | Where-Object { $_.PSIsContainer } | Sort-Object FullName
46+
$files = $items | Where-Object { -not $_.PSIsContainer } | Sort-Object FullName
47+
48+
# Show directory structure first
49+
if ($directories.Count -gt 0) {
50+
Write-Host "📁 Directory Structure:" -ForegroundColor Magenta
51+
foreach ($dir in $directories) {
52+
$relativePath = $dir.FullName.Replace($Path, "").TrimStart('\', '/')
53+
if ($relativePath) {
54+
$depth = ($relativePath.Split([System.IO.Path]::DirectorySeparatorChar, [System.IO.Path]::AltDirectorySeparatorChar) | Where-Object { $_ -ne "" }).Count
55+
$indent = " " * $depth + "├── "
56+
Write-Host "$indent$($dir.Name)/" -ForegroundColor Blue
57+
}
58+
}
59+
Write-Host ""
60+
}
61+
62+
# Show files grouped by directory
63+
if ($files.Count -gt 0) {
64+
Write-Host "📄 Files:" -ForegroundColor Magenta
65+
$filesByDir = $files | Group-Object { Split-Path $_.FullName -Parent } | Sort-Object Name
66+
67+
foreach ($group in $filesByDir) {
68+
$relativeDirPath = $group.Name.Replace($Path, "").TrimStart('\', '/')
69+
if ($relativeDirPath -eq "") {
70+
Write-Host " 📂 Root:" -ForegroundColor Yellow
71+
} else {
72+
Write-Host " 📂 ${relativeDirPath}:" -ForegroundColor Yellow
73+
}
74+
75+
foreach ($file in ($group.Group | Sort-Object Name)) {
76+
try {
77+
$size = if ($file.Length -lt 1KB) { "$($file.Length) B" }
78+
elseif ($file.Length -lt 1MB) { "{0:N1} KB" -f ($file.Length / 1KB) }
79+
else { "{0:N1} MB" -f ($file.Length / 1MB) }
80+
81+
Write-Host " ├── $($file.Name) ($size)" -ForegroundColor White
82+
}
83+
catch {
84+
Write-Host " ├── $($file.Name) (size unknown)" -ForegroundColor Gray
85+
}
86+
}
87+
Write-Host ""
88+
}
89+
}
90+
}
91+
catch {
92+
Write-Host "❌ Error accessing directory: $($_.Exception.Message)" -ForegroundColor Red
93+
}
94+
} else {
95+
Write-Host "❌ Directory does not exist: $Path" -ForegroundColor Red
96+
}
97+
Write-Host "=================================================================" -ForegroundColor Cyan
98+
Write-Host ""
99+
}
100+
101+
Show-DirectoryTree -Path "${{ pathConfig.path }}" -Title "${{ pathConfig.title }}"
102+
103+
displayName: '${{ parameters.displayName }} - ${{ pathConfig.title }}'

pipeline-templates/package-vsix.yaml

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -65,51 +65,52 @@ jobs:
6565
workingDirectory: $(dir-name)
6666
env:
6767
SignType: ${{ parameters.SignType }}
68+
- template: list-file-structure.yaml
6869
- script: dotnet build msbuild/signVsix -v:normal
6970
displayName: 🖊️ Sign VSIXes
7071
env:
7172
SignType: ${{ parameters.SignType }}
72-
- pwsh: |
73-
Function Spawn-Tool($command, $commandArgs, $retryCount=0) {
74-
Write-Host "$pwd >"
75-
for (; $retryCount -ge 0; $retryCount--) {
76-
Write-Host "##[command]$command $commandArgs"
77-
$output = Invoke-Expression "$command $commandArgs" # Do not use @commandArgs because it quotes '-Target', breaking the script.
78-
if ($LASTEXITCODE -eq 0) { break }
79-
Write-Host "Task failed with exit code $LASTEXITCODE. $retryCount retries left."
80-
}
81-
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
73+
- ${{ if eq(variables['Build.Reason'], 'IndividualCI') }}:
74+
- pwsh: |
75+
Function Spawn-Tool($command, $commandArgs, $retryCount=0) {
76+
Write-Host "$pwd >"
77+
for (; $retryCount -ge 0; $retryCount--) {
78+
Write-Host "##[command]$command $commandArgs"
79+
$output = Invoke-Expression "$command $commandArgs" # Do not use @commandArgs because it quotes '-Target', breaking the script.
80+
if ($LASTEXITCODE -eq 0) { break }
81+
Write-Host "Task failed with exit code $LASTEXITCODE. $retryCount retries left."
82+
}
83+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
8284
83-
return $output
84-
}
85+
return $output
86+
}
8587
86-
$anyFailed = $false
87-
$vsixes = Get-ChildItem -Path ../packages -Filter *.vsix -Recurse
88-
foreach ($vsix in $vsixes) {
89-
$baseName = "$($vsix.DirectoryName)\$($vsix.BaseName)"
90-
$manifestFile = $baseName + ".manifest"
91-
$signatureFile = $baseName + ".signature.p7s"
88+
$anyFailed = $false
89+
$vsixes = Get-ChildItem -Path ../packages -Filter *.vsix -Recurse
90+
foreach ($vsix in $vsixes) {
91+
$baseName = "$($vsix.DirectoryName)\$($vsix.BaseName)"
92+
$manifestFile = $baseName + ".manifest"
93+
$signatureFile = $baseName + ".signature.p7s"
9294
93-
$vsceVerifyArgs = '@vscode/vsce','verify-signature','--packagePath',$vsix,'--manifestPath',$manifestFile,'--signaturePath',$signatureFile
94-
$output = Spawn-Tool 'npx' $vsceVerifyArgs
95+
$vsceVerifyArgs = '@vscode/vsce','verify-signature','--packagePath',$vsix,'--manifestPath',$manifestFile,'--signaturePath',$signatureFile
96+
$output = Spawn-Tool 'npx' $vsceVerifyArgs
9597
96-
# This is a brittle check but the command does not return a non-zero exit code for failed validation.
97-
# Opened https://github.com/microsoft/vscode-vsce/issues/1192 to track this.
98-
if ($output.Contains('Signature verification result: Success')) {
99-
Write-Host "Signature verification succeeded for $vsix"
100-
} else {
101-
Write-Host ($output | Out-String)
102-
Write-Host "##[error]Signature verification failed for $vsix"
103-
$anyFailed = $true
98+
# This is a brittle check but the command does not return a non-zero exit code for failed validation.
99+
# Opened https://github.com/microsoft/vscode-vsce/issues/1192 to track this.
100+
if ($output.Contains('Signature verification result: Success')) {
101+
Write-Host "Signature verification succeeded for $vsix"
102+
} else {
103+
Write-Host ($output | Out-String)
104+
Write-Host "##[error]Signature verification failed for $vsix"
105+
$anyFailed = $true
106+
}
104107
}
105-
}
106108
107-
if ($anyFailed) {
108-
exit 1
109-
}
110-
displayName: 🔑 Verify VSIX Signature Files
111-
workingDirectory: $(dir-name)
112-
condition: and( succeeded(), eq('$(SignType)', 'Real'))
109+
if ($anyFailed) {
110+
exit 1
111+
}
112+
displayName: 🔑 Verify VSIX Signature Files
113+
workingDirectory: $(dir-name)
113114
- task: CmdLine@2
114115
displayName: 🤌 Rename Signed VSIX
115116
inputs:

pipeline-templates/prepare-signing.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ steps:
1414
signType: ${{ parameters.SignType }}
1515
zipSources: false
1616
feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
17-
azureSubscription: 'MicroBuild Signing Task (DevDiv)'
1817
${{ if eq(variables['Build.Reason'], 'IndividualCI') }}:
19-
ConnectedPMEServiceName: c24de2a5-cc7a-493d-95e4-8e5ff5cad2bc
18+
signWithProd: true
19+
ConnectedPMEServiceName: 248d384a-b39b-46e3-8ad5-c2c210d5e7ca
2020
env:
2121
SignType: ${{ parameters.SignType }}
2222
TeamName: DotNetCore

pipeline-templates/publish.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
inputs:
2828
path: '$(System.ArtifactsDirectory)'
2929
- template: install-node.yaml
30+
- template: list-file-structure.yaml
3031
- bash: |
3132
VERSION=`node -p "require('./package.json').version"`
3233
npm version $VERSION --allow-same-version

0 commit comments

Comments
 (0)