Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change the tree structure into which libgit2 binaries are located in …

…order to be able to dynamically bind against 32 or 64 bits version of libgit2

Should partially fix issue #70.
  • Loading branch information...
commit 52de337df846ccc8e20f83dc9b1bffccbe55fd51 1 parent 0200e5f
@nulltoken nulltoken authored
View
7 CI-build.msbuild
@@ -39,5 +39,12 @@
<Target Name="Deploy" DependsOnTargets="Test">
<Copy SourceFiles="@(OutputFiles)"
DestinationFiles="@(OutputFiles->'$(DeployFolder)\%(RecursiveDir)%(Filename)%(Extension)')" />
+
+ <ItemGroup>
+ <NativeBinaries Include="$(TestBuildDir)\NativeBinaries\**\*.*" />
+ </ItemGroup>
+
+ <Copy SourceFiles="@(NativeBinaries)"
+ DestinationFiles="@(NativeBinaries->'$(DeployFolder)\NativeBinaries\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
</Project>
View
1  Lib/NativeBinaries/amd64/dummy.txt
@@ -0,0 +1 @@
+Here will be placed the x64 binaries of libgit2
View
0  Lib/git2.dll → Lib/NativeBinaries/x86/git2.dll
File renamed without changes
View
0  Lib/git2.pdb → Lib/NativeBinaries/x86/git2.pdb
File renamed without changes
View
7 LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
@@ -76,11 +76,12 @@
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
+ <ItemGroup>
+ <NativeBinaries Include="$(MSBuildProjectDirectory)\..\Lib\NativeBinaries\**\*.*" />
+ </ItemGroup>
+ <Copy SourceFiles="@(NativeBinaries)" DestinationFiles="@(NativeBinaries->'$(OutputPath)NativeBinaries\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
- -->
</Project>
View
16 LibGit2Sharp/Core/NativeMethods.cs
@@ -1,4 +1,6 @@
using System;
+using System.IO;
+using System.Reflection;
using System.Runtime.InteropServices;
namespace LibGit2Sharp.Core
@@ -8,6 +10,20 @@ internal static class NativeMethods
public const int GIT_PATH_MAX = 4096;
private const string libgit2 = "git2";
+ static NativeMethods()
+ {
+ string originalAssemblypath = new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath;
+
+ //TODO: When amd64 version of libgit2.dll is available, value this depending of the size of an IntPtr
+ const string currentArchSubPath = "NativeBinaries/x86";
+
+ string path = Path.Combine(Path.GetDirectoryName(originalAssemblypath), currentArchSubPath);
+
+ const string pathEnvVariable = "PATH";
+ Environment.SetEnvironmentVariable(pathEnvVariable,
+ String.Format("{0}{1}{2}", path, Path.PathSeparator, Environment.GetEnvironmentVariable(pathEnvVariable)));
+ }
+
[DllImport(libgit2)]
public static extern IntPtr git_blob_rawcontent(IntPtr blob);
View
13 LibGit2Sharp/LibGit2Sharp.csproj
@@ -121,22 +121,17 @@
<ItemGroup>
<CodeAnalysisDictionary Include="CustomDictionary.xml" />
</ItemGroup>
- <ItemGroup>
- <None Include="..\Lib\git2.dll">
- <Link>git2.dll</Link>
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
- </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
+ <ItemGroup>
+ <NativeBinaries Include="$(MSBuildProjectDirectory)\..\Lib\NativeBinaries\**\*.*" />
+ </ItemGroup>
+ <Copy SourceFiles="@(NativeBinaries)" DestinationFiles="@(NativeBinaries->'$(OutputPath)NativeBinaries\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
- -->
</Project>
View
3  nuget.package/LibGit2Sharp.nuspec
@@ -12,8 +12,7 @@
<tags>libgit2 git wrapper bindings API dvcs vcs</tags>
</metadata>
<files>
- <file src="..\Lib\git2.dll" target="NativeBinaries\x86" />
- <file src="..\Lib\git2.pdb" target="NativeBinaries\x86" />
+ <file src="..\Lib\NativeBinaries\**" target="NativeBinaries" />
<file src="..\README.md" target="App_Readme\LibGit2Sharp.README.md" />
<file src="..\LICENSE.md" target="App_Readme\LibGit2Sharp.LICENSE.md" />
<file src="..\CHANGELOG.md" target="App_Readme\LibGit2Sharp.CHANGELOG.md" />
View
7 nuget.package/Tools/GetLibGit2SharpPostBuildCmd.ps1
@@ -3,6 +3,11 @@ $path = $installPath.Replace($solutionDir, "`$(SolutionDir)")
$NativeAssembliesDir = Join-Path $path "NativeBinaries"
$x86 = $(Join-Path $NativeAssembliesDir "x86\*.*")
+$x64 = $(Join-Path $NativeAssembliesDir "amd64\*.*")
$LibGit2SharpPostBuildCmd = "
-xcopy /s /y `"$x86`" `"`$(TargetDir)`""
+if not exist `"`$(TargetDir)NativeBinaries`" md `"`$(TargetDir)NativeBinaries`"
+if not exist `"`$(TargetDir)NativeBinaries\x86`" md `"`$(TargetDir)NativeBinaries\x86`"
+xcopy /s /y `"$x86`" `"`$(TargetDir)NativeBinaries\x86`"
+if not exist `"`$(TargetDir)NativeBinaries\amd64`" md `"`$(TargetDir)NativeBinaries\amd64`"
+xcopy /s /y `"$x64`" `"`$(TargetDir)NativeBinaries\amd64`""
Please sign in to comment.
Something went wrong with that request. Please try again.