Publish symbols for debugging
TFS 2017
With Azure Pipelines, you can publish your symbols to Azure Artifacts symbol server using the Index sources and publish symbols task. You can use the debugger to connect and automatically retrieve the correct symbol files without knowing product names, build numbers, or package names. Using Azure Pipelines, you can also publish your symbols to files shares and portable PDBs.
Note
The Index sources and publish symbols task is not supported in release pipelines.
Publish symbols to Azure Artifacts symbol server
To publish your symbols to Azure Artifacts symbols server, you can use the Index Sources & Publish Symbols task.
From your pipeline definition, select
+
to add a new task.Search for the Index sources and publish symbols task. Select Add to add it to your pipeline.
Fill out the required fields as follows:
Task version: 1.\*.
Display name: task display name.
Path to symbols folder: path to the folder hosting the symbol files.
Search pattern: the pattern used to find the pdb files in the folder that you specified in Path to symbols folder. Single-folder wildcard (
*
) and recursive wildcards (**
) are supported. Example: *\bin**.pdb searches for all .pdb files in all the bin subdirectories.Index sources: indicates whether to inject source server information into the PDB files.
Publish symbols: indicates whether to publish the symbol files.
- Symbol server type: select Symbol Server in this organization/collection (requires Azure Artifacts) to publish your symbols to Azure Artifacts symbol server.
Verbose logging: check to include more information in your logs.
Publish symbols to a file share
Aside from Azure Artifacts symbol server, you can also publish your symbols to a file share using the Index Sources and Publish Symbols task.
From your pipeline definition, select
+
to add a new task.Search for the Index sources and publish symbols task. Select Add to add it to your pipeline.
Fill out the required fields as follows:
Task version: 1.\*.
Display name: task display name.
Path to symbols folder: path to the folder hosting the symbol files.
Search pattern: the pattern used to find the pdb files in the folder that you specified in Path to symbols folder.
Index sources: indicates whether to inject source server information into the PDB files.
Publish symbols: indicates whether to publish the symbol files.
- Symbol server type: select File share to publish your symbols to a file share.
- Path to publish symbols: the file share that will host your symbols.
Verbose logging: check to include more information in your logs.
Publish portable PDBs to Azure Artifacts symbol server
Portable PDBs are symbol files that can be created and used on all platforms unlike the traditional PDBs which are used on Windows only. If you're using portable PDBs, you still need to use the Index Sources and Publish Symbols task to publish your symbols. For portable PDBs, the build does the indexing, however you should use SourceLink to index the symbols as part of your pipeline.
Use Source Link in .NET projects
Source link is a set of tools that allow developers to debug their source code by mapping from the .NET assemblies back to the source code. Check out the dotnet/sourcelink GitHub repository to learn about the different packages included.
For projects hosted on GitHub, add the
Microsoft.SourceLink.GitHub
package reference to your project file.<ItemGroup> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/> </ItemGroup>
For projects hosted on Azure Repos, add the
Microsoft.SourceLink.AzureRepos.Git
package reference to your project file.<ItemGroup> <PackageReference Include="Microsoft.SourceLink.AzureRepos.Git" Version="1.0.0" PrivateAssets="All"/> </ItemGroup>
For projects hosted on Azure DevOps Server, add the
Microsoft.SourceLink.AzureDevOpsServer.Git
package reference to your project file.<ItemGroup> <PackageReference Include="Microsoft.SourceLink.AzureDevOpsServer.Git" Version="1.0.0" PrivateAssets="All"/> </ItemGroup>
Set up the build task
The next step is to modify the build task in your pipeline to invoke Source Link during the build process.
From your pipeline definition, select the Build solution task. You can search for and add the Visual Studio build task to your pipeline if you don't have it already.
Add the following snippet to the MSBuild arguments.
/p:SourceLinkCreate=true
Select Save & queue when you are done.
Set up the publish task
The Index Sources & Publish Symbols task is used to index your source code and publish your symbols to Azure Artifacts symbols server. Because we are using the Visual Studio build task to index our source, we will disable indexing in the publish task.
From your pipeline definition, select
+
to add a new task.Search for the Index sources and publish symbols task. Select Add to add it to your pipeline.
Fill out the required fields as follows:
Task version: 1.\*.
Index sources: Uncheck to disable indexing. Indexing is done during build. See the previous step for more details.
Publish symbols: indicates whether to publish the symbol files.
- Symbol server type: select Symbol Server in this organization/collection (requires Azure Artifacts) to publish your symbols to Azure Artifacts symbol server.
Set up Visual Studio
Before starting to consume our symbols from Azure Artifacts symbol server, let's make sure that Visual Studio is set up properly:
In Visual Studio, select Tools then Options.
Select Symbols from the Debugging menu.
Select the
+
sign to add a new symbol server location.A new dialog box will open, select your account from the dropdown menu, and then select the organization that you wish to connect to. Select Connect when you are done.
Select General from the same Debugging section. Scroll down and check Enable Source Link support to enable support for portable PDBs.
Note
Checking the Enable source server support option enables you to use Source Server when there is no source code on the local machine or the symbol file does not match the source code. If you want to enable third-party source code debugging, uncheck the Enable Just My Code checkbox.
Important
To delete symbols that were published using the Index Sources & Publish Symbols task, you must first delete the build that generated those symbols. This can be accomplished by using retention policies or by manually deleting the run.
FAQs
Q: How long symbols are retained for?
A: A symbol file has the same retention period as the build that generated it. When you delete a build either manually or using retention policies, the symbols that were generated by that build will be deleted as well.
Q: Can I use source indexing on a portable PDB generated from a .NET Core assembly?
A: This is not possible at the moment. Source indexing is not currently supported for portable PDBs. The recommended approach is to configure your build to do the indexing.