Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions GitVersionCore/OutputVariables/VariableProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public static class VariableProvider
public const string AssemblyFileVersion = "AssemblyFileVersion";
public const string OriginalRelease = "OriginalRelease";

// Synonyms
public const string Version = "Version";
public const string NuGetVersionV2 = "NuGetVersionV2";
public const string NuGetVersionV3 = "NuGetVersionV3";
public const string NuGetVersion = "NuGetVersion";

public static Dictionary<string, string> GetVariablesFor(
SemanticVersion semanticVersion,
AssemblyVersioningScheme assemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch,
Expand Down Expand Up @@ -67,6 +73,14 @@ public static Dictionary<string, string> GetVariablesFor(
bmd.ReleaseDate.OriginalDate.UtcDateTime.ToString("u"))},
};

// Synonyms to ensure backwards compatibility
variables[Version] = variables[LegacySemVer];

// Use ToLower() to fix a bug where Beta and beta are different in NuGet
variables[NuGetVersionV2] = variables[LegacySemVerPadded].ToLower();
//variables[NuGetVersionV3] = variables[LegacySemVerPadded].ToLower(); // TODO: when v3 is released, determine what to use
variables[NuGetVersion] = variables[NuGetVersionV2];

return variables;
}
}
Expand Down
9 changes: 9 additions & 0 deletions GitVersionTask/GetVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ public class GetVersion : Task
[Output]
public string OriginalRelease { get; set; }

[Output]
public string Version { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this variable. I don't think it should be added back in, we are pre-v1 to allow breaking changes like this to take place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then wat is your recommendation as the version to show? I (and probably others) need a solid simple variable name. We have used MajorMinorPatch in the past, but that is too long + does not take care of additional commits. FullSemVer sounds like what you want to achieve, but is meaningless for most developers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change all my builds to use FullSemVer instead of Version, but I still think it's too complex without a "Version" variable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To show, or use?

SemVer would be the one I would show (and the one we override the build number with), but if you used it for assembly versioning that will cause issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use this to update my SolutionAssemblyInfo:

AssemblyVersion:"%GitVersion_MajorMinorPatch%"
AssemblyInformationalVersion:"%GitVersion_FullSemVer%" <=== this was %GitVersion_Version% before

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's kind of legacy that I am still doing that manually (in the build server). However, here arises the same question: what do you use for InformationalAssemblyInfo? Is it FullSemVer, or ...? I don't know and I don't care, I juse call it Version or DisplayVersion ;-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the issue, but what version do you want.

I would alias Version to SemVer by default because build metadata is not part of it and pre-release tags are part of the version but you can't use that for assemblies, or NuGet because it is broken.

Would that be the behaviour you would expect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now converted the information version in all builds to FullSemVer, works great (and gives my the thing I want). I can now ask users to send me the informational version and I know exactly what build they are using. Need to fix the unit tests, then I will push the update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated pushed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :) I will spend some time over the weekend and update the doco. Appreciate the feedback and PR's


[Output]
public string NuGetVersionV2 { get; set; }

[Output]
public string NuGetVersion { get; set; }

TaskLogger logger;

public GetVersion()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ static class GitVersionInformation
public static string AssemblyVersion = "2.0.0.0";
public static string AssemblyFileVersion = "2.3.4.0";
public static string OriginalRelease = "originalCommitSha.2014-03-01 00:00:01Z";
public static string Version = "2.3.4";
public static string NuGetVersionV2 = "2.3.4";
public static string NuGetVersion = "2.3.4";

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ static class GitVersionInformation
public static string AssemblyVersion = "2.3.0.0";
public static string AssemblyFileVersion = "2.3.4.0";
public static string OriginalRelease = "originalCommitSha.2014-03-01 00:00:01Z";
public static string Version = "2.3.4";
public static string NuGetVersionV2 = "2.3.4";
public static string NuGetVersion = "2.3.4";

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ static class GitVersionInformation
public static string AssemblyVersion = "2.3.4.0";
public static string AssemblyFileVersion = "2.3.4.0";
public static string OriginalRelease = "originalCommitSha.2014-03-01 00:00:01Z";
public static string Version = "2.3.4";
public static string NuGetVersionV2 = "2.3.4";
public static string NuGetVersion = "2.3.4";

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ static class GitVersionInformation
public static string AssemblyVersion = "1.0.0.0";
public static string AssemblyFileVersion = "2.3.4.0";
public static string OriginalRelease = "originalCommitSha.2014-03-01 00:00:01Z";
public static string Version = "2.3.4";
public static string NuGetVersionV2 = "2.3.4";
public static string NuGetVersion = "2.3.4";

}

Expand Down
3 changes: 3 additions & 0 deletions Tests/AssemblyInfoBuilderTests.VerifyCreatedCode.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ static class GitVersionInformation
public static string AssemblyVersion = "1.2.3.0";
public static string AssemblyFileVersion = "1.2.3.0";
public static string OriginalRelease = "originalCommitSha.2014-03-01 00:00:01Z";
public static string Version = "1.2.3-unstable4";
public static string NuGetVersionV2 = "1.2.3-unstable0004";
public static string NuGetVersion = "1.2.3-unstable0004";

}

Expand Down
5 changes: 4 additions & 1 deletion Tests/JsonVersionBuilderTests.Json.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
"Sha":"commitSha",
"AssemblyVersion":"1.2.3.0",
"AssemblyFileVersion":"1.2.3.0",
"OriginalRelease":"originalCommitSha.2014-03-01 00:00:01Z"
"OriginalRelease":"originalCommitSha.2014-03-01 00:00:01Z",
"Version":"1.2.3-unstable4",
"NuGetVersionV2":"1.2.3-unstable0004",
"NuGetVersion":"1.2.3-unstable0004"
}
1 change: 1 addition & 0 deletions Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="AssemblyInfoBuilderTests.VerifyAssemblyVersion_Major.approved.txt" />
<Content Include="AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor.approved.txt" />
<Content Include="AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatch.approved.txt" />
<Content Include="AssemblyInfoBuilderTests.VerifyAssemblyVersion_None.approved.txt" />
<Content Include="AssemblyInfoBuilderTests.VerifyCreatedCode.approved.txt" />
Expand Down
4 changes: 4 additions & 0 deletions Tests/VariableProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,9 @@ public void AssemblyVersion(

vars[VariableProvider.AssemblyVersion].ShouldBe(version);
vars[VariableProvider.AssemblyFileVersion].ShouldBe(fileVersion);

vars[VariableProvider.Version].ShouldBe(vars[VariableProvider.LegacySemVer]);
vars[VariableProvider.NuGetVersionV2].ShouldBe(vars[VariableProvider.LegacySemVerPadded].ToLower());
vars[VariableProvider.NuGetVersion].ShouldBe(vars[VariableProvider.NuGetVersionV2]);
}
}