我正在尝试让SourceLink与私有NuGet包配合使用。我的netcore2.1 Web应用程序引用了我们Azure Devops NuGet feed上托管的netstandard2.0 NuGet包。
问题1: Source Link是否支持.NET Standard包?
我按照这里的指南https://learn.microsoft.com/en-us/azure/devops/artifacts/symbols/setting-up-github-sourcelinking?view=vsts进行操作,步骤如下:
将索引源和发布符号包添加到我的Azure Devops构建中。
在Visual Studio中,将我们的VSTS服务器添加为符号服务器。
在Visual Studio中启用Source Link支持。我还尝试启用了Source server支持。
构建管道发布符号路径似乎正在工作-在日志中我看到:
Succeeded processing D:\a\1\s\src\MyCompany.Core.Services.SnapshotClient\bin\release\netstandard2.0\MyCompany.Core.Services.SnapshotClient.pdb:
当我开始调试我的应用程序时,在VS输出窗口中会看到一堆输出:
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\2.1.4\Microsoft.AspNetCore.Hosting.dll'. Cannot find or open the PDB file.
对于我的NuGet包,我看到“Symbols loaded”,这似乎是有希望的。
顺便说一下,我没有看到来自Visual Studio的提示“Source Link将从互联网下载”。
当我调试并尝试步入我的NuGet包时,它只是跳过了它。
然后我尝试了:
转到https://github.com/dotnet/sourcelink并按照他们的说明安装了Microsoft.SourceLink.Vsts.Git包(问题2:这是必需的吗?)
当这不起作用时,我升级了我的应用程序中的每个软件包,这迫使我安装.NET Core SDK 2.1.403
在GitHub问题上搜索后,尝试向我的NuGet包的.csproj添加一些内容:
<PublishRepositoryUrl>true</PublishRepositoryUrl> <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
和<DebugType>portable</DebugType> <ci>true</ci>
现在我的.nupkg也包含.pdb文件,之前没有。但仍然无法进行调试。从https://www.nuget.org/packages/sourcelink/安装了sourcelink cli工具,并在我的.nupkg的.pdb上运行
sourcelink print-urls
。URL似乎正确?看到@mitchdenny的评论https://github.com/MicrosoftDocs/vsts-docs/issues/1336#issuecomment-414415049后禁用索引。仍然无效。
现在我迷惑不解为什么它不起作用。