-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
31 lines (31 loc) · 1.94 KB
/
Directory.Build.targets
File metadata and controls
31 lines (31 loc) · 1.94 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
<Project>
<PropertyGroup>
<CommitBranch Condition=" '$(CommitBranch)' == '' ">$(CI_COMMIT_REF_NAME)</CommitBranch>
</PropertyGroup>
<Target Name="AddGitMetadaAssemblyAttributes" AfterTargets="Build" BeforeTargets="PrepareForBuild;CoreGenerateAssemblyInfo" Condition=" '$(Configuration)' == 'Release' ">
<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>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition=" $(CI_PIPELINE_IID) != '' ">
<_Parameter1>BuildId</_Parameter1>
<_Parameter2>$(CI_PIPELINE_IID)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
</Target>
</Project>