libgit2 / libgit2/libgit2sharp
LibGit2Sharp can't find native assembly under PowerShell Core
Personne n'a encore pris cette issue.
- Langage dominant
- C#
- Étoiles
- 3.5k
- Forks
- 925
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
I maintain a PowerShell module, GitAutomation, that wraps the LibGit2Sharp library. Yesterday, I was trying to get it to run on PowerShell Core. It doesn't seem to work. It is looking for the native git assembly in the LibGit2Sharp.dll assembly's folder instead of the lib/win32/xXX folder, like it does under Windows PowerShell (.NET Framework).
The issue appears to be your check for whether or not you're running under .NET Core. It looks like you're looking for the Mono.Runtime type, which doesn't exist in the version of .NET Core that PowerShell Core is using.
It looks like the current best way to determine if you're running under .NET Core is to use the System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription property, which begins with .NET Framework when running under the .NET Framework and .NET Core when running under .NET Core.
Windows PowerShell:
$ [Runtime.InteropServices.RuntimeInformation]::FrameworkDescription
.NET Framework 4.7.3260.0
$ [Mono.Runtime]
Unable to find type [Mono.Runtime].
At line:1 char:1
+ [Mono.Runtime]
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Mono.Runtime:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
PowerShell Core
$ [Runtime.InteropServices.RuntimeInformation]::FrameworkDescription
.NET Core 4.6.26919.02
$ [Mono.Runtime]
Unable to find type [Mono.Runtime].
At line:1 char:1
+ [Mono.Runtime]
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Mono.Runtime:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par localiser la vérification à l’exécution et la résolution de l’assembly natif dans le code source de LibGit2Sharp. Reproduisez la recherche sous PowerShell Core et Windows PowerShell, puis vérifiez que l’assembly natif est trouvé dans le dossier lib/win32/xXX dans les deux environnements. Le travail est considéré comme terminé lorsque GitAutomation peut charger LibGit2Sharp sur PowerShell Core.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- csharp, powershell
- Domaine
- devtools
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100