Skip to content

Commit 8a3059b

Browse files
committed
Refactor NuGet package processing: remove PDB files from nupkg archives and update workflow for improved handling
1 parent 879752f commit 8a3059b

1 file changed

Lines changed: 50 additions & 10 deletions

File tree

.github/workflows/publish-to-nuget.yml

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,56 @@ jobs:
4747
dir
4848
dir artifacts
4949
50-
- name: Publish NuGet packages
50+
- name: Process NuGet packages (remove PDBs)
5151
shell: pwsh
5252
run: |
53-
Get-ChildItem -Path "${{ github.workspace }}/artifacts" -Filter *.nupkg | ForEach-Object {
54-
dotnet nuget push $_.FullName --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json --skip-duplicate
55-
}
56-
57-
- name: Publish symbols packages
58-
shell: pwsh
59-
run: |
60-
Get-ChildItem -Path "${{ github.workspace }}/artifacts" -Filter *.snupkg | ForEach-Object {
61-
dotnet nuget push $_.FullName --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json --skip-duplicate
53+
$artifactsPath = "${{ github.workspace }}/artifacts"
54+
Get-ChildItem -Path $artifactsPath -Filter *.nupkg | ForEach-Object {
55+
$nupkgPath = $_.FullName
56+
$zipPath = $nupkgPath -replace '\.nupkg$', '.zip'
57+
$extractPath = $nupkgPath -replace '\.nupkg$', '_extracted'
58+
59+
# Rename to zip
60+
Write-Host "Processing $($_.Name)"
61+
Copy-Item -Path $nupkgPath -Destination $zipPath
62+
63+
# Extract zip
64+
Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force
65+
66+
# Remove PDB files
67+
Get-ChildItem -Path $extractPath -Filter *.pdb -Recurse | ForEach-Object {
68+
Write-Host "Removing PDB: $($_.FullName)"
69+
Remove-Item -Path $_.FullName -Force
70+
}
71+
72+
# List remaining contents
73+
Write-Host "Remaining contents:"
74+
Get-ChildItem -Path $extractPath -Recurse | Select-Object -ExpandProperty FullName
75+
76+
# Create new zip preserving structure (temporarily delete the original nupkg)
77+
Remove-Item -Path $zipPath -Force
78+
$currentLocation = Get-Location
79+
Set-Location -Path $extractPath
80+
Compress-Archive -Path * -DestinationPath $zipPath -Force
81+
Set-Location -Path $currentLocation
82+
83+
# Rename back to nupkg
84+
Remove-Item -Path $nupkgPath -Force
85+
Move-Item -Path $zipPath -Destination $nupkgPath
86+
87+
# Clean up extraction directory
88+
Remove-Item -Path $extractPath -Recurse -Force
6289
}
90+
# - name: Publish NuGet packages
91+
# shell: pwsh
92+
# run: |
93+
# Get-ChildItem -Path "${{ github.workspace }}/artifacts" -Filter *.nupkg | ForEach-Object {
94+
# dotnet nuget push $_.FullName --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json --skip-duplicate
95+
# }
96+
#
97+
# - name: Publish symbols packages
98+
# shell: pwsh
99+
# run: |
100+
# Get-ChildItem -Path "${{ github.workspace }}/artifacts" -Filter *.snupkg | ForEach-Object {
101+
# dotnet nuget push $_.FullName --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json --skip-duplicate
102+
# }

0 commit comments

Comments
 (0)