写这篇文章是因为我已经花了一整天的时间试图弄清楚这一点。我在网上找到的所有内容似乎都已经过时了。
我尝试过的事情:
这些似乎都不起作用。
如果有人可以写下有关如何正确配置我想要的内容的分步指南,我将非常感激。
我已经尝试了文档中能找到的所有内容,但实在是太糟糕了。
编辑1:
我已尝试按照文档中描述的步骤进行操作,但没有成功。我设法使 SourceLink 工作,但仅当 DebugType 设置为嵌入时才有效。但是,正如我所说,我们不想在 dll 中包含 PDB 文件。之后,我尝试使用文档中提供的管道任务将符号发布到我们的内部Azure DevOps存储库,任务成功,但是当我在VS中开始调试时(配置符号服务器ofc之后),符号没有被加载。但是,我得到了反编译,然后它以某种方式加载了反编译的符号。不知道这是什么
编辑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)'
编辑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>
在此视频的帮助下管理配置 SourceLink + Azure DevOps Symbols Server:
如果.NET版本>=8则无需额外的项目文件配置
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
Azure DevOps 管道 YAML 文件
# 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 调试设置
不要忘记在源设置中授予项目构建服务必要的访问权限。我花了一些时间才弄清楚为什么推送任务总是失败。
工件 -> YourFeed -> Feed 设置(齿轮图标) -> 权限 -> 添加用户/组。开始输入您的项目名称,它将显示为“YourProjectName Build Service (YourOrgName)”。授予其 Feed Publisher 权限。