【问题标题】:SourceLink in VSTSVSTS 中的 SourceLink
【发布时间】:2017-08-22 10:00:11
【问题描述】:

我正在尝试使用 https://github.com/ctaggart/SourceLink 将 SourceLink 集成到 Visual Studio Team Services 我遇到了问题,因为该包似乎无法解析 VSTS 存储库的 URL。

Build started 8/22/2017 11:58:18 AM.
 1>Project "D:\Repos\Core\classic-stats\src\Acme.Stats\Acme.Stats.csproj" on node 1 (Build target(s)).
 1>SourceLinkCreate:
     git rev-parse --show-toplevel
     D:/Repos/Core/classic-stats
     git config --get remote.origin.url
     https://acme.visualstudio.com/DefaultCollection/Core/_git/classic-stats
     git rev-parse HEAD
     8c6a68b325cf10b67332aa2ea15db952a88d027d
     SourceLinkUrl:
     unable to convert OriginUrl: https://acme.visualstudio.com/DefaultCollection/Core/_git/classic-stats
 1>Done Building Project "D:\Repos\Core\classic-stats\src\Acme.Stats\Acme.Stats.csproj" (Build target(s)) -- FAILED.

Build FAILED.
0 Warning(s)
0 Error(s)

AFAIK 只支持 GitHub 和 BitBucket,对吗? 有没有人能够将它集成到 TFS 构建中? 谢谢

【问题讨论】:

  • 开箱即用,它内置了对 GitHub 和 BitBucket 的支持,可以从 remote.origin.url 创建 SourceLinkUrl。如果您知道它应该是什么,您可以设置 SourceLinkUrl。如果那是一个私有存储库,它还不能工作。查看已知问题。 github.com/ctaggart/SourceLink#known-issues
  • 检查github.com/dotnet/sourcelink是否支持VSTS

标签: sourcelink


【解决方案1】:

正如 Skorunka 在 his comment 中所说,SourceLink 现在支持 VSTS(最近更名为 Azure DevOps

在您的项目中安装 Microsoft.SourceLink.Vsts.Git Microsoft.SourceLink.AzureRepos.Git 包并将以下内容添加到您的 .csproj 文件中

<PropertyGroup>
    [...]
    <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
    <PublishRepositoryUrl>true</PublishRepositoryUrl>
    <EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

使用dotnet pack 命令配置您的构建管道以生成您的 Nuget 包。 SourceLink 不适用于Nuget pack(基于我的测试)。

将您的更改推送到您的 Azure DevOps 服务器,让构建管道生成您的 Nuget 包并将其推送到您的 Nuget 源。

在 Visual Studio 中转到 tools -&gt; Option -&gt; Debugging -&gt; General 并确保

  • Enable just my code 未选中
  • Enable SourceLink support 已检查

然后在任何其他项目中,安装你的 Nuget 包。

当您尝试单步执行在包的 DLL 中定义的某些代码时,Visual Studio 会询问您是否想要 Download source code and continue debugging。它将使用您的 Git 凭据向您的 Azure DevOps 服务器进行身份验证,下载源代码并让您对其进行调试。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多