libgit2 / libgit2sharp

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

.NET Standard support? #2073

Closed holc-tkomp closed 3 months ago

holc-tkomp commented 6 months ago

We're using LibGit2Sharp in our internal nuget package, which targets netstandard2.0 and net461.

LibGit2Sharp 0.27.0+ no longer targets netstandard, which prevents us from upgrading it. We need to update native libgit binaries, as git2-106a5f2.dll contains known vulnerabilities.

Why .NET Standard support was removed? Are there any plans to bring it back?

Is there a way to use newer native binaries with older libgit2sharp?

Version of LibGit2Sharp (release number or SHA1)

0.26.2 - Can't upgrade to anything higher due to reason above. git2-106a5f2.dll

msedi commented 3 months ago

I agree. I think the package should have have no strong dependencies on high level .NET and C# features.

bording commented 3 months ago

LibGit2Sharp needs access to APIs to manage the native library that are not part of .NET Standard, so that is why it has moved on past having a netstandard2.0 target. It needs to have logic that is aware of what framework it is being executed on.

.NET Standard 2.0 was a useful abstraction when it was released, but it was a single point in time, and things have moved on. See this article for more information.

msedi commented 3 months ago

.NET Standard 2.0 was a useful abstraction when it was released, but it was a single point in time, and things have moved on. See this article for more information.

I see your point. The problem is though that Visual Studio is still working on Framework 4.8 and build tool tasks/source generators are still on NET Standard 2.0. I was trying to use libgit2 for MSBuild tool tasks or for source generator, now it is not possible anymore.

bording commented 3 months ago

I see your point. The problem is though that Visual Studio is still working on Framework 4.8 and build tool tasks/source generators are still on NET Standard 2.0. I was trying to use libgit2 for MSBuild tool tasks or for source generator, now it is not possible anymore.

MSBuild task assemblies should be targeting net472, not netstandard2.0, especially when they have dependencies. You should be multitargeting them to something like net472;net6.0 to support VS and a .NET SDK.

I would highly recommend against trying to use LibGit2Sharp in a source generator. It's way too heavy for that scenario.