forked from dotnet/templating
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVersion.props
78 lines (68 loc) · 3.11 KB
/
Version.props
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
<Project ToolsVersion="15.0">
<PropertyGroup>
<ProjectUrl>https://github.com/dotnet/templating</ProjectUrl>
<ImageUrl>http://go.microsoft.com/fwlink/?LinkID=288859</ImageUrl>
<Tags>template</Tags>
<NuGet>"$(ToolsTempDir)nuget.exe"</NuGet>
</PropertyGroup>
<Target Name="CollectGitInfo">
<PropertyGroup>
<GitInfoCommitCount Condition="'$(COMMIT_HASH)' != ''">$(COMMIT_COUNT)</GitInfoCommitCount>
<GitInfoCommitHash Condition="'$(COMMIT_HASH)' != ''">$(COMMIT_HASH)</GitInfoCommitHash>
<GitExitCode>0</GitExitCode>
</PropertyGroup>
<Exec Command="git rev-list --count HEAD" ConsoleToMSBuild="true" Condition="'$(COMMIT_HASH)' == ''" IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GitInfoCommitCount" />
<Output TaskParameter="ExitCode" PropertyName="GitExitCode" />
</Exec>
<Exec Command="git rev-parse HEAD" ConsoleToMSBuild="true" Condition="'$(COMMIT_HASH)' == ''" IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GitInfoCommitHash" />
<Output TaskParameter="ExitCode" PropertyName="GitExitCode" />
</Exec>
<PropertyGroup Condition="'$(GitExitCode)' != '0'">
<GitInfoCommitCount>0</GitInfoCommitCount>
<GitInfoCommitHash>UNKNOWN</GitInfoCommitHash>
</PropertyGroup>
<PropertyGroup>
<GitCommitInfoContent>
<![CDATA[
[assembly: System.Reflection.AssemblyVersion("$(AssemblyReleaseVersion)")]
[assembly: System.Reflection.AssemblyFileVersion("$(AssemblyReleaseVersion)")]
[assembly: System.Reflection.AssemblyInformationalVersion("$(PackageVersion)+$(GitInfoCommitCount).$(GitInfoCommitHash)")]
namespace Microsoft.TemplateEngine
{
internal static class GitInfo
{
public static string PackageVersion { get%3B } = "$(PackageVersion)"%3B
public static string CommitCount { get%3B } = "$(GitInfoCommitCount)"%3B
public static string CommitHash { get%3B } = "$(GitInfoCommitHash)"%3B
}
}
]]>
</GitCommitInfoContent>
<GitInfoPropsContent>
<![CDATA[
<Project ToolsVersion="15.0">
<PropertyGroup>
<Version>$(PackageReleaseVersion)</Version>
<FileVersion>$(PackageReleaseVersion)</FileVersion>
<InformationalVersion>$(PackageVersion)+$(GitInfoCommitCount).$(GitInfoCommitHash)</InformationalVersion>
<PackageReleaseNotes>Commit Hash: $(GitInfoCommitHash)</PackageReleaseNotes>
</PropertyGroup>
</Project>
]]>
</GitInfoPropsContent>
</PropertyGroup>
<WriteLinesToFile File="$(GitInfoFile)"
Lines="$(GitCommitInfoContent)"
Overwrite="true" />
<WriteLinesToFile File="$(GitInfoProps)"
Lines="$(GitInfoPropsContent)"
Overwrite="true" />
</Target>
<ItemGroup>
<Compile Include="$(GitInfoFile)" Condition="Exists('$(GitInfoFile)')" Link="%(RecursiveDir)%(Filename)%(Extension)" />
<Compile Include="$(SrcDir)GitInfo.cs" Condition="!Exists('$(GitInfoFile)')" Link="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<Import Project="$(GitInfoProps)" Condition="Exists('$(GitInfoProps)')" />
</Project>