Skip to content

Conversation

@rcdailey
Copy link

  • Upgrade nuget.exe to version 5.10.0.7240

    Newest version ensures best compatibility with nuget.org and support for
    symbol packages.

  • Move libgit2 PDB files to legacy symbol package

    Nuget supports two types of symbol packages: legacy and
    snuget. The latter happens to be the newer implementation. Legacy
    symbol packages only exist for compatibility.

    It should be noted that, unfortunately, snuget symbol packages do not
    support Windows PDBs (the kind you get from C++ code). They only support
    portable PDBs (managed). As such, this patch provides support for legacy
    symbol package format. Note the following information from the symbol
    package MSDN documentation page:

    Native projects, such as C++ projects, produce Windows PDBs instead of
    Portable PDBs. These are not supported by NuGet.org's symbol server.
    Please use Legacy Symbol Packages instead.

    Fixes PDB file should never be a required dependency to run app #111

  • Add a script to publish the nuget package

    Is capable of publishing the nuget package and the symbol package.
    Supports local paths (for testing with a local nuget repository) and
    remote URLs.

    The command follows Microsoft conventions for Powershell scripts,
    including Get-Help support for command line documentation.

rcdailey added 3 commits July 31, 2021 18:52
Newest version ensures best compatibility with nuget.org and support for
symbol packages.
Nuget supports two types of symbol packages: [legacy][1] and
[snuget][2]. The latter happens to be the newer implementation. Legacy
symbol packages only exist for compatibility.

It should be noted that, unfortunately, snuget symbol packages do not
support Windows PDBs (the kind you get from C++ code). They only support
portable PDBs (managed). As such, this patch provides support for legacy
symbol package format. Note the following information from the symbol
package MSDN documentation page:

> Native projects, such as C++ projects, produce Windows PDBs instead of
> Portable PDBs. These are not supported by NuGet.org's symbol server.
> Please use Legacy Symbol Packages instead.

Fixes libgit2#111

[1]: https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages
[2]: https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg
Is capable of publishing the nuget package *and* the symbol package.
Supports local paths (for testing with a local nuget repository) and
remote URLs.

The command follows Microsoft conventions for Powershell scripts,
including `Get-Help` support for command line documentation.
@rcdailey
Copy link
Author

rcdailey commented Aug 1, 2021

Let me explain the testing I did for this. If additional testing is needed, please let me know and
I'll see if I'm able to do that for you.

First, my build and test environment:

  • Windows 10 x64
  • Visual Studio 2019 (16.10.4)
  • CMake v3.21.1
  • Powershell Core 7.1.3

Steps:

  1. Follow the README steps for building the project and its packages. Utilized the changes in
    PR Build is compatible with CMake 3.21.1 #118 for compatibility with my version of CMake for the 64-bit build of libgit2.

  2. Build the packages with .\buildpackage.ps1 2.1.0-test (latest stable release is 2.0.x, so I
    used 2.1 to ensure my local package took precedence if needed).

  3. Published the package to a local nuget repository using command .\Publish-Package.ps1 E:\code\nuget\repo\ E:\code\nuget\symbols\ (symbols and package go to different locations).

  4. Edit my %appdata%\NuGet\NuGet.Config file so that it includes my local nuget repository:

    <packageSources>
      <add key="local" value="E:\code\nuget\repo" />
      <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    </packageSources>
  5. In the project I have that consumes the libgit2sharp project, add an explicit dependency on the
    register binaries package to override the implicit dependency on the 2.0.x version. This
    generates some warnings at build time, but these can be ignored for the purposes of this test:

    <PackageReference Include="LibGit2Sharp" Version="0.*-*" />
    <PackageReference Include="LibGit2Sharp.NativeBinaries" Version="2.1.0-test" />
  6. Run the following command to build and publish a single executable binary of my project. Not all
    of these options may be necessary to reproduce the issue. This is intended to be comprehensive
    and representative of my specific scenario.

    dotnet publish src\Trash `
        --output publish `
        --configuration Release `
        --runtime win-x64 `
        --self-contained true `
        -p:PublishSingleFile=true `
        -p:PublishTrimmed=true `
        -p:IncludeNativeLibrariesForSelfExtract=true `
        -p:PublishReadyToRun=true `
        -p:PublishReadyToRunShowWarnings=true

    The full contents of the script where the above command was taken is visible in my public
    repository here.

  7. Visit the publish directory and observe that the git2-6777db8.pdb file is no longer present
    next to my executable.

  8. Execute my program and observe that it successfully runs now without errors related to the PDB
    file missing.

I'm obviously missing tests for the symbol package itself here. I did enough testing to verify that
the symbol package is published, however:

  1. I'm not certain if there's even a real use for the symbols by the developers. It could be that
    the PDBs getting included in the build were collateral damage. If not, I'd love to learn more
    about the use case for these to ensure that the packages themselves are functional.
  2. My particular use case was only interested in removing the PDB files for reasons explained in
    PDB file should never be a required dependency to run app #111. My particular product was deployed with libgit2sharp included, but many people reported
    being unable to run it due to the missing PDB.

@bording
Copy link
Member

bording commented Aug 12, 2021

Given #111 (comment) and the changes I made in #121, we're not going to need this PR.

Instead, I've just remove the PDBs from the package entirely, which should also solve the problem without needing to introduce symbol packages.

Thanks for the effort on this and the information about the workaround not being valid for .NET 5.

@bording bording closed this Aug 12, 2021
@rcdailey
Copy link
Author

I'm glad my PR could help push us forward to a solution. Thank you for taking your time to review this!

Viir added a commit to pine-vm/pine that referenced this pull request Aug 16, 2021
The single-file build functionality in .NET 5 did not work well with earlier versions of libgit2sharp. Let's see if our build works with this version and .NET 5 or .NET 6.
For discussion of the errors we got when trying .NET 5 with earlier versions of libgit2sharp, see libgit2/libgit2sharp#1857, libgit2/libgit2sharp.nativebinaries#111,
libgit2/libgit2sharp.nativebinaries#119, dotnet/sdk#3685, and dotnet/runtime#36590
Viir added a commit to pine-vm/pine that referenced this pull request Aug 16, 2021
The single-file build functionality in .NET 5 did not work well with earlier versions of libgit2sharp. Let's see if our build works with this version and .NET 5 or .NET 6.
For discussion of the errors we got when trying .NET 5 with earlier versions of libgit2sharp, see libgit2/libgit2sharp#1857, libgit2/libgit2sharp.nativebinaries#111,
libgit2/libgit2sharp.nativebinaries#119, dotnet/sdk#3685, and dotnet/runtime#36590
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDB file should never be a required dependency to run app

2 participants