diff --git a/src/GitVersionTfsTask/GitVersion.ts b/src/GitVersionTfsTask/GitVersion.ts index cef9c58c14..8c4e2f00c4 100644 --- a/src/GitVersionTfsTask/GitVersion.ts +++ b/src/GitVersionTfsTask/GitVersion.ts @@ -12,10 +12,13 @@ export class GitVersionTask { const updateAssemblyInfo = tl.getBoolInput('updateAssemblyInfo'); const updateAssemblyInfoFilename = tl.getInput('updateAssemblyInfoFilename'); const additionalArguments = tl.getInput('additionalArguments'); + const targetPath = tl.getInput('targetPath'); const preferBundledVersion = tl.getBoolInput('preferBundledVersion'); const currentDirectory = __dirname; - const sourcesDirectory = tl.getVariable("Build.SourcesDirectory") || "."; + const workingDirectory = !targetPath + ? tl.getVariable("Build.SourcesDirectory") + : path.join(tl.getVariable("Build.SourcesDirectory"), targetPath); let gitVersionPath = tl.getInput('gitVersionPath'); if (!gitVersionPath) { @@ -69,7 +72,7 @@ export class GitVersionTask { } toolRunner.arg([ - sourcesDirectory, + workingDirectory, "/output", "buildserver", "/nofetch"]); diff --git a/src/GitVersionTfsTask/GitVersionTask/task.json b/src/GitVersionTfsTask/GitVersionTask/task.json index b25397fe5d..03920e6a1f 100644 --- a/src/GitVersionTfsTask/GitVersionTask/task.json +++ b/src/GitVersionTfsTask/GitVersionTask/task.json @@ -54,6 +54,15 @@ "helpMarkDown": "Optionally supply the path to GitVersion.exe", "groupName": "additional" }, + { + "name": "targetPath", + "type": "string", + "label": "Working directory path", + "defaultValue": "", + "required": false, + "helpMarkDown": "Optionally supply the path to the working directory", + "groupName": "additional" + }, { "name": "preferBundledVersion", "type": "boolean",