PublishSymbols@2 - 索引來源和發佈符號 v2 工作

使用此工作來編製原始程式碼的索引,並將符號發佈至檔案共用或 Azure Artifacts 符號伺服器。

編製原始程式碼的索引可讓您使用符號檔來偵錯您用來建置應用程式之機器上的應用程式。 例如,您可以從沒有原始程式碼的開發計算機,對組建代理程式所建置的應用程式進行偵錯。

符號伺服器可讓您的調試程序自動擷取正確的符號檔,而不知道產品名稱、組建編號或套件名稱。

Syntax

# Index sources and publish symbols v2
# Index your source code and publish symbols to a file share or Azure Artifacts symbol server.
- task: PublishSymbols@2
  inputs:
    #SymbolsFolder: '$(Build.SourcesDirectory)' # string. Path to symbols folder. Default: $(Build.SourcesDirectory).
    SearchPattern: '**/bin/**/*.pdb' # string. Required. Search pattern. Default: **/bin/**/*.pdb.
    #IndexSources: true # boolean. Index sources. Default: true.
    #PublishSymbols: true # boolean. Publish symbols. Default: true.
    SymbolServerType: # 'TeamServices' | 'FileShare'. Required when PublishSymbols = true. Symbol server type. 
    #SymbolsPath: # string. Optional. Use when PublishSymbols = true && SymbolServerType = FileShare. Path to publish symbols. 
    #CompressSymbols: false # boolean. Optional. Use when SymbolServerType = FileShare. Compress symbols. Default: false.
    #SymbolExpirationInDays: '36530' # string. Optional. Use when PublishSymbols = true && SymbolServerType = TeamServices. Symbol Expiration (in days). Default: 36530.
  # Advanced
    #IndexableFileFormats: 'Default' # 'Default' | 'Pdb' | 'SourceMap' | 'All'. Optional. Use when PublishSymbols = true && SymbolServerType = TeamServices. Symbol file formats to publish. Default: Default.
    #DetailedLog: true # boolean. Verbose logging. Default: true.
    #TreatNotIndexedAsWarning: false # boolean. Warn if not indexed. Default: false.
    #UseNetCoreClientTool: false # boolean. Use NetCore client tool. Default: false.
    #SymbolsMaximumWaitTime: # string. Max wait time (min). 
    #SymbolsProduct: # string. Product. 
    #SymbolsVersion: # string. Version. 
    #SymbolsArtifactName: 'Symbols_$(BuildConfiguration)' # string. Artifact name. Default: Symbols_$(BuildConfiguration).
# Index sources and publish symbols v2
# Index your source code and publish symbols to a file share or Azure Artifacts symbol server.
- task: PublishSymbols@2
  inputs:
    #SymbolsFolder: '$(Build.SourcesDirectory)' # string. Path to symbols folder. Default: $(Build.SourcesDirectory).
    SearchPattern: '**/bin/**/*.pdb' # string. Required. Search pattern. Default: **/bin/**/*.pdb.
    #IndexSources: true # boolean. Index sources. Default: true.
    #PublishSymbols: true # boolean. Publish symbols. Default: true.
    SymbolServerType: # 'TeamServices' | 'FileShare'. Required when PublishSymbols = true. Symbol server type. 
    #SymbolsPath: # string. Optional. Use when PublishSymbols = true && SymbolServerType = FileShare. Path to publish symbols. 
    #CompressSymbols: false # boolean. Optional. Use when SymbolServerType = FileShare. Compress symbols. Default: false.
  # Advanced
    #DetailedLog: true # boolean. Verbose logging. Default: true.
    #TreatNotIndexedAsWarning: false # boolean. Warn if not indexed. Default: false.
    #SymbolsMaximumWaitTime: # string. Max wait time (min). 
    #SymbolsProduct: # string. Product. 
    #SymbolsVersion: # string. Version. 
    #SymbolsArtifactName: 'Symbols_$(BuildConfiguration)' # string. Artifact name. Default: Symbols_$(BuildConfiguration).
