libgit2 / libgit2sharp

Git + .NET = ❤
http://libgit2.github.com
MIT License
3.13k stars 879 forks source link

Can't update LibGit2Sharp.NativeBinaries in VS 2019 v16.11.15 #1970

Closed astrohart closed 2 years ago

astrohart commented 2 years ago

This is related to Issue #1343.

Can't update LibGit2Sharp.NativeBinaries. Are the NuGet packages broken?

Unable to resolve dependencies. 'LibGit2Sharp.NativeBinaries 2.0.315' is not compatible with 'LibGit2Sharp 0.26.2 constraint: LibGit2Sharp.NativeBinaries (= 2.0.306)'.

Per the issue referenced above, I selected "Include Prereleases" as was advised further down the thread of the existing issue.

As can be seen from the screenshot, I tried the update again and I still received an error (see circles):

image

The error message text is:

Unable to resolve dependencies. 'LibGit2Sharp.NativeBinaries 2.0.315' is not compatible with 'LibGit2Sharp 0.26.2 constraint: LibGit2Sharp.NativeBinaries (= 2.0.306)'.

The contents of my packages.config is:

<?xml version="1.0" encoding="utf-8"?>
<packages>
    <package id="AlphaFS" version="2.2.6" targetFramework="net48" />
    <package id="CredentialManagement" version="1.0.2" targetFramework="net48" />
    <package id="LibGit2Sharp" version="0.26.2" targetFramework="net48" />
    <package id="LibGit2Sharp.NativeBinaries" version="2.0.306" targetFramework="net48" />
    <package id="Microsoft.Alm.Authentication" version="4.3.0" targetFramework="net48" />
    <package id="Microsoft.CSharp" version="4.5.0" targetFramework="net48" />
    <package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.13.8" targetFramework="net48" />
    <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
    <package id="NUnit" version="3.13.3" targetFramework="net48" />
    <package id="Octokit" version="0.50.0" targetFramework="net48" />
    <package id="Salaros.ConfigParser" version="0.3.8" targetFramework="net48" />
    <package id="Vsxmd" version="1.4.5" targetFramework="net48" developmentDependency="true" />
</packages>
bording commented 2 years ago

You aren't supposed to update to a newer version of the NativeBinaries package. Each version of LibGit2Sharp is locked to a specific NativeBinaries package, which is what the error message is telling you.

If you want to use the newer NativeBinaries package, you would need to update to the latest pre-release version of LibGit2Sharp.

astrohart commented 2 years ago

To me, it does not matter "what I am or am not supposed to do." Bottom line, the way the package is set up vs. the native binaries breaks the usual NuGet update flow in Visual Studio.

I am all for LibGit2Sharp architecting their code as they please, but the point of this issue is that the current architecture has a flaw in that it breaks the NuGet updater in VS.

Furthermore, as a cybersecurity expert I am personally a strong advocate of always using the latest version of packages/libraries on which I depend in my code. Visual Studio is prompting me to update this package, and this bad architecture is not user-friendly because it breaks the intent of the VS UI/UX and confuses users, draining developer time responding to superfluous issues.

I strongly advocate the developers of this package to ensure that the package, along with whatever Native Binaries etc. are provided, is distributed to create a smooth end-user experience for VS users (developers) whose software solutions depend on this package.

Not doing this, so that the error described in #1343 and this issue comes up always, is bad package design and needs to be addressed. I really could not give a darn as to what I am "supposed to do." I feel strongly that it's incumbent on the designers of this software and the NuGet package to figure this out on the behalf of package consumers and to re-architect this solution accordingly.

astrohart commented 2 years ago

If you want to use the newer NativeBinaries package, you would need to update to the latest pre-release version of LibGit2Sharp.

@bording I am not sure if you read my original post, but I DID attempt to solve the issue by selecting "include pre-release" and then re-trying the upgrade, as can be seen in the screenshot and second error message in my initial post. Including pre-release still did not work.

I also think that it's a horrible idea to "lock" two NuGet packages together. IMHO, if you are dependent on specific versions of the Native Binaries you need to simply distribute those inside the LibGit2Sharp package.

bording commented 2 years ago

The latest version of LibGit2Sharp is 0.27.0-preview-0182, and that version uses 2.0.315-alpha.0.9 of the NativeBinaries package, so that's the version you would upgrade to.

There is not currently a version of the LibGit2Sharp package that uses the 2.0.315 NativeBinaries package because there is still an open PR for updating to it: #1957

I also think that it's a horrible idea to "lock" two NuGet packages together. IMHO, if you are dependent on specific versions of the Native Binaries you need to simply distribute those inside the LibGit2Sharp package.

Agree to disagree on that.

Packages.config is outdated and you should consider moving to PackageReferences instead. With a package reference, you only have a reference to LibGit2Sharp in your project, and the correct NativeBinaries package is brought in transitively.