Closed rcdailey closed 3 years ago
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:
Steps:
Follow the README steps for building the project and its packages. Utilized the changes in PR #118 for compatibility with my version of CMake for the 64-bit build of libgit2.
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).
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).
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>
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" />
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.
Visit the publish
directory and observe that the git2-6777db8.pdb
file is no longer present
next to my executable.
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:
being unable to run it due to the missing PDB.
Given https://github.com/libgit2/libgit2sharp.nativebinaries/issues/111#issuecomment-897316837 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.
I'm glad my PR could help push us forward to a solution. Thank you for taking your time to review this!
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:
Fixes #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.