Skip to content

Commit

Permalink
Merge branch 'master' into feature/1469-dotnet-version-variable
Browse files Browse the repository at this point in the history
  • Loading branch information
snovak7 authored Oct 17, 2018
2 parents a2c6923 + 2ea47b9 commit eb9f090
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 31 deletions.
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ works out the [semantic version][semver] of the commit being built.
| **Docker DotnetCore** | [Dotnetcore][dockerhub-dotnetcore] | - |
| **Docker FullFX** | [FullFX][dockerhub-fullfx] | - |


## Compatibility

GitVersion works on Mac, Linux with Mono and Windows.

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

## Quick Links
- [Documentation][docs]
- [Contributing][contribute]
- [Why GitVersion][why]
- [Usage][usage]
- [How it works][how]
- [FAQ][faq]
- [Who is using GitVersion][who]

- [Documentation][docs]
- [Contributing][contribute]
- [Why GitVersion][why]
- [Usage][usage]
- [How it works][how]
- [FAQ][faq]
- [Who is using GitVersion][who]

## GitVersion in action!

![README][gv-in-action]

You are seeing:

- Pull requests being built as pre-release builds
- A branch called `release-1.0.0` producing beta v1 packages
- Pull requests being built as pre-release builds
- A branch called `release-1.0.0` producing beta v1 packages

## Icon

<a href="http://thenounproject.com/noun/tree/#icon-No13389"
target="_blank">Tree</a> designed by <a
href="http://thenounproject.com/david.chapman" target="_blank">David Chapman</a>
Expand Down
22 changes: 13 additions & 9 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
BuildParameters parameters = BuildParameters.GetParameters(Context);
bool publishingError = false;
DotNetCoreMSBuildSettings msBuildSettings = null;

string dotnetVersion = "net40";
GitVersion gitVersion = null;

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -36,7 +34,7 @@ GitVersion gitVersion = null;
Setup(context =>
{
Build(parameters.Configuration, null);
gitVersion = GetVersion(dotnetVersion);
gitVersion = GetVersion(parameters);
parameters.Initialize(context, gitVersion);

// Increase verbosity?
Expand Down Expand Up @@ -76,6 +74,12 @@ Teardown(context =>
{
Information("Starting Teardown...");

Information("Repository info : IsMainRepo {0}, IsMainBranch {1}, IsTagged: {2}, IsPullRequest: {3}",
parameters.IsMainRepo,
parameters.IsMainBranch,
parameters.IsTagged,
parameters.IsPullRequest);

if(context.Successful)
{
// if(parameters.ShouldPublish)
Expand Down Expand Up @@ -113,7 +117,7 @@ Teardown(context =>
Task("Clean")
.Does(() =>
{
Information("Cleaning direcories..");
Information("Cleaning directories..");

CleanDirectories("./src/**/bin/" + parameters.Configuration);
CleanDirectories("./src/**/obj");
Expand Down Expand Up @@ -200,7 +204,7 @@ Task("Copy-Files")
// .NET Core
DotNetCorePublish("./src/GitVersionExe/GitVersionExe.csproj", new DotNetCorePublishSettings
{
Framework = "netcoreapp2.0",
Framework = parameters.NetCoreVersion,
NoRestore = true,
Configuration = parameters.Configuration,
OutputDirectory = netCoreDir,
Expand All @@ -209,12 +213,12 @@ Task("Copy-Files")

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

// .NET 4.0
DotNetCorePublish("./src/GitVersionExe/GitVersionExe.csproj", new DotNetCorePublishSettings
{
Framework = dotnetVersion,
Framework = parameters.FullFxVersion,
NoBuild = true,
NoRestore = true,
Configuration = parameters.Configuration,
Expand All @@ -227,9 +231,9 @@ Task("Copy-Files")
var cmdlineDir = parameters.Paths.Directories.ArtifactsBinFullFxCmdline.Combine("tools");

// Portable
PublishILRepackedGitVersionExe(true, parameters.Paths.Directories.ArtifactsBinFullFx, ilMergDir, portableDir, parameters.Configuration, dotnetVersion);
PublishILRepackedGitVersionExe(true, parameters.Paths.Directories.ArtifactsBinFullFx, ilMergDir, portableDir, parameters.Configuration, parameters.FullFxVersion);
// Commandline
PublishILRepackedGitVersionExe(false, parameters.Paths.Directories.ArtifactsBinFullFx, ilMergDir, cmdlineDir, parameters.Configuration, dotnetVersion);
PublishILRepackedGitVersionExe(false, parameters.Paths.Directories.ArtifactsBinFullFx, ilMergDir, cmdlineDir, parameters.Configuration, parameters.FullFxVersion);

// Vsix
var tfsPath = new DirectoryPath("./src/GitVersionTfsTask/GitVersionTask");
Expand Down
6 changes: 5 additions & 1 deletion build/parameters.cake
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ public class BuildParameters
public string Target { get; private set; }
public string Configuration { get; private set; }

public string NetCoreVersion { get; private set; } = "netcoreapp2.0";
public string FullFxVersion { get; private set; } = "net40";

public bool EnabledUnitTests { get; private set; }
public bool EnabledSetVersion { get; private set; }
public bool EnabledPublishGem { get; private set; }
public bool EnabledPublishTfs { get; private set; }
public bool EnabledPublishNuget { get; private set; }
public bool EnabledPublishChocolatey { get; private set; }
public bool EnabledPublishDocker { get; private set; }
public bool EnabledPullRequestPublish { get; private set; }

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

EnabledUnitTests = IsEnabled(context, "ENABLED_UNIT_TESTS"),
EnabledSetVersion = IsEnabled(context, "ENABLED_SET_VERSION"),
EnabledPublishGem = IsEnabled(context, "ENABLED_PUBLISH_GEM"),
EnabledPublishTfs = IsEnabled(context, "ENABLED_PUBLISH_TFS"),
EnabledPublishNuget = IsEnabled(context, "ENABLED_PUBLISH_NUGET"),
Expand Down
17 changes: 10 additions & 7 deletions build/utils.cake
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ void SetRubyGemPushApiKey(string apiKey)
CopyFileToDirectory(credentialFile, gemHomeDir);
}

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

var gitVersion = GitVersion(settings);

settings.UpdateAssemblyInfo = true;
settings.LogFilePath = "console";
settings.OutputType = GitVersionOutput.BuildServer;

GitVersion(settings);
if (parameters.EnabledSetVersion)
{
settings.UpdateAssemblyInfo = true;
settings.LogFilePath = "console";
settings.OutputType = GitVersionOutput.BuildServer;

GitVersion(settings);
}
return gitVersion;
}

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

var tags = new List<string> {
$"{name}:{platform}",
$"{name}:{platform}-{parameters.Version.Version}"
};

Expand Down
6 changes: 3 additions & 3 deletions build/version.cake
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public class BuildVersion
public static BuildVersion Calculate(ICakeContext context, BuildParameters parameters, GitVersion gitVersion)
{
var version = gitVersion.MajorMinorPatch;
var semVersion = gitVersion.LegacySemVerPadded;
var semVersion = gitVersion.LegacySemVer;

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

return new BuildVersion
Expand Down
1 change: 0 additions & 1 deletion src/GitVersionTfsTask/GitVersion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import tl = require('vsts-task-lib/task');
import { IExecOptions, ToolRunner } from 'vsts-task-lib/toolrunner';
import path = require('path');
import q = require('q');
import os = require('os');

var updateAssemblyInfo = tl.getBoolInput('updateAssemblyInfo');
Expand Down

0 comments on commit eb9f090

Please sign in to comment.