Skip to content
This repository was archived by the owner on Mar 20, 2019. It is now read-only.

Commit cca405d

Browse files
committed
Fixed up versioning to use SemVer 2.0.
1 parent 188fb4a commit cca405d

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

lib/DotNetOpenAuth.BuildTasks.dll

0 Bytes
Binary file not shown.

lib/DotNetOpenAuth.BuildTasks.pdb

0 Bytes
Binary file not shown.

nuget/nuget.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
</NuGetPackages>
4848
<NuGetPackages Include="DotNetOpenAuth.Ultimate.nuspec" />
4949

50-
<NuGetProperties Include="version=$(BuildVersion)" />
50+
<NuGetProperties Include="version=$(NuGetPackageVersion)" />
5151
<NuGetProperties Include="oauth2version=0.11.0-draft" />
5252
<NuGetProperties Include="OutputPath35=$(OutputPath35)" />
5353
<NuGetProperties Include="OutputPath40=$(OutputPath40)" />

src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public GetBuildVersion() {
3434
[Output]
3535
public string GitCommitId { get; private set; }
3636

37+
/// <summary>
38+
/// Gets the build number (JDate) for this version.
39+
/// </summary>
40+
[Output]
41+
public int BuildNumber { get; private set; }
42+
3743
/// <summary>
3844
/// The file that contains the version base (Major.Minor.Build) to use.
3945
/// </summary>
@@ -48,11 +54,12 @@ public GetBuildVersion() {
4854
public override bool Execute() {
4955
try {
5056
Version typedVersion = ReadVersionFromFile();
51-
SimpleVersion = typedVersion.ToString();
57+
this.SimpleVersion = typedVersion.ToString();
58+
this.BuildNumber = this.CalculateJDate(DateTime.Now);
59+
60+
var fullVersion = new Version(typedVersion.Major, typedVersion.Minor, typedVersion.Build, this.BuildNumber);
61+
this.Version = fullVersion.ToString();
5262

53-
var fullVersion = new Version(typedVersion.Major, typedVersion.Minor, typedVersion.Build, CalculateJDate(DateTime.Now));
54-
Version = fullVersion.ToString();
55-
5663
this.GitCommitId = GetGitHeadCommitId();
5764
} catch (ArgumentOutOfRangeException ex) {
5865
Log.LogErrorFromException(ex);

tools/DotNetOpenAuth.Versioning.targets

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<PropertyGroup>
77
<VersionCsFile>$(IntermediatePath)\$(AssemblyName).Version.cs</VersionCsFile>
88
<NoWarn>$(NoWarn);1607</NoWarn>
9+
10+
<!-- PrereleaseVersion can be any alphanumeric identifier with a preceding hyphen, or blank. -->
11+
<PrereleaseVersion>-beta</PrereleaseVersion>
912
</PropertyGroup>
1013

1114
<UsingTask AssemblyFile="$(ProjectRoot)lib\MSBuild.Community.Tasks.dll" TaskName="AssemblyInfo"/>
@@ -16,15 +19,25 @@
1619
GitRepoRoot="$(ProjectRoot)">
1720
<Output TaskParameter="Version" PropertyName="BuildVersion" />
1821
<Output TaskParameter="SimpleVersion" PropertyName="BuildVersionSimple" />
19-
<Output TaskParameter="GitCommitId" PropertyName="AssemblyInformationalVersion" />
22+
<Output TaskParameter="GitCommitId" PropertyName="GitCommitId" />
23+
<Output TaskParameter="BuildNumber" PropertyName="BuildNumber" />
2024
</GetBuildVersion>
2125
<PropertyGroup>
2226
<!-- In TeamCity, the build agent doesn't get the .git directory, but the commit id is available by other means. -->
23-
<AssemblyInformationalVersion Condition=" '$(AssemblyInformationalVersion)' == '' ">$(BUILD_VCS_NUMBER)</AssemblyInformationalVersion>
27+
<GitCommitId Condition=" '$(GitCommitId)' == '' ">$(BUILD_VCS_NUMBER)</GitCommitId>
28+
29+
<SemVerBuildSuffix>+build.$(BuildNumber).$(GitCommitId.Substring(0,10))</SemVerBuildSuffix>
30+
<AssemblyInformationalVersion>$(BuildVersionSimple)$(PrereleaseVersion)$(SemVerBuildSuffix)</AssemblyInformationalVersion>
31+
32+
<!-- When NuGet supports SemVer 2.0, we can set NuGetPackageVersion to be the same as $(AssemblyInformationalVersion) -->
33+
<NuGetPackageVersion Condition=" '$(PrereleaseVersion)' == '' ">$(BuildVersion)</NuGetPackageVersion>
34+
<NuGetPackageVersion Condition=" '$(PrereleaseVersion)' != '' ">$(BuildVersionSimple)$(PrereleaseVersion)</NuGetPackageVersion>
2435
</PropertyGroup>
2536
<Warning Condition=" '$(AssemblyInformationalVersion)' == '' " Text="Unable to determine the git HEAD commit ID to use for informational version number." />
26-
<Message Condition=" '$(AssemblyInformationalVersion)' != '' " Text="Building version $(BuildVersion) from commit $(AssemblyInformationalVersion)"/>
37+
<Message Condition=" '$(AssemblyInformationalVersion)' != '' " Text="Building version $(BuildVersion) from commit $(GitCommitId)"/>
2738
<Message Condition=" '$(AssemblyInformationalVersion)' == '' " Text="Building version $(BuildVersion)"/>
39+
<Message Importance="low" Text="AssemblyInformationalVersion: $(AssemblyInformationalVersion)" />
40+
<Message Importance="low" Text="NuGetPackageVersion: $(NuGetPackageVersion)" />
2841
</Target>
2942

3043
<Target Name="BeforeBuild" DependsOnTargets="GetBuildVersion">

0 commit comments

Comments
 (0)