-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory.Build.props
More file actions
48 lines (41 loc) · 2.24 KB
/
Directory.Build.props
File metadata and controls
48 lines (41 loc) · 2.24 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
<Project>
<PropertyGroup>
<!-- Базовая версия -->
<VersionPrefix>1.0</VersionPrefix>
<!-- Автогенерация версии из даты и Git -->
<VersionSuffix Condition="'$(Configuration)' == 'Debug'">dev</VersionSuffix>
</PropertyGroup>
<!-- Git информация -->
<Target Name="SetGitInfo" BeforeTargets="GenerateAssemblyInfo" Condition="Exists('.git')">
<Exec Command="git rev-list --count HEAD" ConsoleToMSBuild="true" IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GitCommitCount" />
</Exec>
<Exec Command="git rev-parse --short HEAD" ConsoleToMSBuild="true" IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GitShortHash" />
</Exec>
<Exec Command="git log -1 --format=%%ci" ConsoleToMSBuild="true" IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GitCommitDate" />
</Exec>
<PropertyGroup>
<GitCommitCount Condition="'$(GitCommitCount)' == ''">0</GitCommitCount>
<GitShortHash Condition="'$(GitShortHash)' == ''">unknown</GitShortHash>
<!-- Версия: 1.0.{commit_count} -->
<Version>$(VersionPrefix).$(GitCommitCount)</Version>
<AssemblyVersion>$(VersionPrefix).$(GitCommitCount).0</AssemblyVersion>
<FileVersion>$(VersionPrefix).$(GitCommitCount).0</FileVersion>
<!-- Информационная версия с Git hash -->
<InformationalVersion Condition="'$(Configuration)' == 'Debug'">$(Version)-dev+$(GitShortHash)</InformationalVersion>
<InformationalVersion Condition="'$(Configuration)' != 'Debug'">$(Version)+$(GitShortHash)</InformationalVersion>
</PropertyGroup>
<Message Importance="High" Text="Version: $(Version) ($(GitCommitCount) commits, $(GitShortHash))" />
</Target>
<!-- Fallback без Git -->
<Target Name="SetFallbackVersion" BeforeTargets="GenerateAssemblyInfo" Condition="!Exists('.git')">
<PropertyGroup>
<Version>$(VersionPrefix).0</Version>
<AssemblyVersion>$(VersionPrefix).0.0</AssemblyVersion>
<FileVersion>$(VersionPrefix).0.0</FileVersion>
<InformationalVersion>$(Version)-local</InformationalVersion>
</PropertyGroup>
</Target>
</Project>