forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeGenerator.targets
More file actions
89 lines (82 loc) · 3.69 KB
/
CodeGenerator.targets
File metadata and controls
89 lines (82 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?xml version="1.0" encoding="utf-8"?>
<Project InitialTargets="GenerateCodeFirst">
<PropertyGroup>
<CodeGenerationOutputPath>$(MSBuildProjectDirectory)\..\lkg\</CodeGenerationOutputPath>
</PropertyGroup>
<ItemGroup>
<GeneratorAssemblySearchPaths Include="$(CodeGenerationOutputPath)">
<Visible>false</Visible>
</GeneratorAssemblySearchPaths>
</ItemGroup>
<!-- Related to https://github.com/dotnet/sdk/issues/939, this carefully written ProjectReference
allows MSBuild to get the build order right without given nuget grief at the command line.
Sadly, it still causes failures when run in VS or Travis CI: https://travis-ci.org/libgit2/libgit2sharp/jobs/220381005#L788
So instead, we control build ordering in VS via a project dependency expressed in the SLN file,
and a preliminary build of the project referenced below in Travis and AppVeyor.
<ItemGroup>
<ProjectReference Include="..\CodeGeneration\CodeGeneration.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
<UndefineProperties>TargetFramework</UndefineProperties>
<Properties>Configuration=$(CodeGeneratorConfiguration);Platform=AnyCPU</Properties>
</ProjectReference>
</ItemGroup>
-->
<Target Name="GenerateCodeFirst">
<PropertyGroup>
<CoreCompileDependsOn>$(CoreCompileDependsOn);GenerateNativeDllNameCs</CoreCompileDependsOn>
<PrepareResourceNamesDependsOn>GenerateCommitIdVersion;$(PrepareResourceNamesDependsOn)</PrepareResourceNamesDependsOn>
<NativeDllNamePath>$(IntermediateOutputPath)NativeDllName.cs</NativeDllNamePath>
<UniqueIdentifierPath>$(IntermediateOutputPath)UniqueIdentifier.cs</UniqueIdentifierPath>
<CommitIdVersionPath>$(IntermediateOutputPath)libgit2sharp_hash.txt</CommitIdVersionPath>
</PropertyGroup>
</Target>
<Target Name="GenerateNativeDllNameCs"
Inputs="@(EmbeddedResource)"
Outputs="$(NativeDllNamePath)">
<ReadLinesFromFile File="@(EmbeddedResource)"
Condition=" '%(Filename)%(Extension)' == 'libgit2_filename.txt' ">
<Output TaskParameter="Lines" PropertyName="libgit2FileName" />
</ReadLinesFromFile>
<PropertyGroup>
<NativeDllNameSourceLines>
namespace LibGit2Sharp.Core
{
internal static class NativeDllName
{
public const string Name = "$(libgit2FileName)"%3b
}
}
</NativeDllNameSourceLines>
</PropertyGroup>
<WriteLinesToFile File="$(NativeDllNamePath)"
Lines="$(NativeDllNameSourceLines)"
Overwrite="true" />
<ItemGroup>
<Compile Include="$(NativeDllNamePath)" />
<FileWrites Include="$(NativeDllNamePath)" />
</ItemGroup>
</Target>
<Target Name="AddNativeDllCommitShaToBuildMetadata"
BeforeTargets="GetBuildVersion"
Condition=" '$(IsCrossTargetingBuild)' != 'true' ">
<ReadLinesFromFile File="@(EmbeddedResource)"
Condition=" '%(Filename)%(Extension)' == 'libgit2_hash.txt' ">
<Output TaskParameter="Lines" PropertyName="libgit2hash" />
</ReadLinesFromFile>
<ItemGroup>
<BuildMetadata Include="LibGit2-$(libgit2hash.Substring(0,7))" />
</ItemGroup>
</Target>
<Target Name="GenerateCommitIdVersion"
DependsOnTargets="GetBuildVersion">
<WriteLinesToFile File="$(CommitIdVersionPath)"
Lines="$(GitCommitId)"
Overwrite="true" />
<ItemGroup>
<EmbeddedResource Include="$(CommitIdVersionPath)">
<LogicalName>$(RootNamespace).libgit2sharp_hash.txt</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Target>
</Project>