Embedding C# sources in PDB with new csproj

后端 未结 2 1799
无人及你
无人及你 2021-01-12 07:33

The recently-released .NET tooling seem to have support for embedding C# in PDBs, which should improve the experience of stepping into third-party, etc. Running csc /?

相关标签:
2条回答
  • 2021-01-12 08:09

    Looks like the roslyn task should support them via the EmbeddedFiles Item Group, by adding this to your .csproj:

    <Target Name="EmbedSources" BeforeTargets="CoreCompile">
       <ItemGroup>
          <EmbeddedFiles Include="@(Compile) " />
       </ItemGroup>
    </Target>
    

    ... which is basically what the /embed option does.

    You probably need to also provide a SourceLink json file, to wire up the sources in the PDB, not sure that happens automatically.

    0 讨论(0)
  • 2021-01-12 08:20

    There's now a proper MSBuild EmbedAllSources property:

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
        <EmbedAllSources>true</EmbedAllSources>
        [...]
    

    From what I observed locally, it behaves the same as the mentioned EmbedFiles target.

    0 讨论(0)
提交回复
热议问题