Skip to content

Commit 7d27524

Browse files
committed
simplify assembly versioing
1 parent a4abfe3 commit 7d27524

File tree

6 files changed

+7
-50
lines changed

6 files changed

+7
-50
lines changed

GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ public class AssemblyInfoBuilder
66
{
77
public SemanticVersion SemanticVersion;
88
public AssemblyVersioningScheme AssemblyVersioningScheme;
9-
public bool AppendRevision;
109

1110
public string GetAssemblyInfoText()
1211
{
13-
var assemblyMetaData = AssemblyVersionsGenerator.Process(SemanticVersion, AssemblyVersioningScheme, AppendRevision);
14-
1512
var vars = VariableProvider.GetVariablesFor(SemanticVersion);
1613
var assemblyInfo = string.Format(@"
1714
using System;
@@ -42,7 +39,7 @@ static class GitVersionInformation
4239
}}
4340
4441
45-
", assemblyMetaData.Version, assemblyMetaData.FileVersion, SemanticVersion.ToString("i"),
42+
", SemanticVersion.GetAssemblyVersion(AssemblyVersioningScheme), string.Format("{0}.{1}.{2}.0", SemanticVersion.Major, SemanticVersion.Minor, SemanticVersion.Patch), SemanticVersion.ToString("i"),
4643
SemanticVersion.BuildMetaData.ReleaseDate.OriginalDate.UtcDateTime.ToString("yyyy-MM-dd"),
4744
SemanticVersion.BuildMetaData.ReleaseDate.Date.UtcDateTime.ToString("yyyy-MM-dd"),
4845
GenerateVariableMembers(vars));

GitVersionTask/AssemblyInfoBuilder/AssemblyMetaData.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

GitVersionTask/AssemblyInfoBuilder/AssemblyVersionsGenerator.cs

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,22 @@
44

55
public static class AssemblyVersionsGenerator
66
{
7-
public static AssemblyMetaData Process(
8-
SemanticVersion sv,
9-
AssemblyVersioningScheme scheme,
10-
bool addNumberOfCommitsSinceTagOnMasterBranchToFileVersion)
7+
public static string GetAssemblyVersion(
8+
this SemanticVersion sv,
9+
AssemblyVersioningScheme scheme)
1110
{
12-
var fileVersion = GetStrictAssemblyFileVersion(sv, addNumberOfCommitsSinceTagOnMasterBranchToFileVersion);
13-
string version;
14-
1511
switch (scheme)
1612
{
1713
case AssemblyVersioningScheme.Major:
18-
version = string.Format("{0}.0.0.0", sv.Major);
19-
break;
20-
14+
return string.Format("{0}.0.0.0", sv.Major);
2115
case AssemblyVersioningScheme.MajorMinor:
22-
version = string.Format("{0}.{1}.0.0", sv.Major, sv.Minor);
23-
break;
24-
16+
return string.Format("{0}.{1}.0.0", sv.Major, sv.Minor);
2517
case AssemblyVersioningScheme.MajorMinorPatch:
26-
version = GetStrictAssemblyFileVersion(sv, false);
27-
break;
28-
18+
return string.Format("{0}.{1}.{2}.0", sv.Major, sv.Minor, sv.Patch);
2919
default:
3020
throw new ArgumentException(string.Format("Unexpected value ({0}).", scheme), "scheme");
3121
}
3222

33-
return new AssemblyMetaData(version, fileVersion);
3423
}
3524

36-
static string GetStrictAssemblyFileVersion(SemanticVersion sv, bool appendRevision)
37-
{
38-
if (appendRevision && sv.BuildMetaData.Branch == "master")
39-
{
40-
if (sv.BuildMetaData.CommitsSinceTag != null)
41-
{
42-
return string.Format("{0}.{1}.{2}.{3}", sv.Major, sv.Minor, sv.Patch, sv.BuildMetaData.CommitsSinceTag);
43-
}
44-
}
45-
46-
return string.Format("{0}.{1}.{2}.0", sv.Major, sv.Minor, sv.Patch);
47-
}
4825
}

GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
public class UpdateAssemblyInfo : Task
1111
{
12-
public bool AppendRevision { get; set; }
13-
1412
public string AssemblyVersioningScheme { get; set; }
1513

1614
[Required]
@@ -107,7 +105,6 @@ void CreateTempAssemblyInfo(SemanticVersion semanticVersion)
107105
{
108106
SemanticVersion = semanticVersion,
109107
AssemblyVersioningScheme = versioningScheme,
110-
AppendRevision = AppendRevision
111108
};
112109
var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText();
113110

GitVersionTask/GitVersionTask.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
</ItemGroup>
5656
<ItemGroup>
5757
<Compile Include="AssemblyInfoBuilder\AssemblyInfoBuilder.cs" />
58-
<Compile Include="AssemblyInfoBuilder\AssemblyMetaData.cs" />
5958
<Compile Include="AssemblyInfoBuilder\AssemblyVersioningScheme.cs" />
6059
<Compile Include="AssemblyInfoBuilder\AssemblyVersionsGenerator.cs" />
6160
<Compile Include="BuildLogger.cs" />

GitVersionTask/NugetAssets/GitVersionTask.targets

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)..\</SolutionDir>
55
</PropertyGroup>
66
<PropertyGroup>
7-
<GitVersionAppendRevision Condition="$(GitVersionAppendRevision) == '' Or $(GitVersionAppendRevision) == '*Undefined*'">false</GitVersionAppendRevision>
87
<GitVersionAssemblyVersioningScheme Condition="$(GitVersionAssemblyVersioningScheme) == '' Or $(GitVersionAssemblyVersioningScheme) == '*Undefined*'"></GitVersionAssemblyVersioningScheme>
98
</PropertyGroup>
109

@@ -26,7 +25,6 @@
2625
<UpdateAssemblyInfo
2726
SolutionDirectory="$(SolutionDir)"
2827
ProjectFile="$(ProjectPath)"
29-
AppendRevision="$(GitVersionAppendRevision)"
3028
AssemblyVersioningScheme="$(GitVersionAssemblyVersioningScheme)"
3129
CompileFiles ="@(Compile)">
3230
<Output

0 commit comments

Comments
 (0)