Skip to content

Enable SourceLink, deterministic builds, and .snupkg symbol packages #7

Closed

Description

@rd-rtca

Problem

The packages ship without any debugging or provenance support:

  • No SourceLink. No PublishRepositoryUrl / EmbedUntrackedSources in any project, and no SourceLink package reference. A consumer stepping into MessagePipeline in the debugger sees decompiled IL, not the real source.
  • No symbol packages. .github/workflows/publish-nuget.yml:31 pushes only *.nupkg:
    dotnet nuget push ./nupkgs/*.nupkg --api-key ... --skip-duplicate
    
    No .snupkg is produced or pushed, so the NuGet.org symbol server has nothing to serve.
  • No deterministic CI build. ContinuousIntegrationBuild is not set, so binaries embed local machine paths and are not byte-for-byte reproducible.

Consequences: no step-into debugging for adopters, no "Source repository" link on the NuGet.org listing, and no way for a security-conscious consumer to verify the shipped DLL was built from the tagged commit. All three are now baseline expectations for a serious .NET library.

Proposed change

SourceLink for GitHub is built into the .NET SDK since .NET 8 — no Microsoft.SourceLink.GitHub package reference is needed. Setting the properties is enough.

Add to a shared Directory.Build.props (see the central-properties issue) or to each packable project:

<PropertyGroup>
  <PublishRepositoryUrl>true</PublishRepositoryUrl>
  <EmbedUntrackedSources>true</EmbedUntrackedSources>
  <IncludeSymbols>true</IncludeSymbols>
  <SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
  <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

ContinuousIntegrationBuild is scoped to CI on purpose — enabling it locally normalizes source paths and breaks local debugging.

Then push the symbol packages in .github/workflows/publish-nuget.yml:

       - name: Push to NuGet.org
         run: dotnet nuget push ./nupkgs/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
+
+      - name: Push symbols to NuGet.org
+        run: dotnet nuget push ./nupkgs/*.snupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

Note: the Build & Test workflow uses dotnet pack --no-build; confirm symbol generation still happens there, or drop --no-build for the pack-validation step only.

Acceptance criteria

  • dotnet pack -c Release emits both .nupkg and .snupkg for all 10 packages
  • The .nupkg .nuspec contains a repository element with url, type="git", and the exact commit SHA
  • publish-nuget.yml pushes *.snupkg alongside *.nupkg
  • The NuGet.org package page shows a "Source repository" link
  • Step-into debugging from a consumer project lands on real source
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions