forked from martincostello/project-euler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Directory.Build.targets
50 lines (50 loc) · 2.77 KB
/
Directory.Build.targets
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
<Project>
<PropertyGroup>
<CommitBranch Condition=" '$(CommitBranch)' == '' ">$(APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH)</CommitBranch>
<CommitBranch Condition=" '$(CommitBranch)' == '' ">$(APPVEYOR_REPO_BRANCH)</CommitBranch>
<CommitBranch Condition=" '$(CommitBranch)' == '' ">$(BUILD_SOURCEBRANCHNAME)</CommitBranch>
<CommitBranch Condition=" '$(CommitBranch)' == '' ">$(TRAVIS_PULL_REQUEST_BRANCH)</CommitBranch>
<CommitBranch Condition=" '$(CommitBranch)' == '' ">$(TRAVIS_BRANCH)</CommitBranch>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<Target Name="AddGitMetadaAssemblyAttributes"
BeforeTargets="CoreGenerateAssemblyInfo"
Condition=" '$(GenerateGitMetadata)' == 'true' ">
<Exec Command="git rev-parse HEAD" ConsoleToMSBuild="true" StandardOutputImportance="low" IgnoreExitCode="true" Condition=" '$(CommitHash)' == '' ">
<Output TaskParameter="ConsoleOutput" PropertyName="CommitHash" />
</Exec>
<Exec Command="git rev-parse --abbrev-ref HEAD" ConsoleToMSBuild="true" StandardOutputImportance="low" IgnoreExitCode="true" Condition=" '$(CommitBranch)' == '' ">
<Output TaskParameter="ConsoleOutput" PropertyName="CommitBranch" />
</Exec>
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>BuildTimestamp</_Parameter1>
<_Parameter2>$([System.DateTime]::UtcNow.ToString(yyyy-MM-ddTHH:mm:ssK))</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition=" $(CommitHash) != '' ">
<_Parameter1>CommitHash</_Parameter1>
<_Parameter2>$(CommitHash)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition=" $(CommitBranch) != '' ">
<_Parameter1>CommitBranch</_Parameter1>
<_Parameter2>$(CommitBranch)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
</Target>
<Target Name="GitMetadataAssemblyInfoCacheFileFix"
BeforeTargets="CreateGeneratedAssemblyInfoInputsCacheFile"
Condition=" '$(GenerateGitMetadata)' == 'true' ">
<ItemGroup>
<AssemblyAttribute Include="TemporaryAdditionalHashItem" Condition=" $(CommitHash) != '' or $(CommitBranch) != '' ">
<_Parameter1>$(CommitHash);$(CommitBranch)</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Target>
<Target Name="CleanupTemporaryAdditionalHashItem"
AfterTargets="CreateGeneratedAssemblyInfoInputsCacheFile;AddGitMetadaAssemblyAttributes"
Condition=" '$(GenerateGitMetadata)' == 'true' ">
<ItemGroup>
<AssemblyAttribute Remove="TemporaryAdditionalHashItem" />
</ItemGroup>
</Target>
</Project>