Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a .NET Core version of the Azure DevOps (vsts) build/release task. #1499

Merged
merged 2 commits into from
Nov 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ artifacts
/src/Docker/**/content
/src/GitVersionTfsTask/GitVersionTask
!src/GitVersionTfsTask/GitVersionTask/task.json
/src/GitVersionTfsTask/GitVersionNetCoreTask
!src/GitVersionTfsTask/GitVersionNetCoreTask/task.json
/src/GitVersionTfsTask/*.vsix
/src/GitVersionRubyGem/*.gem
/src/GitVersionRubyGem/bin/lib
Expand Down
38 changes: 27 additions & 11 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ Task("Copy-Files")
.IsDependentOn("Test")
.Does<BuildParameters>((parameters) =>
{
var netCoreDir = parameters.Paths.Directories.ArtifactsBinNetCore.Combine("tools");
// .NET Core
var netCoreDir = parameters.Paths.Directories.ArtifactsBinNetCore.Combine("tools");
DotNetCorePublish("./src/GitVersionExe/GitVersionExe.csproj", new DotNetCorePublishSettings
{
Framework = parameters.NetCoreVersion,
Expand Down Expand Up @@ -226,6 +226,11 @@ Task("Copy-Files")
CopyFileToDirectory(portableDir + "/" + "GitVersion.exe", tfsPath);
CopyDirectory(portableDir.Combine("lib"), tfsPath.Combine("lib"));

// Vsix dotnet core
var tfsNetCorePath = new DirectoryPath("./src/GitVersionTfsTask/GitVersionNetCoreTask");
EnsureDirectoryExists(tfsNetCorePath);
CopyDirectory(netCoreDir, tfsNetCorePath.Combine("netcore"));

// Ruby Gem
var gemPath = new DirectoryPath("./src/GitVersionRubyGem/bin");
EnsureDirectoryExists(gemPath);
Expand All @@ -241,15 +246,10 @@ Task("Pack-Tfs")
var workDir = "./src/GitVersionTfsTask";

// update version number
ReplaceTextInFile(new FilePath(workDir + "/vss-extension.json"), "$version$", parameters.Version.SemVersion);

var taskJsonFile = new FilePath(workDir + "/GitVersionTask/task.json");
var taskJson = ParseJsonFromFile(taskJsonFile);
var gitVersion = parameters.Version.GitVersion;
taskJson["version"]["Major"] = gitVersion.Major.ToString();
taskJson["version"]["Minor"] = gitVersion.Minor.ToString();
taskJson["version"]["Patch"] = gitVersion.Patch.ToString();
SerializeJsonToPrettyFile(taskJsonFile, taskJson);
ReplaceTextInFile(new FilePath(workDir + "/vss-extension.mono.json"), "$version$", parameters.Version.SemVersion);
ReplaceTextInFile(new FilePath(workDir + "/vss-extension.netcore.json"), "$version$", parameters.Version.SemVersion);
UpdateTaskVersion(new FilePath(workDir + "/GitVersionTask/task.json"), parameters.Version.GitVersion);
UpdateTaskVersion(new FilePath(workDir + "/GitVersionNetCoreTask/task.json"), parameters.Version.GitVersion);

// build and pack
NpmSet("progress", "false");
Expand All @@ -260,7 +260,15 @@ Task("Pack-Tfs")
{
ToolPath = workDir + "/node_modules/.bin/" + (parameters.IsRunningOnWindows ? "tfx.cmd" : "tfx"),
WorkingDirectory = workDir,
ManifestGlobs = new List<string>(){ "vss-extension.json" },
ManifestGlobs = new List<string>(){ "vss-extension.mono.json" },
OutputPath = parameters.Paths.Directories.BuildArtifact
});

TfxExtensionCreate(new TfxExtensionCreateSettings
{
ToolPath = workDir + "/node_modules/.bin/" + (parameters.IsRunningOnWindows ? "tfx.cmd" : "tfx"),
WorkingDirectory = workDir,
ManifestGlobs = new List<string>(){ "vss-extension.netcore.json" },
OutputPath = parameters.Paths.Directories.BuildArtifact
});
});
Expand Down Expand Up @@ -493,6 +501,14 @@ Task("Publish-Tfs")
AuthType = TfxAuthType.Pat,
Token = token
});

var netCoreWorkDir = "./src/GitVersionTfsTask.NetCore";
TfxExtensionPublish(parameters.Paths.Files.VsixNetCoreOutputFilePath, new TfxExtensionPublishSettings
arturcic marked this conversation as resolved.
Show resolved Hide resolved
{
ToolPath = netCoreWorkDir + "/node_modules/.bin/" + (parameters.IsRunningOnWindows ? "tfx.cmd" : "tfx"),
AuthType = TfxAuthType.Pat,
Token = token
});
})
.OnError(exception =>
{
Expand Down
1 change: 1 addition & 0 deletions build/parameters.cake
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public class BuildParameters
files.TestCoverageOutputFilePath,
files.ReleaseNotesOutputFilePath,
files.VsixOutputFilePath,
files.VsixNetCoreOutputFilePath,
files.GemOutputFilePath
});

Expand Down
5 changes: 5 additions & 0 deletions build/paths.cake
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class BuildPaths
var releaseNotesOutputFilePath = buildArtifactDir.CombineWithFilePath("releasenotes.md");

var vsixOutputFilePath = buildArtifactDir.CombineWithFilePath("gittools.gitversion-" + semVersion + ".vsix");
var vsixNetCoreOutputFilePath = buildArtifactDir.CombineWithFilePath("gittools.gitversion-netcore-" + semVersion + ".vsix");
var gemOutputFilePath = buildArtifactDir.CombineWithFilePath("gitversion-" + version.GemVersion + ".gem");

// Directories
Expand All @@ -62,6 +63,7 @@ public class BuildPaths
testCoverageOutputFilePath,
releaseNotesOutputFilePath,
vsixOutputFilePath,
vsixNetCoreOutputFilePath,
gemOutputFilePath);

return new BuildPaths
Expand All @@ -79,6 +81,7 @@ public class BuildFiles
public FilePath TestCoverageOutputFilePath { get; private set; }
public FilePath ReleaseNotesOutputFilePath { get; private set; }
public FilePath VsixOutputFilePath { get; private set; }
public FilePath VsixNetCoreOutputFilePath { get; private set; }
public FilePath GemOutputFilePath { get; private set; }

public BuildFiles(
Expand All @@ -88,6 +91,7 @@ public class BuildFiles
FilePath testCoverageOutputFilePath,
FilePath releaseNotesOutputFilePath,
FilePath vsixOutputFilePath,
FilePath vsixNetCoreOutputFilePath,
FilePath gemOutputFilePath
)
{
Expand All @@ -96,6 +100,7 @@ public class BuildFiles
TestCoverageOutputFilePath = testCoverageOutputFilePath;
ReleaseNotesOutputFilePath = releaseNotesOutputFilePath;
VsixOutputFilePath = vsixOutputFilePath;
VsixNetCoreOutputFilePath = vsixNetCoreOutputFilePath;
GemOutputFilePath = gemOutputFilePath;
}
}
Expand Down
9 changes: 9 additions & 0 deletions build/utils.cake
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,12 @@ void GetReleaseNotes(FilePath outputPath, DirectoryPath workDir, string repoToke

Information(string.Join("\n", redirectedOutput));
}

void UpdateTaskVersion(FilePath taskJsonPath, GitVersion gitVersion)
yohanb marked this conversation as resolved.
Show resolved Hide resolved
{
var taskJson = ParseJsonFromFile(taskJsonPath);
taskJson["version"]["Major"] = gitVersion.Major.ToString();
taskJson["version"]["Minor"] = gitVersion.Minor.ToString();
taskJson["version"]["Patch"] = gitVersion.Patch.ToString();
SerializeJsonToPrettyFile(taskJsonPath, taskJson);
}
90 changes: 45 additions & 45 deletions docs/build-server-support/build-server/continua.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
# Continua CI Setup
This guide explains how to run GitVersion inside [Continua CI](https://www.finalbuilder.com/continua-ci).
## Assumptions
This guide assumes a few variables are present in the configuration. Note that this example uses `Catel` as repository name, but it should be replaced by the name of the repository where GitVersion is runnign against.
* RepositoryBranchName => $Source.Catel.BranchName$
* RepositoryCommitId => $Source.Catel.LatestChangeset.Id$
* RepositoryName => Catel
* RepositoryName => $Source.Catel.Path$
* RepositoryUrl => $Source.Catel.Url$
It also requires a few variables which will automatically be filled by GitVersion. The example below are just a few, any of the GitVersion variables written to the output can be used.
* GitVersion_FullSemVer
* GitVersion_MajorMinorPatch
* GitVersion_NuGetVersion
You also need to add a property collector for the agents to detect the GitVersion tool on the agents:
* Namespace => GitVersion
* Run On => Agent
* Type => Path Finder Plugin
* Property Name => Path
* Executable => GitVersion.exe
* Search paths => your installation folder (e.g. `C:\Tools\GitVersion` or if you are using Chocolatey `C:\ProgramData\chocolatey\lib\GitVersion.Portable\tools`)
## Basic Usage
To run GitLink inside [Continua CI](https://www.finalbuilder.com/continua-ci), follow the steps below:
* Add a new `Execute Program` step to a stage
* In the `Execute Program` tab, set the following values:
* Executable path: $Agent.GitVersion.Path$
* Working directory: %RepositoryPath%
* In the `Arguments` tab, set the following values:
* Arguments: /url %RepositoryUrl% /b %RepositoryBranchName% /c %RepositoryCommitId% /output buildserver
* In the `Options` tab, set the following values:
* Wait for completion: checked
* Log output: checked
* Check program exit code: checked
* Exit code must be: equal to
* Exit code: 0
Now GitVersion will automatically run and fill the `GitVersion_` variables.
# Continua CI Setup

This guide explains how to run GitVersion inside [Continua CI](https://www.finalbuilder.com/continua-ci).

## Assumptions
This guide assumes a few variables are present in the configuration. Note that this example uses `Catel` as repository name, but it should be replaced by the name of the repository where GitVersion is runnign against.

* RepositoryBranchName => $Source.Catel.BranchName$
* RepositoryCommitId => $Source.Catel.LatestChangeset.Id$
* RepositoryName => Catel
* RepositoryName => $Source.Catel.Path$
* RepositoryUrl => $Source.Catel.Url$

It also requires a few variables which will automatically be filled by GitVersion. The example below are just a few, any of the GitVersion variables written to the output can be used.

* GitVersion_FullSemVer
* GitVersion_MajorMinorPatch
* GitVersion_NuGetVersion

You also need to add a property collector for the agents to detect the GitVersion tool on the agents:

* Namespace => GitVersion
* Run On => Agent
* Type => Path Finder Plugin
* Property Name => Path
* Executable => GitVersion.exe
* Search paths => your installation folder (e.g. `C:\Tools\GitVersion` or if you are using Chocolatey `C:\ProgramData\chocolatey\lib\GitVersion.Portable\tools`)

## Basic Usage
To run GitLink inside [Continua CI](https://www.finalbuilder.com/continua-ci), follow the steps below:

* Add a new `Execute Program` step to a stage
* In the `Execute Program` tab, set the following values:
* Executable path: $Agent.GitVersion.Path$
* Working directory: %RepositoryPath%
* In the `Arguments` tab, set the following values:
* Arguments: /url %RepositoryUrl% /b %RepositoryBranchName% /c %RepositoryCommitId% /output buildserver
* In the `Options` tab, set the following values:
* Wait for completion: checked
* Log output: checked
* Check program exit code: checked
* Exit code must be: equal to
* Exit code: 0

Now GitVersion will automatically run and fill the `GitVersion_` variables.
2 changes: 1 addition & 1 deletion src/GitVersion.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">


<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/AutoCompleteBasicCompletion/@EntryValue">True</s:Boolean>
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionCore/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: AssemblyTitle("GitVersionCore")]
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionExe/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: AssemblyTitle("GitVersion")]
Expand Down
Loading