-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.csharp.getversion.msbuild
More file actions
66 lines (64 loc) · 3.1 KB
/
test.csharp.getversion.msbuild
File metadata and controls
66 lines (64 loc) · 3.1 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!--
Copyright 2013 nBuildKit. Licensed under the Apache License, Version 2.0.
-->
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'
ToolsVersion="11.0">
<UsingTask TaskName="CalculateCustomVersion"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<VersionMajor ParameterType="System.String" Output="true" />
<VersionMinor ParameterType="System.String" Output="true" />
<VersionPatch ParameterType="System.String" Output="true" />
<VersionBuild ParameterType="System.String" Output="true" />
<VersionPreRelease ParameterType="System.String" Output="true" />
<VersionSemantic ParameterType="System.String" Output="true" />
<VersionSemanticFull ParameterType="System.String" Output="true" />
<VersionSemanticNuGet ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Code Type="Method" Language="cs">
<![CDATA[
public override bool Execute()
{
try
{
VersionMajor = "4";
VersionMinor = "3";
VersionPatch = "2";
VersionBuild = "1";
VersionPreRelease = "MyPreRelease";
VersionSemantic = string.Format(
"{0}.{1}.{2}",
VersionMajor,
VersionMinor,
VersionPatch);
VersionSemanticFull = string.Format(
"{0}.{1}.{2}-{3}+{4}",
VersionMajor,
VersionMinor,
VersionPatch,
VersionPreRelease,
VersionBuild);
VersionSemanticNuGet = string.Format(
"{0}.{1}.{2}-{3}{4}",
VersionMajor,
VersionMinor,
VersionPatch,
VersionPreRelease,
VersionBuild);
}
catch(Exception e)
{
Log.LogError(e.ToString());
}
// Log.HasLoggedErrors is true if the task logged any errors -- even if they were logged
// from a task's constructor or property setter. As long as this task is written to always log an error
// when it fails, we can reliably return HasLoggedErrors.
return !Log.HasLoggedErrors;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>