# Index sources and publish symbols v2
# Index your source code and publish symbols to a file share or Azure Artifacts Symbol Server.
- task: PublishSymbols@2
  inputs:
    #SymbolsFolder: '$(Build.SourcesDirectory)' # string. Path to symbols folder. Default: $(Build.SourcesDirectory).
    SearchPattern: '**/bin/**/*.pdb' # string. Required. Search pattern. Default: **/bin/**/*.pdb.
    #IndexSources: true # boolean. Index sources. Default: true.
    #PublishSymbols: true # boolean. Publish symbols. Default: true.
    SymbolServerType: # 'TeamServices' | 'FileShare'. Required when PublishSymbols = true. Symbol server type. 
    #SymbolsPath: # string. Optional. Use when PublishSymbols = true && SymbolServerType = FileShare. Path to publish symbols. 
    #CompressSymbols: false # boolean. Optional. Use when SymbolServerType = FileShare. Compress symbols. Default: false.
  # Advanced
    #DetailedLog: true # boolean. Verbose logging. Default: true.
    #TreatNotIndexedAsWarning: false # boolean. Warn if not indexed. Default: false.
    #SymbolsMaximumWaitTime: # string. Max wait time (min). 
    #SymbolsProduct: # string. Product. 
    #SymbolsVersion: # string. Version. 
    #SymbolsArtifactName: 'Symbols_$(BuildConfiguration)' # string. Artifact name. Default: Symbols_$(BuildConfiguration).

輸入

SymbolsFolder - 符號資料夾的路徑
string. 預設值:$(Build.SourcesDirectory)

指定使用符號檔搜尋之資料夾的路徑。 預設為 $(Build.SourcesDirectory)。 否則,請指定根路徑,例如 $(Build.BinariesDirectory)/MyProject

注意

如果您選取 Azure Artifacts 符號伺服器作為伺服器類型,則不支援 UNC 路徑。


SearchPattern - 搜尋模式
string. 必要。 預設值:**/bin/**/*.pdb

指定用來探索要發佈的 PDB 檔案的模式。 如需詳細資訊 ,請參閱檔案比對模式參考


IndexSources - 索引來源
boolean. 預設值:true

指定是否要將來源伺服器資訊插入 PDB 檔案中。 只有 Windows 代理程式才支援此選項。


PublishSymbols - 發佈符號
boolean. 預設值:true

指定是否要發佈符號檔。


SymbolServerType - 符號伺服器類型
string. 當 PublishSymbols = true 時為必要。 允許的值: TeamServices (此組織/集合中的符號伺服器 (需要 Azure Artifacts) ) , FileShare (檔案共享) 。

指定要發佈符號的位置。 發佈至 Azure Artifacts 符號伺服器的符號可供任何具有組織/集合存取權的使用者存取。 Azure DevOps Server 僅支援 File share 選項。 請參閱 發佈符號 以偵錯以在 Azure Artifacts 中使用符號伺服器的指示。


SymbolsPath - 發佈符號的路徑
string. 選擇性。 使用 時 PublishSymbols = true && SymbolServerType = FileShare

指定裝載符號的檔案共用。 這個值將用於呼叫 symstore.exe add 中做為 /s 參數。 準備您的 SymStore 符號存放區:

  1. 在檔案共用伺服器上設定儲存符號的資料夾。 例如,設定 \fabrikam-share\symbols
  2. 授與 組建代理程式服務帳戶的完整控制許可權。

如果您將此自變數保留空白,您的符號將會編製索引,但不會發佈。 您也可以將符號與置放一起儲存。 請參閱發佈組建成品


CompressSymbols - 壓縮符號
boolean. 選擇性。 使用 時 SymbolServerType = FileShare。 預設值:false

在發佈至檔案共享時壓縮符號。


SymbolExpirationInDays - 符號到期 (天數)
string. 選擇性。 使用 時 PublishSymbols = true && SymbolServerType = TeamServices。 預設值:36530

指定應該保留符號的天數。


IndexableFileFormats - 要發佈的符號檔格式
string. 選擇性。 使用 時 PublishSymbols = true && SymbolServerType = TeamServices。 允許的值: Default (要上傳) 的預設符號集, Pdb (僅限 Pdb 型符號 Windows pdb 和 Managed Portable pdb 的 s.) , SourceMap (僅限 JavaScript 型 SourceMap 符號 (*.js.map) ) , All (所有支援的符號格式) 。 預設值:Default

