Skip to content

Invalid PDB symbols with SourceLink, non-deterministic build #39

Description

@tompazourek

Issue description

When viewing the NuGet package (2.0.0) via NuGet Package Explorer, I see this:

image

I also get an error when debugging process dumps in Visual Studio:

image

Source Link data for Microsoft.Azure.StackExchangeRedis.dll (embedded) failed to parse or does not conform to the schema: {"documents":{}}

Untracked sources fix

I think the untracked sources (generated AssemblyInfo) warning is only minor, and can be resolved by adding an MSBuild property:

<EmbedUntrackedSources>true</EmbedUntrackedSources>

Non-deterministic paths fix for SourceLink

The bigger issue is the non-deterministic build where the source file paths in the embedded symbols are not normalized, and thus don't work with SourceLink.

As seen via ILSpy:

image

The paths shouldn't be real disk paths like C:\..., the "normalized" paths should start with /_/.

This can be achieved by passing MSBuild property:

<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>

But this property should only be used for non-local-development builds as it affects debugging. A good way might be to pass it as -p:ContinuousIntegrationBuild=true in a build pipeline, or alternatively make it conditional based on some environment variable etc:

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

I would contribute the fix, but it seems that the build pipelines are unfortunately not open-source, so I cannot confirm it will work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions