libgit2 / libgit2/libgit2sharp

LibGit2Sharp can't find native assembly under PowerShell Core

Ouverte
#1,721 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

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

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. 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

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.