Skip to content

Commit eb9f090

Browse files
authored
Merge branch 'master' into feature/1469-dotnet-version-variable
2 parents a2c6923 + 2ea47b9 commit eb9f090

File tree

6 files changed

+44
-31
lines changed

6 files changed

+44
-31
lines changed

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ works out the [semantic version][semver] of the commit being built.
2424
| **Docker DotnetCore** | [Dotnetcore][dockerhub-dotnetcore] | - |
2525
| **Docker FullFX** | [FullFX][dockerhub-fullfx] | - |
2626

27-
2827
## Compatibility
28+
2929
GitVersion works on Mac, Linux with Mono and Windows.
3030

3131
Tip: If you get `System.TypeInitializationException: The type initializer for
@@ -35,23 +35,26 @@ System.DllNotFoundException: lib/linux/x86_64/libgit2-baa87df.so`
3535
You likely need to install `libcurl3`. Run `sudo apt-get install libcurl3`
3636

3737
## Quick Links
38-
- [Documentation][docs]
39-
- [Contributing][contribute]
40-
- [Why GitVersion][why]
41-
- [Usage][usage]
42-
- [How it works][how]
43-
- [FAQ][faq]
44-
- [Who is using GitVersion][who]
38+
39+
- [Documentation][docs]
40+
- [Contributing][contribute]
41+
- [Why GitVersion][why]
42+
- [Usage][usage]
43+
- [How it works][how]
44+
- [FAQ][faq]
45+
- [Who is using GitVersion][who]
4546

4647
## GitVersion in action!
48+
4749
![README][gv-in-action]
4850

4951
You are seeing:
5052

51-
- Pull requests being built as pre-release builds
52-
- A branch called `release-1.0.0` producing beta v1 packages
53+
- Pull requests being built as pre-release builds
54+
- A branch called `release-1.0.0` producing beta v1 packages
5355

5456
## Icon
57+
5558
<a href="http://thenounproject.com/noun/tree/#icon-No13389"
5659
target="_blank">Tree</a> designed by <a
5760
href="http://thenounproject.com/david.chapman" target="_blank">David Chapman</a>

build.cake

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
BuildParameters parameters = BuildParameters.GetParameters(Context);
2626
bool publishingError = false;
2727
DotNetCoreMSBuildSettings msBuildSettings = null;
28-
29-
string dotnetVersion = "net40";
3028
GitVersion gitVersion = null;
3129

