Writing this because I've already spent an entire day trying to figure this out. Everything I could find in the web seems outdated.
Things I tried:
None of these seem to work.
I would be very grateful if somebody could write down the step-by-step guide on how to properly configure what I want.
I've tried everything I could find in the docs, but it just sucks tbh.
Edit 1:
I have tried following the described steps in the docs, but no luck. I managed to make SourceLink work but only when the DebugType is set to embedded. But, as I said, we don’t want to include PDB files in the dll. After that, I tried to publish symbols to our internal Azure DevOps repo using the pipeline task provided in the docs, the task succeeded, but the symbols are not getting loaded when I start debugging in the VS (after configuring the Symbol server ofc). However, I get the decompiled, and then somehow it loads symbols of the decompiled. Idk what’s this
Edit 2:
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
trigger:
- main
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishSymbols@2
inputs:
SymbolsFolder: '$(Build.SourcesDirectory)'
SearchPattern: '**/bin/**/*.pdb'
IndexSources: false
PublishSymbols: true
SymbolServerType: 'TeamServices'
SymbolExpirationInDays: '36530'
IndexableFileFormats: 'Default'
DetailedLog: true
SymbolsArtifactName: 'Symbols_$(BuildConfiguration)'
Edit 3:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
</PropertyGroup>
</Project>
Managed to configure SourceLink + Azure DevOps Symbols Server with the help of this video:
No need for additional project file configurations if .NET version is >= 8
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
Azure DevOps pipeline YAML file
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: windows-latest
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'pack'
packagesToPack: '**/*.csproj'
versioningScheme: 'byPrereleaseNumber'
majorVersion: '1'
minorVersion: '0'
patchVersion: '0'
- task: DotNetCoreCLI@2
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'c4a7af6d-9593-4a8f-ab27-07194500dea0'
- task: PublishSymbols@2
inputs:
SearchPattern: '**/bin/**/*.pdb'
IndexSources: false
SymbolServerType: 'TeamServices'
VS Debugging settings
Don't forget to grant the necessary access permissions to your project build service in your feed's settings. I've spent some time until I figured why the Push task was failing all the time.
Artifacts -> YourFeed -> Feed Settings (gear icon) -> Permissions -> Add users/groups. Start typing your project's name, and it will appear there as "YourProjectName Build Service (YourOrgName)". Grant it the Feed Publisher permissions.