Skip to content
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
18 changes: 2 additions & 16 deletions build/pack.cake
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,6 @@ Task("Copy-Files")
// Commandline
PublishILRepackedGitVersionExe(false, ilMergeDir, cmdlineDir, parameters);

// Vsix
var vsixPath = new DirectoryPath("./src/GitVersionVsixTask/GitVersionTask");

var vsixPathFull = vsixPath.Combine("full");
EnsureDirectoryExists(vsixPathFull);
CopyFileToDirectory(portableDir + "/" + "LibGit2Sharp.dll.config", vsixPathFull);
CopyFileToDirectory(portableDir + "/" + "GitVersion.exe", vsixPathFull);
CopyDirectory(portableDir.Combine("lib"), vsixPathFull.Combine("lib"));

// Vsix dotnet core
var vsixPathCore = vsixPath.Combine("core");
EnsureDirectoryExists(vsixPathCore);
CopyDirectory(coreFxDir, vsixPathCore);

// Ruby Gem
var gemPath = new DirectoryPath("./src/GitVersionRubyGem/bin");
EnsureDirectoryExists(gemPath);
Expand All @@ -200,14 +186,14 @@ Task("Copy-Files")
});

Task("Pack-Vsix")
.IsDependentOn("Copy-Files")
.IsDependentOn("Test")
.Does<BuildParameters>((parameters) =>
{
var workDir = "./src/GitVersionVsixTask";
var idSuffix = parameters.IsStableRelease() ? "" : "-preview";
var titleSuffix = parameters.IsStableRelease() ? "" : " (Preview)";
var visibility = parameters.IsStableRelease() ? "Public" : "Preview";
var taskId = parameters.IsStableRelease() ? "e5983830-3f75-11e5-82ed-81492570a08e" : "25b46667-d5a9-4665-97f7-e23de366ecdf";
var taskId = parameters.IsStableRelease() ? "bab30d5c-39f3-49b0-a7db-9a5da6676eaa" : "dd065e3b-6aef-46af-845c-520195836b35";

ReplaceTextInFile(new FilePath(workDir + "/vss-extension.json"), "$idSuffix$", idSuffix);
ReplaceTextInFile(new FilePath(workDir + "/vss-extension.json"), "$titleSuffix$", titleSuffix);
Expand Down
2 changes: 1 addition & 1 deletion build/utils/paths.cake
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class BuildPaths
var gemOutputFilePath = buildArtifactDir.CombineWithFilePath("gitversion-" + version.GemVersion + ".gem");

var vsixSuffix = parameters.IsStableRelease() ? "" : "preview-";
var vsixOutputFilePath = buildArtifactDir.CombineWithFilePath("gittools.gitversion-" + vsixSuffix + version.VsixVersion + ".vsix");
var vsixOutputFilePath = buildArtifactDir.CombineWithFilePath("gittools.usegitversion-" + vsixSuffix + version.VsixVersion + ".vsix");

// Directories
var buildDirectories = new BuildDirectories(
Expand Down
69 changes: 19 additions & 50 deletions src/GitVersionVsixTask/GitVersion.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
import * as path from 'path';
import * as os from 'os';

import * as tl from 'azure-pipelines-task-lib/task';
import * as tr from 'azure-pipelines-task-lib/toolrunner';

import { ToolInstaller } from './ToolInstaller';

export class GitVersionTask {
execOptions: tr.IExecOptions;

preferBundledVersion: boolean;
versionSpec: string;
includePrerelease: boolean;
targetPath: string;

useConfigFile: boolean;
configFilePath: string;
updateAssemblyInfo: boolean;

updateAssemblyInfo: boolean;
updateAssemblyInfoFilename: string;

additionalArguments: string;
targetPath: string;

sourcesDirectory: string;
gitVersionPath: string;
runtime: string;

constructor() {

this.versionSpec = tl.getInput('versionSpec', true);
this.includePrerelease = tl.getBoolInput('includePrerelease');
this.targetPath = tl.getInput('targetPath');

this.useConfigFile = tl.getBoolInput('useConfigFile');
Expand All @@ -29,10 +34,6 @@ export class GitVersionTask {
this.updateAssemblyInfo = tl.getBoolInput('updateAssemblyInfo');
this.updateAssemblyInfoFilename = tl.getInput('updateAssemblyInfoFilename');

this.preferBundledVersion = tl.getBoolInput('preferBundledVersion');
this.runtime = tl.getInput('runtime') || 'core';
this.gitVersionPath = tl.getInput('gitVersionPath');

this.additionalArguments = tl.getInput('additionalArguments');

this.sourcesDirectory = tl.getVariable('Build.SourcesDirectory').replace(/\\/g, '/');
Expand All @@ -51,8 +52,10 @@ export class GitVersionTask {

public async execute() {
try {
let toolPath = await this.installTool(this.versionSpec, this.includePrerelease);

let workingDirectory = this.getWorkingDirectory(this.targetPath);
let exe = this.getExecutable();
let exe = tl.tool('dotnet-gitversion');
exe.arg([
workingDirectory,
"/output",
Expand Down Expand Up @@ -95,48 +98,14 @@ export class GitVersionTask {
}
}

public getExecutable(){
let exe: tr.ToolRunner;

switch (this.runtime) {
case "full":
const isWin32 = os.platform() == "win32";
let exePath = this.getExecutablePath("GitVersion.exe") || tl.which("GitVersion.exe", true);
if (isWin32) {
exe = tl.tool(exePath);
} else {
exe = tl.tool("mono");
exe.arg(exePath);
}
break;
case "core":
let assemblyPath = this.getExecutablePath("GitVersion.dll");
let dotnetPath = tl.which("dotnet", true);
exe = tl.tool(dotnetPath);
exe.arg(assemblyPath);
break;
async installTool(version: string, includePrerelease: boolean) : Promise<string> {
let installTool = tl.getVariable("INSTALL_TOOL");
if (installTool === null || installTool === undefined || installTool.toUpperCase() == "TRUE") {
return await new ToolInstaller().downloadAndInstall("GitVersion.Tool", version, false, includePrerelease);
}

return exe;
}

public getExecutablePath(exeName:string) {
let exePath;
if (this.preferBundledVersion) {
let currentDirectory = __dirname;
exePath = path.join(currentDirectory, this.runtime, exeName);
} else {
if (tl.filePathSupplied('gitVersionPath') && tl.exist(this.gitVersionPath) && tl.stats(this.gitVersionPath).isFile()) {
exePath = this.gitVersionPath;
} else{
throw new Error('GitVersion executable not found at ' + this.gitVersionPath);
}
}

return exePath.replace(/\\/g, '/');
}

public getWorkingDirectory(targetPath: string) {
getWorkingDirectory(targetPath: string) {
let workDir;

if (!targetPath){
Expand Down
91 changes: 44 additions & 47 deletions src/GitVersionVsixTask/GitVersionTask/task.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,56 @@
{
"id": "e5983830-3f75-11e5-82ed-81492570a08e",
"name": "GitVersion",
"id": "dd065e3b-6aef-46af-845c-520195836b35",
"name": "UseGitVersion",
"friendlyName": "GitVersion Task",
"description": "Easy Semantic Versioning (http://semver.org) for projects using Git",
"author": "GitVersion Contributors",
"helpMarkDown": "See the [documentation](http://gitversion.readthedocs.org/en/latest/) for help",
"category": "Build",
"demands": [],
"version": {
"Major": "4",
"Major": "5",
"Minor": "0",
"Patch": "0"
"Patch": "2"
},
"minimumAgentVersion": "2.115.0",
"groups": [{
"name": "gitversionDetails",
"displayName": "GitVersion details",
"isExpanded": true,
"visibleRule": "preferBundledVersion = false"
}, {
"name": "additional",
"displayName": "Additional Options",
"isExpanded": false
}],
"groups": [
{
"name": "gitversionDetails",
"displayName": "GitVersion details",
"isExpanded": true
},
{
"name": "additional",
"displayName": "Additional Options",
"isExpanded": false
}
],
"instanceNameFormat": "GitVersion",
"inputs": [{
"name": "runtime",
"type": "radio",
"label": "Runtime",
"defaultValue": "core",
"inputs": [
{
"name": "versionSpec",
"type": "string",
"label": "The version spec",
"defaultValue": "",
"required": true,
"options": {
"core": "dotnet core",
"full": "dotnet fullframework (or mono)"
},
"helpMarkDown": "Specify the runtime used for running the tool"
}, {
"name": "preferBundledVersion",
"helpMarkDown": "Required version in the form of 5.x or exact version like 5.0.0"
},
{
"name": "includePrerelease",
"type": "boolean",
"label": "Prefer bundled GitVersion",
"defaultValue": "true",
"label": "Include pre-release versions",
"defaultValue": "false",
"required": false,
"helpMarkDown": "If checked it will prefer the bundled version over a version found in path"
}, {
"name": "gitVersionPath",
"helpMarkDown": "Include pre-release versions when matching a version"
},
{
"name": "targetPath",
"type": "string",
"label": "Path to GitVersion",
"label": "Working directory path",
"defaultValue": "",
"required": false,
"helpMarkDown": "Optionally supply the path to GitVersion",
"visibleRule": "preferBundledVersion = true"
"helpMarkDown": "Optionally supply the path to the working directory",
"groupName": "gitversionDetails"
},
{
"name": "useConfigFile",
Expand All @@ -58,38 +59,34 @@
"defaultValue": "false",
"required": false,
"helpMarkDown": "Whether to use a custom configuration file"
}, {
},
{
"name": "configFilePath",
"type": "filePath",
"label": "Configuration file",
"defaultValue": "",
"required": false,
"helpMarkDown": "Optional path to config file (defaults to GitVersion.yml)",
"visibleRule": "useConfigFile = true"
}, {
},
{
"name": "updateAssemblyInfo",
"type": "boolean",
"label": "Update AssemblyInfo files",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Whether to update versions in the AssemblyInfo files"
}, {
},
{
"name": "updateAssemblyInfoFilename",
"type": "string",
"label": "Update Assembly File",
"defaultValue": "",
"required": false,
"helpMarkDown": "Update versions in specified file",
"visibleRule": "updateAssemblyInfo = true"
}, {
"name": "targetPath",
"type": "string",
"label": "Working directory path",
"defaultValue": "",
"required": false,
"helpMarkDown": "Optionally supply the path to the working directory",
"groupName": "gitversionDetails"
}, {
},
{
"name": "additionalArguments",
"type": "string",
"label": "Additional GitVersion arguments",
Expand All @@ -106,4 +103,4 @@
"workingDirectory": "."
}
}
}
}
Loading