无法从私有的Azure仓库调试包。

huangapple go评论55阅读模式
英文:

Unable to debug package from private Azure Repo

问题

我有一个项目,我发布到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>

现在,我还想发布适当的符号以便调试该包。因此,我按照 https://learn.microsoft.com/azure/devops/pipelines/artifacts/symbols?view=azure-devops#publish-portable-pdbs-to-azure-artifacts-symbol-server 中的说明进行了操作。我的流水线包含以下内容:

steps:
... 省略部分内容
- 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'

当我调试引用该包的应用程序并查看当前加载的模块时,我看到我的包及其符号已被加载。然而,当我尝试进入其中的任何类型时,什么都不会发生,调试器会跳到我的应用程序的下一行。

这是我用于调试的VS设置:

无法从私有的Azure仓库调试包。

如您所见,“仅我的代码”被禁用,而“Source link support”以及“Source server support”都已启用。

我还尝试将我的项目的DebugType设置为embedded,以将PDB嵌入到程序集中。但是这并没有改变任何事情。符号已加载,但某种原因SourceLink无法从中获取信息。

编辑:我的包部署为Release配置,而不是Debug

英文:

I have a project that I publish to Azure Artifacts:

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

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: &#39;build&#39;
    projects: &#39;**/*.csproj&#39;
    arguments: &#39;--configuration Release&#39;
- task: DotNetCoreCLI@2
  inputs:
    command: &#39;pack&#39;
    packagesToPack: &#39;**/*.csproj&#39;
    nobuild: true
    includesymbols: true
    versioningScheme: &#39;off&#39;
- task: DotNetCoreCLI@2
  inputs:
    command: &#39;push&#39;
    packagesToPush: &#39;$(Build.ArtifactStagingDirectory)/*.nupkg&#39;
    nuGetFeedType: &#39;internal&#39;
    publishVstsFeed: &#39;myfeed&#39;
- task: PublishSymbols@2
  inputs:
    SearchPattern: &#39;**/bin/**/*.pdb&#39;
    IndexSources: false
    SymbolServerType: &#39;TeamServices&#39;

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:

无法从私有的Azure仓库调试包。

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

得分: 1

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

    • "仔细检查来自 Claire Novotny(在 Microsoft 的 @dotnet 团队上担任 PM 角色)的 2020 年文章:"
  • "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."

    • "还要检查构建日志,查看与 PDB 文件发布相关的任何问题。"
  • "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 -&gt; Options -&gt; Debugging -&gt; General and uncheck the "Enable Just My Code" box if it is checked."

    • "“只有我的代码”是一个调试器功能,启用后,调试器会忽略不是您自己的代码。请在 工具 -&gt; 选项 -&gt; 调试 -&gt; 一般 中检查此设置,并取消选中“启用只有我的代码”的框(如果已选中)。
  • "You have enabled EmbedUntrackedSources, which is usually a good idea, but if the sources are not being embedded correctly, it could cause issues."

    • "您已启用了 EmbedUntrackedSources,这通常是一个不错的想法,但如果源代码没有正确嵌入,可能会导致问题。"
  • "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."

    • "要检查 PDB 文件并查看它们包含的信息,您需要使用专用工具,如 dotPeekPDB2PDB,尽管后者最近已归档。这些工具可以帮助您验证 PDB 文件是否包含了预期的调试信息和源代码路径。"
  • "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."

    • "源链接很有用,因为它将源代码控制信息嵌入到 PDB 文件中,使调试器能够从源代码控制系统中获取正确版本的源代码。"
  • "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."

    • "听起来是一个不错的计划。如果“只有我的代码”已禁用,而“源链接支持”已启用,那么您的 Visual Studio 设置似乎是正确的。"
  • "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."

    • "PDB 文件(符号)必须与它们构建的 DLL 文件(编译代码)完全匹配。如果不匹配,调试器将无法使用 PDB 文件进入代码。"
  • "the PDB files are being published to the symbol server in your Azure Pipelines configuration."

    • "PDB 文件正在发布到 Azure Pipelines 配置中的符号服务器。"
  • "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 &gt; Options &gt; Debugging &gt; Output Window &gt; Module Load Messages and setting it to Verbose. This could provide more information on what's happening when the symbols are loaded."

    • "一旦您确认了这些要点,如果仍然遇到问题,您可以尝试以更详细的日志级别进行调试。在 Visual Studio 中,您可以通过导航到 调试 &gt; 选项 &gt; 调试 &gt; 输出窗口 &gt; 模块加载消息 并将其设置为 详细 来启用符号加载日志记录。这可能会提供有关符号加载时发生的情况的更多信息。"
  • "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."

    • "您还可以在调试过程中在 模块 窗口中手动加载特定模块的符号。右键单击模块,然后选择 加载符号。如果符号未加载或出现错误,这可能会提供有关问题的更多信息。"
英文:

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 -&gt; Options -&gt; Debugging -&gt; 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 &gt; Options &gt; Debugging &gt; Output Window &gt; 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.

huangapple
  • 本文由 发表于 2023年6月1日 19:31:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76381413.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定