如何为VisualLink公开的库代码启用visual studio“Go to implementation”?
我们最近开始在我们的.NETcore库中使用SourceLink,试图在使用它时调试库。我们使用此项目启用了SourceLink:ctaggart/SourceLink通过在csproj中添加以下行:
<PackageReference Include="SourceLink.Embed.AllSourceFiles" Version="2.6.0" PrivateAssets="All" />
这很有效,我现在可以使用调试器进入库代码,但是我无法跳转到任何这个库代码的实现/定义。有没有办法让视觉工作室做到这一点?
答案 0 :(得分:2)
SourceLink现在是位于https://github.com/dotnet/sourcelink/的.NET Foundation项目。
首先,配置Source Link的行为:
您可以通过设置自己的项目来启用SourceLink体验 一些属性,并向SourceLink包中添加PackageReference:
<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>
Team Foundation Server
<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>
答案 1 :(得分:1)
能够导航到NuGet包的来源是正在考虑但尚未完成的事情。您可以在https://github.com/dotnet/roslyn/issues/24349上跟踪其进度。