netstandard2.1 netstandard2.1 netstandard2.1

Unable to debug package from private Azure Repo

163 views Asked by At

I have a project that I publish to Azure Artifacts:

<Project Sdk="Microsoft.NET.Sdk">    
    <PropertyGroup>
        <TargetFramework>netstandard2.1</TargetFramework>
        <DebugType>portable</DebugType>
        <Version>1.0.11</Version>
        <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
        <IncludeSymbols>True</IncludeSymbols>
        <SymbolPackageFormat>snupkg</SymbolPackageFormat>
        <PublishRepositoryUrl>true</PublishRepositoryUrl>
        <EmbedUntrackedSources>true</EmbedUntrackedSources>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Microsoft.SourceLink.AzureRepos.Git" Version="1.1.1" PrivateAssets="All"/>
    </ItemGroup>
</Project>

Now I also want to publish the appropriate symbols in order to debug that package. Thus I followed the instructions from https://learn.microsoft.com/azure/devops/pipelines/artifacts/symbols?view=azure-devops#publish-portable-pdbs-to-azure-artifacts-symbol-server. My pipeline contains this:

steps:
... omited for brevity
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '**/*.csproj'
    arguments: '--configuration Release'
- task: DotNetCoreCLI@2
  inputs:
    command: 'pack'
    packagesToPack: '**/*.csproj'
    nobuild: true
    includesymbols: true
    versioningScheme: 'off'
- task: DotNetCoreCLI@2
  inputs:
    command: 'push'
    packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
    nuGetFeedType: 'internal'
    publishVstsFeed: 'myfeed'
- task: PublishSymbols@2
  inputs:
    SearchPattern: '**/bin/**/*.pdb'
    IndexSources: false
    SymbolServerType: 'TeamServices'

When I debug my consuming app, that references the package, and take a look into the currently loaded modules, I see my package with its symbols being loaded. However When I step into any of its types, just nothing happens and debugger steps to the next line of my consuming app.

This are my VS-settings for Debugging:

enter image description here

As you can see "Just my code" is disabled, and "Source link support" as well as "Source server support" are enabled.

I also tried to set the DebugType of my project to embedded, in order to embed the PDB into the assembly. However that didn't change anything. The symbols are loaded, but somehow SourceLink isn't able to get the information from them.

EDIT: my package is deployed with Release-configuration, instead of Debug.

1

There are 1 answers

9
VonC On

Double-check the 2020 articles from Claire Novotny (PM on the @NuGet team working on @dotnet at Microsoft):

There might be an issue with Source Linking, especially if your repository is private and there is an authentication issue.
Check also the build log for any issue related to PDB files publication.

Even with correct symbols, you might not be able to step into code if "Just My Code" is enabled in the debugger settings. "Just My Code" is a debugger feature that, when enabled, lets the debugger ignore code that is not your own. Check this setting in Tools -> Options -> Debugging -> General and uncheck the "Enable Just My Code" box if it is checked.

You have enabled EmbedUntrackedSources, which is usually a good idea, but if the sources are not being embedded correctly, it could cause issues.

To inspect PDB files and check the information they contain, you will need to use a specialized tool like dotPeek or PDB2PDB, although the latter has been recently archived. These tools can help you verify that the PDB files contain the expected debug information and source code paths.

Source Link is useful, as it embeds the source control information into the PDBs, allowing the debugger to fetch the correct version of the source code from the source control system.

That sounds like a good plan. If "Just My Code" is disabled and "Source Link support" is enabled, it seems like your Visual Studio settings are correct.

Make sure:

  • the PDB files (symbols) must match exactly with the DLLs (compiled code) they were built with. If there is a mismatch, the debugger will not be able to use the PDBs to step into the code.

  • the PDB files are being published to the symbol server in your Azure Pipelines configuration.

Once you have confirmed these points and if you are still encountering issues, you may want to try debugging with a more verbose logging level. In Visual Studio, you can enable symbol load logging by navigating to Debug > Options > Debugging > Output Window > Module Load Messages and setting it to Verbose. This could provide more information on what's happening when the symbols are loaded.

Another thing you can do is to manually load the symbols for a specific module in the Modules window during debugging. Right-click on the module and select Load Symbols. If the symbols are not loaded or there is an error, it could give you more information about the issue.