Skip to content

Commit 267041e

Browse files
committed
Generate nativeLibraries from package information
1 parent 59bfde3 commit 267041e

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

LibGit2Sharp/NativeLibraryPathResolver.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77

88
namespace LibGit2Sharp
99
{
10-
static class NativeLibraryPathResolver
10+
static partial class NativeLibraryPathResolver
1111
{
12-
static readonly HashSet<string> nativeLibraries = new HashSet<string> { "debian.9-x64", "fedora-x64", "linux-x64", "osx", "rhel-x64", "win-x64", "win-x86" };
13-
1412
public static string GetNativeLibraryDefaultPath()
1513
{
1614
var runtimeIdentifier = RuntimeEnvironment.GetRuntimeIdentifier();

Targets/CodeGenerator.targets

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,37 @@
66

77
<Target Name="DefineProperties">
88
<PropertyGroup>
9+
<NativeLibraryPathResolverPath>$(IntermediateOutputPath)NativeLibraryPathResolver.g.cs</NativeLibraryPathResolverPath>
910
<UniqueIdentifierPath>$(IntermediateOutputPath)UniqueIdentifier.g.cs</UniqueIdentifierPath>
1011
<AssemblyCommitIdsPath>$(IntermediateOutputPath)AssemblyCommitIds.g.cs</AssemblyCommitIdsPath>
1112
</PropertyGroup>
1213
</Target>
1314

1415

16+
<Target Name="GenerateNativeLibraryPathResolverCs" Inputs="$(libgit2_propsfile)" Outputs="$(NativeLibraryPathResolverPath)" BeforeTargets="CoreCompile" DependsOnTargets="DefineProperties">
17+
18+
<PropertyGroup>
19+
<NativeLibraryPathResolverSourceLines>
20+
namespace LibGit2Sharp
21+
{
22+
static partial class NativeLibraryPathResolver
23+
{
24+
static readonly System.Collections.Generic.HashSet&lt;string&gt; nativeLibraries = new System.Collections.Generic.HashSet&lt;string&gt; { @(libgit2_rid, ', ') }%3b
25+
}
26+
}
27+
</NativeLibraryPathResolverSourceLines>
28+
</PropertyGroup>
29+
30+
<WriteLinesToFile File="$(NativeLibraryPathResolverPath)" Lines="$(NativeLibraryPathResolverSourceLines)" Overwrite="true" />
31+
32+
<ItemGroup>
33+
<Compile Include="$(NativeLibraryPathResolverPath)" />
34+
<FileWrites Include="$(NativeLibraryPathResolverPath)" />
35+
</ItemGroup>
36+
37+
</Target>
38+
39+
1540
<Target Name="GenerateUniqueIdentifierCs" Inputs="$(MSBuildThisFileFullPath);$(MSBuildAllProjects);@(Compile)" Outputs="$(UniqueIdentifierPath)" BeforeTargets="CoreCompile" DependsOnTargets="DefineProperties">
1641

1742
<PropertyGroup>

0 commit comments

Comments
 (0)