-
Notifications
You must be signed in to change notification settings - Fork 4
Add GitVersionTask #6
Changes from 15 commits
8ec60df
ea670f5
6507e43
f56a43c
a8e7b1c
1367213
cea174a
4aba279
4ad4473
c2c4f09
b941937
125a25c
3bce24b
ed88802
1f397ec
f911474
c5fb84d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#tool "nuget:?package=GitVersion.CommandLine&version=3.5.4" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So in the end we use both the Task and the commandline? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, we unfortunately can't yet get the result from GitVersionTask available in the Cake script, so we need to run |
||
////////////////////////////////////////////////////////////////////// | ||
// ARGUMENTS | ||
////////////////////////////////////////////////////////////////////// | ||
|
@@ -18,10 +20,9 @@ var SOLUTION = PROJECT_DIR + "NUnit.System.Linq.sln"; | |
// SET PACKAGE VERSION | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
var version = "0.6.0"; | ||
var modifier = ""; | ||
var version = "0.0.0"; | ||
var dbgSuffix = configuration == "Debug" ? "-dbg" : ""; | ||
var packageVersion = version + modifier + dbgSuffix; | ||
var packageVersion = version + dbgSuffix; | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// CLEAN | ||
|
@@ -37,39 +38,72 @@ Task("Clean") | |
// RESTORE PACKAGES | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
Task("InitializeBuild") | ||
Task("NuGet-Package-Restore") | ||
.Does(() => | ||
{ | ||
if (BuildSystem.IsRunningOnAppVeyor) | ||
{ | ||
var tag = AppVeyor.Environment.Repository.Tag; | ||
|
||
if (tag.IsTag) | ||
{ | ||
packageVersion = tag.Name; | ||
} | ||
else | ||
{ | ||
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; | ||
else | ||
packageVersion += "-" + AppVeyor.Environment.Repository.Branch; | ||
} | ||
|
||
AppVeyor.UpdateBuildVersion(packageVersion); | ||
} | ||
NuGetRestore(SOLUTION); | ||
}); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// INITIALIZE BUILD | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
Setup(context => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any particular reason to prefer SetUp to a Task here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a Cake expert, but it seems like this is something you'd want to explicitly run no matter what target you choose or how you set the different target dependencies up, for which There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, cake is a general scripting language and the Tasks could do anything. For example, we have targets in nunit that just run the tests, without building. That's why we created InitializeBuild. In fact, it doesn't matter much, because (1) everything is conditioned by IsRunningOnAppveyor and (2) there are no targets like that in this project. I think it's mostly a style thing - no need to change what you have done. |
||
{ | ||
if (IsRunningOnWindows()) | ||
{ | ||
var settings = new GitVersionSettings | ||
{ | ||
OutputType = GitVersionOutput.Json, | ||
}; | ||
|
||
/*if (!BuildSystem.IsLocalBuild) | ||
{ | ||
settings.LogFilePath = "console"; | ||
settings.OutputType = GitVersionOutput.BuildServer; | ||
}*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the commented out stuff be removed? |
||
|
||
var gitVersion = GitVersion(settings); | ||
|
||
Information("AssemblySemVer: " + gitVersion.AssemblySemVer); | ||
Information("BranchName: " + gitVersion.BranchName); | ||
Information("BuildMetaData: " + gitVersion.BuildMetaData); | ||
Information("BuildMetaDataPadded: " + gitVersion.BuildMetaDataPadded); | ||
Information("CommitDate: " + gitVersion.CommitDate); | ||
Information("CommitsSinceVersionSource: " + gitVersion.CommitsSinceVersionSource); | ||
Information("CommitsSinceVersionSourcePadded: " + gitVersion.CommitsSinceVersionSourcePadded); | ||
Information("FullBuildMetaData: " + gitVersion.FullBuildMetaData); | ||
Information("FullSemVer: " + gitVersion.FullSemVer); | ||
Information("InformationalVersion: " + gitVersion.InformationalVersion); | ||
Information("LegacySemVer: " + gitVersion.LegacySemVer); | ||
Information("LegacySemVerPadded: " + gitVersion.LegacySemVerPadded); | ||
Information("Major: " + gitVersion.Major); | ||
Information("Minor: " + gitVersion.Minor); | ||
Information("NuGetVersion: " + gitVersion.NuGetVersion); | ||
Information("NuGetVersionV2: " + gitVersion.NuGetVersionV2); | ||
Information("Patch: " + gitVersion.Patch); | ||
Information("PreReleaseLabel: " + gitVersion.PreReleaseLabel); | ||
Information("PreReleaseNumber: " + gitVersion.PreReleaseNumber); | ||
Information("PreReleaseTag: " + gitVersion.PreReleaseTag); | ||
Information("PreReleaseTagWithDash: " + gitVersion.PreReleaseTagWithDash); | ||
Information("SemVer: " + gitVersion.SemVer); | ||
Information("Sha: " + gitVersion.Sha); | ||
|
||
packageVersion = gitVersion.NuGetVersion ?? context.EnvironmentVariable("GitVersion_NuGetVersion"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We had some logic in the original script that did different things based on whether there was a tag and the name of the branch. Is that all incorporated somewhere or are we getting default settings now? |
||
} | ||
|
||
if (string.IsNullOrWhiteSpace(packageVersion)) | ||
{ | ||
Warning("The package version is null or empty."); | ||
} | ||
}); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// BUILD | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Build") | ||
.IsDependentOn("InitializeBuild") | ||
.IsDependentOn("NuGet-Package-Restore") | ||
.Does(() => | ||
{ | ||
if (IsRunningOnWindows()) | ||
|
@@ -88,7 +122,7 @@ Task("Build") | |
.WithTarget("Build") | ||
.WithProperty("Configuration", configuration) | ||
.SetVerbosity(Verbosity.Minimal)); | ||
} | ||
} | ||
}); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
|
@@ -125,7 +159,7 @@ Task("Travis") | |
.IsDependentOn("Build"); | ||
|
||
Task("Default") | ||
.IsDependentOn("Build"); | ||
.IsDependentOn("Build"); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// EXECUTION | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="GitVersionTask" version="3.5.4" targetFramework="net20" developmentDependency="true" /> | ||
</packages> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Cake" version="0.6.4" /> | ||
<package id="Cake" version="0.13.0" /> | ||
</packages> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should drop this once we're satisfied it works correctly.