指定要發佈至符號伺服器的偵錯格式。


DetailedLog - 詳細信息記錄
boolean. 預設值:true

指定詳細信息記錄。


TreatNotIndexedAsWarning - 如果未編製索引,則發出警告
boolean. 預設值:false

指定是否要警告來源是否未為 PDB 檔案編製索引。 否則,訊息會記錄為一般輸出。


UseNetCoreClientTool - 使用 NetCore 用戶端工具
boolean. 預設值:false

指定是否使用支援 DWARF 和 ELF 檔案的符號上傳工具版本。 這個選項僅適用於 Windows 代理程式。 在非 Windows 代理程式上,一律會使用支援 DWARF 和 ELF 檔案的符號上傳工具版本。


SymbolsMaximumWaitTime - 最大等候時間 (分鐘)
string.

指定要在失敗此工作之前等候的分鐘數。


SymbolsProduct - 產品
string.

將 product 參數指定為 symstore.exe。 預設值為 $(Build.DefinitionName)


SymbolsVersion - 版本
string.

將 version 參數指定為 symstore.exe。 預設值為 $(Build.BuildNumber)


SymbolsArtifactName - 成品名稱
string. 預設值:Symbols_$(BuildConfiguration)

指定要用於符號成品的成品名稱。 這應該只與 FileShare 符號伺服器類型搭配使用。 預設為 Symbols_$(BuildConfiguration)


工作控制選項

除了工作輸入之外,所有工作都有控制選項。 如需詳細資訊,請參閱 控制選項和一般工作屬性

輸出變數

無。

備註

使用此工作來編製原始程式碼的索引,並將符號發佈至檔案共用或 Azure Artifacts 符號伺服器。

編製原始程式碼的索引可讓您使用符號檔來偵錯您用來建置應用程式之機器上的應用程式。 例如,您可以從沒有原始程式碼的開發計算機,對組建代理程式所建置的應用程式進行偵錯。

符號伺服器可讓您的調試程序自動擷取正確的符號檔,而不需要知道產品名稱、組建編號或套件名稱。

重要

若要刪除使用 索引來源發行的符號 & 發佈符號 工作,您必須先刪除產生這些符號的組建。 這可以藉由使用 保留 原則或手動 刪除執行來完成。

索引的運作方式為何?

選擇為來源編製索引,會將額外的區段插入 PDB 檔案中。 PDB 檔案通常只包含本機原始程式檔路徑的參考,例如: C:\BuildAgent_work\1\src\MyApp\Program.cs。 插入 PDB 檔案的額外區段包含調試程式的對應指示。 對應資訊會指出如何擷取對應至每個本機路徑的伺服器專案。

Visual Studio 調試程式會使用對應資訊,從伺服器擷取來源檔案。 擷取來源檔案的實際命令會包含在對應資訊中。 範例:

tf.exe git view /collection:http://SERVER:8080/tfs/DefaultCollection /teamproject:"93fc2e4d-0f0f-4e40-9825-01326191395d" /repository:"647ed0e6-43d2-4e3d-b8bf-2885476e9c44" /commitId:3a9910862e22f442cd56ff280b43dd544d1ee8c9 /path:"/MyApp/Program.cs" /output:"C:\Users\username\AppData\Local\SOURCE~1\TFS_COMMIT\3a991086\MyApp\Program.cs" /applyfilters

我可以在從 .NET Core 元件建立的可攜式 PDB 上使用來源索引嗎?

否,但您可以改用 Source Link

符號保留多久?

符號會與發行至 Azure Pipelines 的組建相關聯,這些組建與組建相關聯。 手動或使用保留原則刪除組建時,也會刪除符號。 如果您想要無限期保留符號,請將組建標示為 [無限期保留]。

規格需求

需求 描述
管線類型 YAML、傳統組建
在上執行 Agent、DeploymentGroup
要求
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任何
可設定變數 任何
代理程式版本 2.144.0 或更新版本
工作類別 建置
需求 描述
管線類型 YAML、傳統組建
在上執行 Agent、DeploymentGroup
要求
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任何
可設定變數 任何
代理程式版本 1.95.0 或更新版本
工作類別 建置

另請參閱