2

我在我的 csproj 中启用了源链接并使用 github 操作来发布我的 nuget,但添加了PublishRepositoryUrl属性并引用了Microsoft.SourceLink.GitHub包。

但是,当我引用包时,我无法进入代码,也无法进行定义:

<Project Sdk="Microsoft.NET.Sdk.Razor">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    <PackageProjectUrl>https://github.com/Liero/vNext.BlazorComponents</PackageProjectUrl>
    <PublishRepositoryUrl>true</PublishRepositoryUrl>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
  </ItemGroup>

</Project>

我错过了什么?所有源代码都可以在这里找到https://github.com/Liero/vNext.BlazorComponents

编辑:当我运行一个引用包的项目时,看起来符号是根据调试输出加载的:

'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\5.0.3\Microsoft.AspNetCore.Components.Web.dll'. Symbol loading disabled by Include/Exclude setting.
'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Projects\liero\BlazorComponents\BlazorApp1\bin\Debug\net5.0\vNext.BlazorComponents.dll'. 

我还在 Visual Studio 中禁用了我的代码调试。

如果有人想尝试,以下是重现的步骤:

  1. 在 Visual Studio 中创建新的 Blazor 项目

  2. 添加对 vNext.BlazorComponents 的包引用

  3. 修改 index.razor:

     @page "/"
     @using vNext.BlazorComponents.Grid
    
     <SimpleGrid TRow="object" @ref="grid"></SimpleGrid>
    
     @code {
         SimpleGrid<object> grid;
    
             protected override void OnAfterRender(bool firstRender)
             {
                 base.OnAfterRender(firstRender);
                 grid.Refresh(); // put breakpoint here and step into
             }
     }
    
  4. 运行应用程序

4

2 回答 2

2
<PublishRepositoryUrl>true</PublishRepositoryUrl>

<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />

是不足够的。我还必须补充:

<PropertyGroup>
  <EmbedUntrackedSources>true</EmbedUntrackedSources>
  <DebugType>embedded</DebugType>
</PropertyGroup>  

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
  <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

然后我能够进入从 github 下载的 nuget 源

于 2021-02-24T12:05:29.020 回答
1

SourceLink 需要编辑器的支持。VS2019,Rider 支持,VS code 不支持。要在 VS2019 内部启用调试,请在内部Just my code禁用Tool - options - debugging - general 在此处输入图像描述

于 2021-02-24T09:56:21.113 回答