Skip to content

Commit e27bec0

Browse files
committed
Specify including Cocuhbase.Core's debug symbols in published NuGet package
1 parent 0a93681 commit e27bec0

2 files changed

Lines changed: 69 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,49 @@ jobs:
157157
dotnet build src/Couchbase.Analytics/Couchbase.Analytics.csproj -c Release --no-restore /p:ContinuousIntegrationBuild=true /p:Version="${{ needs.validate-inputs.outputs.tag }}" /p:IncludeSymbols=true /p:IncludeSource=true /p:SourceLinkCreate=true /p:SignAssembly=true /p:AssemblyOriginatorKeyFile="$env:SIGNKEY_PATH"
158158
dotnet pack src/Couchbase.Analytics/Couchbase.Analytics.csproj -c Release /p:ContinuousIntegrationBuild=true /p:Version="${{ needs.validate-inputs.outputs.tag }}" /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:IncludeSource=true /p:SourceLinkCreate=true /p:SignAssembly=true /p:AssemblyOriginatorKeyFile="$env:SIGNKEY_PATH"
159159
160+
- name: Verify package contents (DLL <-> PDB parity)
161+
shell: pwsh
162+
run: |
163+
$ver = "${{ needs.validate-inputs.outputs.tag }}"
164+
$packDir = "src/Couchbase.Analytics/bin/Release"
165+
$nupkg = Get-ChildItem -Path $packDir -Filter "*.$ver.nupkg" | Where-Object { $_.Name -notlike "*.symbols.nupkg" } | Select-Object -First 1
166+
$snupkg = Get-ChildItem -Path $packDir -Filter "*.$ver.snupkg" | Select-Object -First 1
167+
if (-not $nupkg) { Write-Error "No .nupkg matching version $ver found in $packDir"; exit 1 }
168+
if (-not $snupkg) { Write-Error "No .snupkg matching version $ver found in $packDir"; exit 1 }
169+
170+
Add-Type -AssemblyName System.IO.Compression.FileSystem
171+
172+
function Get-LibEntries($path, $extension) {
173+
$zip = [System.IO.Compression.ZipFile]::OpenRead($path)
174+
try {
175+
return @($zip.Entries | Where-Object { $_.FullName -like "lib/*$extension" } | ForEach-Object { $_.FullName })
176+
} finally {
177+
$zip.Dispose()
178+
}
179+
}
180+
181+
$dlls = Get-LibEntries $nupkg.FullName ".dll"
182+
$pdbs = Get-LibEntries $snupkg.FullName ".pdb"
183+
184+
Write-Host "DLLs in $($nupkg.Name):"
185+
$dlls | ForEach-Object { Write-Host " $_" }
186+
Write-Host "PDBs in $($snupkg.Name):"
187+
$pdbs | ForEach-Object { Write-Host " $_" }
188+
189+
# Every DLL shipped in lib/<tfm>/ must have a matching PDB at the same path in the symbol package.
190+
$missing = @()
191+
foreach ($dll in $dlls) {
192+
$expectedPdb = [System.IO.Path]::ChangeExtension($dll, ".pdb")
193+
if (-not ($pdbs -contains $expectedPdb)) {
194+
$missing += $expectedPdb
195+
}
196+
}
197+
if ($missing.Count -gt 0) {
198+
Write-Error ("Symbol package is missing PDB(s) for bundled DLL(s):`n " + ($missing -join "`n "))
199+
exit 1
200+
}
201+
Write-Host "Symbol package contains PDBs for all $($dlls.Count) bundled DLL(s)."
202+
160203
- name: Upload Packages Artifact
161204
uses: actions/upload-artifact@v4
162205
with:

src/Couchbase.Analytics/Couchbase.Analytics.csproj

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
<Nullable>enable</Nullable>
77
<RootNamespace>Couchbase.AnalyticsClient</RootNamespace>
88
<VersionPrefix>1.0.1</VersionPrefix>
9-
9+
1010
<AssemblyName>Couchbase.AnalyticsClient</AssemblyName>
1111
<PackageId>Couchbase.AnalyticsClient</PackageId>
1212
<Product>Couchbase Analytics Client</Product>
1313
<Description>The Official Couchbase Analytics .NET SDK</Description>
14-
14+
1515
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1616
<PackageReadmeFile>README.md</PackageReadmeFile>
17-
17+
1818
<PackageReleaseNotes>https://docs.couchbase.com/dotnet-analytics-sdk/current/project-docs/analytics-sdk-release-notes.html</PackageReleaseNotes>
1919
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2020
</PropertyGroup>
@@ -39,10 +39,30 @@
3939
<IncludeAssets>Couchbase.Core.dll</IncludeAssets>
4040
</ProjectReference>
4141
</ItemGroup>
42-
42+
4343
<ItemGroup>
4444
<None Include="..\..\README.md" Pack="true" PackagePath="" />
4545
</ItemGroup>
46-
4746

48-
</Project>
47+
<!--
48+
NuGet's symbol pack only includes the PDB of the project being packed.
49+
Couchbase.Core.dll is bundled into the main package (lib/<tfm>/), so its
50+
PDB must be added to the symbol package explicitly.
51+
This target adds the PDB of every ProjectReference whose DLL flows into the build output.
52+
-->
53+
<PropertyGroup>
54+
<TargetsForTfmSpecificDebugSymbolsInPackage>$(TargetsForTfmSpecificDebugSymbolsInPackage);IncludeReferencedProjectSymbolsInSymbolPackage</TargetsForTfmSpecificDebugSymbolsInPackage>
55+
</PropertyGroup>
56+
57+
<Target Name="IncludeReferencedProjectSymbolsInSymbolPackage" DependsOnTargets="BuildOnlySettings;ResolveReferences">
58+
<ItemGroup>
59+
<_ReferencedProjectPdb Include="@(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)%(Filename).pdb')"
60+
Condition="'%(ReferenceCopyLocalPaths.ReferenceSourceTarget)' == 'ProjectReference' and '%(ReferenceCopyLocalPaths.Extension)' == '.dll'" />
61+
<TfmSpecificDebugSymbolsFile Include="@(_ReferencedProjectPdb)"
62+
Condition="Exists('%(Identity)')"
63+
TargetPath="/lib/$(TargetFramework)/%(Filename)%(Extension)"
64+
TargetFramework="$(TargetFramework)" />
65+
</ItemGroup>
66+
</Target>
67+
68+
</Project>

0 commit comments

Comments
 (0)