forked from AndersMalmgren/FreePIE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_git_version.xml
44 lines (40 loc) · 1.21 KB
/
get_git_version.xml
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
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MajorVersion>1.2</MajorVersion>
</PropertyGroup>
<UsingTask TaskName="GitVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
<ParameterGroup>
<CommitCount ParameterType="System.Int32" Output="true" />
</ParameterGroup>
<Task>
<!--<Reference Include="" />-->
<Using Namespace="System"/>
<Using Namespace="System.Diagnostics"/>
<Code Type="Fragment" Language="cs">
<![CDATA[
var psi = new ProcessStartInfo("cmd", "/c git rev-list --count HEAD") {
UseShellExecute = false,
ErrorDialog = false,
CreateNoWindow = false,
WorkingDirectory = ".",
RedirectStandardOutput = true,
RedirectStandardError = true
};
string result;
using (var p = Process.Start(psi)) {
p.WaitForExit();
if (p.ExitCode != 0) {
Log.LogMessage("Could not get Git rev.number");
CommitCount = 0;
} else {
using (var standardOutput = p.StandardOutput) {
CommitCount = Int32.Parse(standardOutput.ReadToEnd());
}
}
}
]]>
</Code>
</Task>
</UsingTask>
</Project>