forked from justeattakeaway/httpclient-interception
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Directory.Build.targets
22 lines (22 loc) · 1.36 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
<Project>
<PropertyGroup>
<CommitBranch Condition=" '$(CommitBranch)' == '' ">$(BUILD_SOURCEBRANCHNAME)</CommitBranch>
<CommitBranch Condition=" '$(CommitBranch)' == '' and '$(GITHUB_REF)' != '' ">$(GITHUB_REF.Substring(11))</CommitBranch>
<CommitHash Condition=" '$(CommitHash)' == '' ">$(GITHUB_SHA)</CommitHash>
</PropertyGroup>
<Target Name="AddGitMetadaAssemblyAttributes"
BeforeTargets="GetAssemblyAttributes"
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>
<AssemblyMetadata Include="BuildTimestamp" Value="$([System.DateTime]::UtcNow.ToString(yyyy-MM-ddTHH:mm:ssK))" />
<AssemblyMetadata Condition=" $(CommitHash) != '' " Include="CommitHash" Value="$(CommitHash)" />
<AssemblyMetadata Condition=" $(CommitBranch) != '' " Include="CommitBranch" Value="$(CommitBranch)" />
</ItemGroup>
</Target>
</Project>