ctaggart / SourceLink

Source Code On Demand
MIT License
356 stars 55 forks source link

New project system does not copy PDBs from packages when targeting .NET Framework #313

Closed ctaggart closed 6 years ago

ctaggart commented 6 years ago

The bug is here https://github.com/dotnet/sdk/issues/1458. This should be added to the Known Issues in the readme. It prevents source linking from working for apps targeting .NET Framework when using the net .NET Core project system.

I logged more info here:

There is a workaround by @jnm2 which involves adding this to your project file:

  <!-- https://github.com/dotnet/sdk/issues/1458 -->
  <PropertyGroup>
    <AllowedReferenceRelatedFileExtensions>.pdb</AllowedReferenceRelatedFileExtensions>
  </PropertyGroup>
  <Target Name="AddReferenceRelatedPathsToCopyLocal" AfterTargets="ResolveAssemblyReferences">
    <ItemGroup>
      <ReferenceCopyLocalPaths Include="@(_ReferenceRelatedPaths)" />
    </ItemGroup>
  </Target>
ctaggart commented 6 years ago

The work-a-round was published as SourceLink.Copy.PdbFiles in February. Simply add it to your project for the work-a-round.

kukjevov commented 6 years ago

I know this is closed, but SourceLink.Copy.PdbFiles does not work anymore with SDK 2.1.300. New workaround is required see below.

<Target Name="_ResolveCopyLocalNuGetPackagePdbs" Condition="$(CopyLocalLockFileAssemblies) == true" AfterTargets="ResolveReferences">
        <ItemGroup>
            <ReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)%(Filename).pdb')" Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != '' and Exists('%(RootDir)%(Directory)%(Filename).pdb')" />
        </ItemGroup>
    </Target>
ctaggart commented 6 years ago

Thanks @kukjevov. Happy to take a pull request.

ctaggart commented 6 years ago

Fixed by @kukjevov in #352. SourceLink.Copy.PdbFiles has the update in 2.8.3:

<Project>
  <ItemGroup>
    <PackageReference Include="SourceLink.Copy.PdbFiles" Version="2.8.3" PrivateAssets="All" /> 
  </ItemGroup>
</Project>