Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

help enable source link for Paket #181

Closed
ctaggart opened this issue Mar 26, 2017 · 5 comments
Closed

help enable source link for Paket #181

ctaggart opened this issue Mar 26, 2017 · 5 comments

Comments

@ctaggart
Copy link
Owner

Progress is in fsprojects/Paket#2200

I'm a bit confused why there is a document with a blank guid showing up.

2 Documents with errors:
 00000000-0000-0000-0000-000000000000 fsharp C:\Users\CameronTaggart\fs\Paket\src\Paket.Core\unknown
https://raw.githubusercontent.com/fsprojects/Paket/76f174ba5f033f63237cebc7f70211e65c582f29/src/Paket.Core/unknown
error: url failed NotFound: Not Found
43344be7465a330ca6145cf1f6064a2f md5 fsharp C:\Users\CameronTaggart\fs\Paket\paket-files\fsharp\FAKE\src\app\FakeLib\Globbing\Globbing.fs
https://raw.githubusercontent.com/fsprojects/Paket/76f174ba5f033f63237cebc7f70211e65c582f29/paket-files/fsharp/FAKE/src/app/FakeLib/Globbing/Globbing.fs
error: url failed NotFound: Not Found
sourcelink test failed
@ctaggart
Copy link
Owner Author

Solved the uknown file with #183.

@ctaggart
Copy link
Owner Author

ctaggart commented Apr 1, 2017

The pull request is working. Here are some notes. I switched the AppVeyor build to VS 2017 in appveyor.yml:

os: Visual Studio 2017
init:
  - git config --global core.autocrlf input

I added the equivalent of msbuild /t:Restore in build.fsx:

Target "MSBuildRestore" (fun _ ->
    !! solutionFile
    |> Seq.iter (build (fun p -> {p with RestorePackagesFlag=true; Targets=["Restore"]}))
)

Target "Build" (fun _ ->
    if isMono then
        !! solutionFile
        |> MSBuildReleaseExt "" [
                "VisualStudioVersion", "14.0"
                "ToolsVersion"       , "14.0"  
        ] "Rebuild"
        |> ignore
    else
        !! solutionFile
        |> MSBuildReleaseExt "" [] "Rebuild"
        |> ignore
)

I worked around a MSBuild 15 bug with restore by referencing Microsoft.NuGet.Build.Tasks.Workaround. I worked around dotnet tools not working with F# projects by creating and using SourceLink.Create.CommandLine instead of SourceLink.Create.GitHub. These are both in Directory.Build.props:

<Project>
  <PropertyGroup>
    <DebugType>portable</DebugType>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="SourceLink.Create.CommandLine" Version="2.1.0" PrivateAssets="all" />
    <PackageReference Include="Microsoft.NuGet.Build.Tasks.Workaround" Version="*" PrivateAssets="all" />
  </ItemGroup>
</Project>

SourceLink.Create.GitHub embeds files not in the repository automatically, but SourceLink.Create.CommandLine can't do that. To get the source files from paket-files embedded in the pdb, I created an EmbedPaketFiles target that gets automatically run using Directory.Build.targets:

<Project>
  <PropertyGroup>
    <BuildDependsOn>EmbedPaketFiles;$(BuildDependsOn)</BuildDependsOn>
  </PropertyGroup>
  <Target Name="EmbedPaketFiles">
    <ItemGroup>
      <EmbeddedFiles Include="$([System.IO.Path]::GetFullPath('%(Compile.Identity)'))"
        Condition="$([System.String]::Copy('%(Identity)').Contains('paket-files'))" />
    </ItemGroup>
    <CreateProperty Value="@(EmbeddedFiles)">  
      <Output TaskParameter="Value" PropertyName="embed" />  
    </CreateProperty>
  </Target>
</Project>

I wish F# would have been consistent with the C# MSBuild targets by using @(EmbeddedFiles) too and not requiring full paths.

@ctaggart
Copy link
Owner Author

ctaggart commented May 6, 2017

This is in Packet.Core
fsprojects/Paket@4ca52a4
first tag is 5.0.0-alpha013

Added the pdb files to the nupkg:
fsprojects/Paket#2313

@ctaggart
Copy link
Owner Author

ctaggart commented May 6, 2017

Going to need to

nuget install paket.core -pre
dotnet sourcelink test .\Paket.Core.5.0.0-alpha013\Paket.Core.5.0.0-alpha013.nupkg
dotnet sourcelink test .\Paket.Core.5.0.0-alpha013\lib\net45\Paket.Core.pdb

dotnet sourcelink print-json .\Paket.Core.5.0.0-alpha013\lib\net45\Paket.Core.pdb
Source Link JSON not found in file: .\Paket.Core.5.0.0-alpha013\lib\net45\Paket.Core.pdb

We should add a test to the build.

@ctaggart
Copy link
Owner Author

fsprojects/Paket#2313 shows how to add the portable pdb files to nuget package using both paket pack and dotnet pack. The dotnet pack uses an MSBuild ItemGroup labeled dotnet pack instructions as described in https://docs.microsoft.com/en-us/dotnet/articles/core/tools/extensibility.

Paket.Core.fsproj

  <ItemGroup Label="dotnet pack instructions">
    <Content Include="$(OutputPath)Paket.Core.pdb">
      <Pack>true</Pack>
      <PackagePath>lib/netstandard1.6</PackagePath>
    </Content>
  </ItemGroup>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant