【问题标题】:Go to Implementation with sourcelink使用 sourcelink 转到实施
【发布时间】:2017-12-20 00:42:25
【问题描述】:

如何让 Visual Studio 为使用 SourceLink 公开的库代码“转到实现”?

我们最近开始在我们的 .NETcore 库中使用 SourceLink,以尝试在使用该库时对其进行调试。我们使用这个项目启用了 SourceLink:ctaggart/SourceLink,通过在我们的 csproj 中添加以下行:

<PackageReference Include="SourceLink.Embed.AllSourceFiles" Version="2.6.0" PrivateAssets="All" />

这非常有效,因为我现在可以使用调试器进入库代码,但我无法跳转到任何此库代码的实现/定义。有没有办法让 Visual Studio 做到这一点?

【问题讨论】:

标签: c# visual-studio sourcelink


【解决方案1】:

能够导航到 NuGet 包的源是正在考虑但尚未完成的事情。您可以在https://github.com/dotnet/roslyn/issues/24349 跟踪其进度。

【讨论】:

    【解决方案2】:

    SourceLink 现在是https://github.com/dotnet/sourcelink/ 的一个.NET Foundation 项目。

    首先,配置源链接的行为方式:

    您可以在自己的项目中启用 SourceLink 体验,方法是设置 几个属性并将 PackageReference 添加到 SourceLink 包:

    <Project Sdk="Microsoft.NET.Sdk">
     <PropertyGroup>
        <TargetFramework>netcoreapp2.1</TargetFramework>
    
        <!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
        <PublishRepositoryUrl>true</PublishRepositoryUrl>
    
        <!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
        <EmbedUntrackedSources>true</EmbedUntrackedSources>
    
        <!-- Optional: Include the PDB in the built .nupkg -->
        <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
      </PropertyGroup>
      <ItemGroup>
        <!-- Add PackageReference specific for your source control provider (see below) --> 
      </ItemGroup>
    </Project>
    

    然后,添加与您的存储库匹配的 Source Link 包。软件包目前处于预发布状态,这些是可用的:

    github.com 和 GitHub Enterprise

    <ItemGroup>
        <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
    </ItemGroup>
    

    Visual Studio 团队服务

    <ItemGroup>
        <PackageReference Include="Microsoft.SourceLink.Vsts.Git" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
    </ItemGroup>
    

    团队基础服务器

    <ItemGroup>
        <PackageReference Include="Microsoft.SourceLink.Tfs.Git" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
        <SourceLinkTfsGitHost Include="tfs-server-name" VirtualDirectory="tfs"/>
    </ItemGroup>
    

    GitLab

    <ItemGroup>
        <PackageReference Include="Microsoft.SourceLink.GitLab" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
    </ItemGroup>
    

    Bitbucket.org

    <ItemGroup>
        <PackageReference Include="Microsoft.SourceLink.Bitbucket.Git" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
    </ItemGroup>
    

    【讨论】:

    • 请考虑从与问题相关的链接中添加更多信息。如果链接被删除,它会有所帮助。
    • @MarcoThomazini 这如何回答这个问题?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-14
    • 2019-03-07
    相关资源
    最近更新 更多