3230
///////////////////////////////////////////////////////////////////////////////
@@ -36,7 +34,7 @@ GitVersion gitVersion = null;
3634
Setup(context =>
3735
{
3836
Build(parameters.Configuration, null);
39-
gitVersion = GetVersion(dotnetVersion);
37+
gitVersion = GetVersion(parameters);
4038
parameters.Initialize(context, gitVersion);
4139

4240
// Increase verbosity?
@@ -76,6 +74,12 @@ Teardown(context =>
7674
{
7775
Information("Starting Teardown...");
7876

77+
Information("Repository info : IsMainRepo {0}, IsMainBranch {1}, IsTagged: {2}, IsPullRequest: {3}",
78+
parameters.IsMainRepo,
79+
parameters.IsMainBranch,
80+
parameters.IsTagged,
81+
parameters.IsPullRequest);
82+
7983
if(context.Successful)
8084
{
8185
// if(parameters.ShouldPublish)
@@ -113,7 +117,7 @@ Teardown(context =>
113117
Task("Clean")
114118
.Does(() =>
115119
{
116-
Information("Cleaning direcories..");
120+
Information("Cleaning directories..");
117121

118122
CleanDirectories("./src/**/bin/" + parameters.Configuration);
119123
CleanDirectories("./src/**/obj");
@@ -200,7 +204,7 @@ Task("Copy-Files")
200204
// .NET Core
201205
DotNetCorePublish("./src/GitVersionExe/GitVersionExe.csproj", new DotNetCorePublishSettings
202206
{
203-
Framework = "netcoreapp2.0",
207+
Framework = parameters.NetCoreVersion,
204208
NoRestore = true,
205209
Configuration = parameters.Configuration,
206210
OutputDirectory = netCoreDir,
@@ -209,12 +213,12 @@ Task("Copy-Files")
209213

210214
// Copy license & Copy GitVersion.XML (since publish does not do this anymore)
211215
CopyFileToDirectory("./LICENSE", netCoreDir);
212-
CopyFileToDirectory("./src/GitVersionExe/bin/" + parameters.Configuration + "/netcoreapp2.0/GitVersion.xml", netCoreDir);
216+
CopyFileToDirectory($"./src/GitVersionExe/bin/{parameters.Configuration}/{parameters.NetCoreVersion}/GitVersion.xml", netCoreDir);
213217

214218
// .NET 4.0
215219
DotNetCorePublish("./src/GitVersionExe/GitVersionExe.csproj", new DotNetCorePublishSettings
216220
{
217-
Framework = dotnetVersion,
221+
Framework = parameters.FullFxVersion,
218222
NoBuild = true,
219223
NoRestore = true,
220224
Configuration = parameters.Configuration,
@@ -227,9 +231,9 @@ Task("Copy-Files")
227231
var cmdlineDir = parameters.Paths.Directories.ArtifactsBinFullFxCmdline.Combine("tools");
228232

229233
// Portable
230-
PublishILRepackedGitVersionExe(true, parameters.Paths.Directories.ArtifactsBinFullFx, ilMergDir, portableDir, parameters.Configuration, dotnetVersion);
234+
PublishILRepackedGitVersionExe(true, parameters.Paths.Directories.ArtifactsBinFullFx, ilMergDir, portableDir, parameters.Configuration, parameters.FullFxVersion);
231235
// Commandline
232-
PublishILRepackedGitVersionExe(false, parameters.Paths.Directories.ArtifactsBinFullFx, ilMergDir, cmdlineDir, parameters.Configuration, dotnetVersion);
236+
PublishILRepackedGitVersionExe(false, parameters.Paths.Directories.ArtifactsBinFullFx, ilMergDir, cmdlineDir, parameters.Configuration, parameters.FullFxVersion);
233237

234238
// Vsix
235239
var tfsPath = new DirectoryPath("./src/GitVersionTfsTask/GitVersionTask");

build/parameters.cake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ public class BuildParameters
88
public string Target { get; private set; }
99
public string Configuration { get; private set; }
1010

11+
public string NetCoreVersion { get; private set; } = "netcoreapp2.0";
12+
public string FullFxVersion { get; private set; } = "net40";
13+
1114
public bool EnabledUnitTests { get; private set; }
15+
public bool EnabledSetVersion { get; private set; }
1216
public bool EnabledPublishGem { get; private set; }
1317
public bool EnabledPublishTfs { get; private set; }
1418
public bool EnabledPublishNuget { get; private set; }
1519
public bool EnabledPublishChocolatey { get; private set; }
1620
public bool EnabledPublishDocker { get; private set; }
17-
public bool EnabledPullRequestPublish { get; private set; }
1821

1922
public bool IsRunningOnUnix { get; private set; }
2023
public bool IsRunningOnWindows { get; private set; }
@@ -58,6 +61,7 @@ public class BuildParameters
5861
Configuration = context.Argument("configuration", "Release"),
5962

6063
EnabledUnitTests = IsEnabled(context, "ENABLED_UNIT_TESTS"),
64+
EnabledSetVersion = IsEnabled(context, "ENABLED_SET_VERSION"),
6165
EnabledPublishGem = IsEnabled(context, "ENABLED_PUBLISH_GEM"),
6266
EnabledPublishTfs = IsEnabled(context, "ENABLED_PUBLISH_TFS"),
6367
EnabledPublishNuget = IsEnabled(context, "ENABLED_PUBLISH_NUGET"),

build/utils.cake

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ void SetRubyGemPushApiKey(string apiKey)
4747
CopyFileToDirectory(credentialFile, gemHomeDir);
4848
}
4949

50-
GitVersion GetVersion(string dotnetVersion)
50+
GitVersion GetVersion(BuildParameters parameters)
5151
{
52-
var dllFile = GetFiles("**/netcoreapp2.0/GitVersion.dll").FirstOrDefault();
52+
var dllFile = GetFiles($"**/{parameters.NetCoreVersion}/GitVersion.dll").FirstOrDefault();
5353
var settings = new GitVersionSettings
5454
{
5555
OutputType = GitVersionOutput.Json,
@@ -59,12 +59,14 @@ GitVersion GetVersion(string dotnetVersion)
5959

6060
var gitVersion = GitVersion(settings);
6161

62-
settings.UpdateAssemblyInfo = true;
63-
settings.LogFilePath = "console";
64-
settings.OutputType = GitVersionOutput.BuildServer;
65-
66-
GitVersion(settings);
62+
if (parameters.EnabledSetVersion)
63+
{
64+
settings.UpdateAssemblyInfo = true;
65+
settings.LogFilePath = "console";
66+
settings.OutputType = GitVersionOutput.BuildServer;
6767

68+
GitVersion(settings);
69+
}
6870
return gitVersion;
6971
}
7072

@@ -173,6 +175,7 @@ string[] GetDockerTags(string platform, string variant, BuildParameters paramete
173175
var name = $"gittools/gitversion-{variant}";
174176

175177
var tags = new List<string> {
178+
$"{name}:{platform}",
176179
$"{name}:{platform}-{parameters.Version.Version}"
177180
};
178181

build/version.cake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ public class BuildVersion
77
public static BuildVersion Calculate(ICakeContext context, BuildParameters parameters, GitVersion gitVersion)
88
{
99
var version = gitVersion.MajorMinorPatch;
10-
var semVersion = gitVersion.LegacySemVerPadded;
10+
var semVersion = gitVersion.LegacySemVer;
1111

12-
if (!string.IsNullOrWhiteSpace(gitVersion.BuildMetaDataPadded)) {
13-
semVersion += "-" + gitVersion.BuildMetaDataPadded;
12+
if (!string.IsNullOrWhiteSpace(gitVersion.BuildMetaData)) {
13+
semVersion += "-" + gitVersion.BuildMetaData;
1414
}
1515

1616
return new BuildVersion

src/GitVersionTfsTask/GitVersion.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import tl = require('vsts-task-lib/task');
22
import { IExecOptions, ToolRunner } from 'vsts-task-lib/toolrunner';
33
import path = require('path');
4-
import q = require('q');
54
import os = require('os');
65

76
var updateAssemblyInfo = tl.getBoolInput('updateAssemblyInfo');

0 commit comments

Comments
 (0)