Skip to content
This repository has been archived by the owner on Jan 8, 2023. It is now read-only.

Commit

Permalink
Use GitVersion to set the package version
Browse files Browse the repository at this point in the history
  • Loading branch information
asbjornu committed Jun 29, 2016
1 parent f56a43c commit a8e7b1c
Showing 1 changed file with 33 additions and 16 deletions.
49 changes: 33 additions & 16 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#tool "nuget:https://www.nuget.org/api/v2?package=GitVersion.CommandLine&version=3.5.4"

//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -49,27 +51,42 @@ Task("NuGet-Package-Restore")

Setup(context =>
{
if (BuildSystem.IsRunningOnAppVeyor)
{
var tag = AppVeyor.Environment.Repository.Tag;
GitVersion gitVersion;

if (tag.IsTag)
{
packageVersion = tag.Name;
}
else
if (!BuildSystem.IsLocalBuild)
{
// TODO: Figure out if and how we can update the build number on Travis. @asbjornu
if (BuildSystem.IsRunningOnAppVeyor)
{
var buildNumber = AppVeyor.Environment.Build.Number;
packageVersion = version + "-CI-" + buildNumber + dbgSuffix;
if (AppVeyor.Environment.PullRequest.IsPullRequest)
packageVersion += "-PR-" + AppVeyor.Environment.PullRequest.Number;
else if (AppVeyor.Environment.Repository.Branch.StartsWith("release", StringComparison.OrdinalIgnoreCase))
packageVersion += "-PRE-" + buildNumber;
var tag = AppVeyor.Environment.Repository.Tag;

if (tag.IsTag)
{
packageVersion = tag.Name;
}
else
packageVersion += "-" + AppVeyor.Environment.Repository.Branch;
{
gitVersion = GitVersion(new GitVersionSettings
{
UpdateAssemblyInfo = true,
LogFilePath = "console",
OutputType = GitVersionOutput.BuildServer
});

packageVersion = gitVersion.NuGetVersion;
}

AppVeyor.UpdateBuildVersion(packageVersion);
}
}
else
{
gitVersion = GitVersion(new GitVersionSettings
{
OutputType = GitVersionOutput.Json
});

AppVeyor.UpdateBuildVersion(packageVersion);
packageVersion = gitVersion.NuGetVersion;
}
});

Expand Down

0 comments on commit a8e7b1c

Please sign in to comment.