From e75447f81555d7c74825857a829ae180bf9e36fe Mon Sep 17 00:00:00 2001 From: Daniel Khodabakhsh Date: Mon, 3 Jun 2019 16:34:40 -0700 Subject: [PATCH 1/8] Fix DotNetCoreCLIV2 not being able to restore custom MsBuild SDKs. --- Tasks/DotNetCoreCLIV2/restorecommand.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Tasks/DotNetCoreCLIV2/restorecommand.ts b/Tasks/DotNetCoreCLIV2/restorecommand.ts index 5f05b223ea9f..c9d433755148 100644 --- a/Tasks/DotNetCoreCLIV2/restorecommand.ts +++ b/Tasks/DotNetCoreCLIV2/restorecommand.ts @@ -1,3 +1,4 @@ +import * as fs from 'fs'; import * as tl from 'azure-pipelines-task-lib/task'; import * as Q from 'q'; import * as utility from './Common/utility'; @@ -11,6 +12,8 @@ import * as commandHelper from 'packaging-common/nuget/CommandHelper'; import * as pkgLocationUtils from 'packaging-common/locationUtilities'; import { getProjectAndFeedIdFromInputParam } from 'packaging-common/util'; +const nugetFileName: string = 'nuget.config'; + export async function run(): Promise { let packagingLocation: pkgLocationUtils.PackagingLocation; try { @@ -125,6 +128,13 @@ export async function run(): Promise { nuGetConfigHelper.setAuthForSourcesInTempNuGetConfig(); const configFile = nuGetConfigHelper.tempNugetConfigPath; + + // TODO: Remove this once NuGet issue https://github.com/NuGet/Home/issues/7855 is fixed. + const nuGetFiles = fs.readdirSync('.').filter((file) => file.toLowerCase() === nugetFileName); + const temporaryRootNugetName = (nugetFile: string) => `tempRename_${tl.getVariable('build.buildId')}_${nugetFile}`; + nuGetFiles.forEach((file) => fs.renameSync(file, temporaryRootNugetName(file))); + fs.writeFileSync(nugetFileName, fs.readFileSync(configFile)); + const dotnetPath = tl.which('dotnet', true); try { @@ -133,6 +143,10 @@ export async function run(): Promise { } } finally { credCleanup(); + + // TODO: Remove this once NuGet issue https://github.com/NuGet/Home/issues/7855 is fixed. + fs.unlinkSync(nugetFileName); + nuGetFiles.forEach((file) => fs.renameSync(temporaryRootNugetName(file), file)); } tl.setResult(tl.TaskResult.Succeeded, tl.loc('PackagesInstalledSuccessfully')); From 7d831fc141df975f207d6c9275ef9542c55bb949 Mon Sep 17 00:00:00 2001 From: Daniel Khodabakhsh Date: Tue, 4 Jun 2019 01:58:39 -0700 Subject: [PATCH 2/8] Fix unit tests. --- .../nuget/NuGetConfigHelper2.ts | 21 +++++++++++++++++++ .../Tests/NuGetConfigHelper-mock.ts | 4 ++++ Tasks/DotNetCoreCLIV2/restorecommand.ts | 12 ++--------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts b/Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts index 069173d43410..e16c05eea811 100644 --- a/Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts +++ b/Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts @@ -14,9 +14,12 @@ import * as ngutil from "./Utility"; // NuGetConfigHelper2 handles authenticated scenarios where the user selects a source from the UI or from a service connection. // It is used by the NuGetCommand >= v2.0.0 and DotNetCoreCLI >= v2.0.0 +const nugetFileName: string = 'nuget.config'; + export class NuGetConfigHelper2 { public tempNugetConfigPath = undefined; private nugetXmlHelper: INuGetXmlHelper; + private nuGetFiles: Array; constructor( private nugetPath: string, @@ -158,6 +161,19 @@ export class NuGetConfigHelper2 { return packageSources.map((source) => this.convertToIPackageSource(source)); } + // TODO: Remove this once NuGet issue https://github.com/NuGet/Home/issues/7855 is fixed. + public backupExistingNuGetFiles(): void { + this.nuGetFiles = fs.readdirSync('.').filter((file) => file.toLowerCase() === nugetFileName); + this.nuGetFiles.forEach((file) => fs.renameSync(file, this.temporaryRootNugetName(file))); + fs.writeFileSync(nugetFileName, fs.readFileSync(this.tempNugetConfigPath)); + } + + // TODO: Remove this once NuGet issue https://github.com/NuGet/Home/issues/7855 is fixed. + public restoreBackupNuGetFiles(): void { + fs.unlinkSync(nugetFileName); + this.nuGetFiles.forEach((file) => fs.renameSync(this.temporaryRootNugetName(file), file)); + } + private removeSourceFromTempNugetConfig(packageSource: IPackageSource) { this.nugetXmlHelper.RemoveSourceFromNuGetConfig(packageSource.feedName); } @@ -188,4 +204,9 @@ export class NuGetConfigHelper2 { isInternal }; } + + // TODO: Remove this once NuGet issue https://github.com/NuGet/Home/issues/7855 is fixed. + private temporaryRootNugetName(nugetFile: string) { + return `tempRename_${tl.getVariable('build.buildId')}_${nugetFile}`; + } } diff --git a/Tasks/DotNetCoreCLIV2/Tests/NuGetConfigHelper-mock.ts b/Tasks/DotNetCoreCLIV2/Tests/NuGetConfigHelper-mock.ts index 9ce67e433b83..f438a3348c3d 100644 --- a/Tasks/DotNetCoreCLIV2/Tests/NuGetConfigHelper-mock.ts +++ b/Tasks/DotNetCoreCLIV2/Tests/NuGetConfigHelper-mock.ts @@ -16,4 +16,8 @@ export class NuGetConfigHelper2 { static getTempNuGetConfigBasePath() { return tl.getVariable("Agent.HomeDirectory"); } + + backupExistingNuGetFiles() {} + + restoreBackupNuGetFiles() {} } \ No newline at end of file diff --git a/Tasks/DotNetCoreCLIV2/restorecommand.ts b/Tasks/DotNetCoreCLIV2/restorecommand.ts index c9d433755148..14038b84421b 100644 --- a/Tasks/DotNetCoreCLIV2/restorecommand.ts +++ b/Tasks/DotNetCoreCLIV2/restorecommand.ts @@ -12,8 +12,6 @@ import * as commandHelper from 'packaging-common/nuget/CommandHelper'; import * as pkgLocationUtils from 'packaging-common/locationUtilities'; import { getProjectAndFeedIdFromInputParam } from 'packaging-common/util'; -const nugetFileName: string = 'nuget.config'; - export async function run(): Promise { let packagingLocation: pkgLocationUtils.PackagingLocation; try { @@ -129,11 +127,7 @@ export async function run(): Promise { const configFile = nuGetConfigHelper.tempNugetConfigPath; - // TODO: Remove this once NuGet issue https://github.com/NuGet/Home/issues/7855 is fixed. - const nuGetFiles = fs.readdirSync('.').filter((file) => file.toLowerCase() === nugetFileName); - const temporaryRootNugetName = (nugetFile: string) => `tempRename_${tl.getVariable('build.buildId')}_${nugetFile}`; - nuGetFiles.forEach((file) => fs.renameSync(file, temporaryRootNugetName(file))); - fs.writeFileSync(nugetFileName, fs.readFileSync(configFile)); + nuGetConfigHelper.backupExistingNuGetFiles(); const dotnetPath = tl.which('dotnet', true); @@ -144,9 +138,7 @@ export async function run(): Promise { } finally { credCleanup(); - // TODO: Remove this once NuGet issue https://github.com/NuGet/Home/issues/7855 is fixed. - fs.unlinkSync(nugetFileName); - nuGetFiles.forEach((file) => fs.renameSync(temporaryRootNugetName(file), file)); + nuGetConfigHelper.restoreBackupNuGetFiles(); } tl.setResult(tl.TaskResult.Succeeded, tl.loc('PackagesInstalledSuccessfully')); From 920d133e950cce42624858543e4b4e96644cb088 Mon Sep 17 00:00:00 2001 From: Daniel Khodabakhsh Date: Tue, 4 Jun 2019 02:42:20 -0700 Subject: [PATCH 3/8] Bump versions. --- Tasks/DotNetCoreCLIV2/task.json | 2 +- Tasks/DotNetCoreCLIV2/task.loc.json | 2 +- Tasks/DownloadPackageV0/task.json | 2 +- Tasks/DownloadPackageV0/task.loc.json | 2 +- Tasks/DownloadPackageV1/task.json | 2 +- Tasks/DownloadPackageV1/task.loc.json | 2 +- Tasks/NpmAuthenticateV0/task.json | 2 +- Tasks/NpmAuthenticateV0/task.loc.json | 2 +- Tasks/NpmV1/task.json | 2 +- Tasks/NpmV1/task.loc.json | 2 +- Tasks/NuGetCommandV2/task.json | 2 +- Tasks/NuGetCommandV2/task.loc.json | 2 +- Tasks/NuGetPublisherV0/task.json | 2 +- Tasks/NuGetPublisherV0/task.loc.json | 2 +- Tasks/NuGetToolInstallerV0/task.json | 2 +- Tasks/NuGetToolInstallerV0/task.loc.json | 2 +- Tasks/NuGetToolInstallerV1/task.json | 2 +- Tasks/NuGetToolInstallerV1/task.loc.json | 2 +- Tasks/NuGetV0/task.json | 2 +- Tasks/NuGetV0/task.loc.json | 2 +- Tasks/PipAuthenticateV0/task.json | 2 +- Tasks/PipAuthenticateV0/task.loc.json | 2 +- Tasks/TwineAuthenticateV0/task.json | 2 +- Tasks/TwineAuthenticateV0/task.loc.json | 2 +- Tasks/UniversalPackagesV0/task.json | 2 +- Tasks/UniversalPackagesV0/task.loc.json | 2 +- Tasks/UseDotNetV2/task.json | 2 +- Tasks/UseDotNetV2/task.loc.json | 2 +- Tasks/UseNodeV1/task.json | 2 +- Tasks/UseNodeV1/task.loc.json | 2 +- 30 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Tasks/DotNetCoreCLIV2/task.json b/Tasks/DotNetCoreCLIV2/task.json index b1217278690c..070a9bd4c396 100644 --- a/Tasks/DotNetCoreCLIV2/task.json +++ b/Tasks/DotNetCoreCLIV2/task.json @@ -18,7 +18,7 @@ "version": { "Major": 2, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "minimumAgentVersion": "2.115.0", "instanceNameFormat": "dotnet $(command)", diff --git a/Tasks/DotNetCoreCLIV2/task.loc.json b/Tasks/DotNetCoreCLIV2/task.loc.json index 223cf7d7dd97..ee46e8d26476 100644 --- a/Tasks/DotNetCoreCLIV2/task.loc.json +++ b/Tasks/DotNetCoreCLIV2/task.loc.json @@ -18,7 +18,7 @@ "version": { "Major": 2, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "minimumAgentVersion": "2.115.0", "instanceNameFormat": "ms-resource:loc.instanceNameFormat", diff --git a/Tasks/DownloadPackageV0/task.json b/Tasks/DownloadPackageV0/task.json index 16ef0fd39507..6002c1afbcc5 100644 --- a/Tasks/DownloadPackageV0/task.json +++ b/Tasks/DownloadPackageV0/task.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "demands": [], "minimumAgentVersion": "1.99.0", diff --git a/Tasks/DownloadPackageV0/task.loc.json b/Tasks/DownloadPackageV0/task.loc.json index 6e823af4b1e5..c771998e852e 100644 --- a/Tasks/DownloadPackageV0/task.loc.json +++ b/Tasks/DownloadPackageV0/task.loc.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "demands": [], "minimumAgentVersion": "1.99.0", diff --git a/Tasks/DownloadPackageV1/task.json b/Tasks/DownloadPackageV1/task.json index 37465122268f..54fca11dd914 100644 --- a/Tasks/DownloadPackageV1/task.json +++ b/Tasks/DownloadPackageV1/task.json @@ -10,7 +10,7 @@ "version": { "Major": 1, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "demands": [], "releaseNotes": "Adds support to download Maven, Python, Universal and Npm packages.", diff --git a/Tasks/DownloadPackageV1/task.loc.json b/Tasks/DownloadPackageV1/task.loc.json index 3e1910476aee..5c9ce212514c 100644 --- a/Tasks/DownloadPackageV1/task.loc.json +++ b/Tasks/DownloadPackageV1/task.loc.json @@ -10,7 +10,7 @@ "version": { "Major": 1, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "demands": [], "releaseNotes": "ms-resource:loc.releaseNotes", diff --git a/Tasks/NpmAuthenticateV0/task.json b/Tasks/NpmAuthenticateV0/task.json index 370323a351a7..b7f13cb416e9 100644 --- a/Tasks/NpmAuthenticateV0/task.json +++ b/Tasks/NpmAuthenticateV0/task.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 0 + "Patch": 1 }, "runsOn": [ "Agent", diff --git a/Tasks/NpmAuthenticateV0/task.loc.json b/Tasks/NpmAuthenticateV0/task.loc.json index 8ded62a626e0..730a54e19790 100644 --- a/Tasks/NpmAuthenticateV0/task.loc.json +++ b/Tasks/NpmAuthenticateV0/task.loc.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 0 + "Patch": 1 }, "runsOn": [ "Agent", diff --git a/Tasks/NpmV1/task.json b/Tasks/NpmV1/task.json index ba016b682387..edc26e6ea864 100644 --- a/Tasks/NpmV1/task.json +++ b/Tasks/NpmV1/task.json @@ -10,7 +10,7 @@ "version": { "Major": 1, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/NpmV1/task.loc.json b/Tasks/NpmV1/task.loc.json index 9985e7ce93ce..98404e763d94 100644 --- a/Tasks/NpmV1/task.loc.json +++ b/Tasks/NpmV1/task.loc.json @@ -10,7 +10,7 @@ "version": { "Major": 1, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/NuGetCommandV2/task.json b/Tasks/NuGetCommandV2/task.json index c015a9595657..7d5277737aef 100644 --- a/Tasks/NuGetCommandV2/task.json +++ b/Tasks/NuGetCommandV2/task.json @@ -10,7 +10,7 @@ "version": { "Major": 2, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/NuGetCommandV2/task.loc.json b/Tasks/NuGetCommandV2/task.loc.json index 193e4958cfb7..94bd28afe67c 100644 --- a/Tasks/NuGetCommandV2/task.loc.json +++ b/Tasks/NuGetCommandV2/task.loc.json @@ -10,7 +10,7 @@ "version": { "Major": 2, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/NuGetPublisherV0/task.json b/Tasks/NuGetPublisherV0/task.json index 3a587145d313..c0409cbb48e9 100644 --- a/Tasks/NuGetPublisherV0/task.json +++ b/Tasks/NuGetPublisherV0/task.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 0 + "Patch": 1 }, "runsOn": [ "Agent", diff --git a/Tasks/NuGetPublisherV0/task.loc.json b/Tasks/NuGetPublisherV0/task.loc.json index b4cc8d318b01..819b33a606de 100644 --- a/Tasks/NuGetPublisherV0/task.loc.json +++ b/Tasks/NuGetPublisherV0/task.loc.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 0 + "Patch": 1 }, "runsOn": [ "Agent", diff --git a/Tasks/NuGetToolInstallerV0/task.json b/Tasks/NuGetToolInstallerV0/task.json index 0a0b8d1d951d..f5f86ebecdfb 100644 --- a/Tasks/NuGetToolInstallerV0/task.json +++ b/Tasks/NuGetToolInstallerV0/task.json @@ -15,7 +15,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 0 + "Patch": 1 }, "preview": false, "satisfies": [ diff --git a/Tasks/NuGetToolInstallerV0/task.loc.json b/Tasks/NuGetToolInstallerV0/task.loc.json index f97e5c323c12..e79cf8084ff6 100644 --- a/Tasks/NuGetToolInstallerV0/task.loc.json +++ b/Tasks/NuGetToolInstallerV0/task.loc.json @@ -15,7 +15,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 0 + "Patch": 1 }, "preview": false, "satisfies": [ diff --git a/Tasks/NuGetToolInstallerV1/task.json b/Tasks/NuGetToolInstallerV1/task.json index 3e8b36daf9c6..59be139c29f9 100644 --- a/Tasks/NuGetToolInstallerV1/task.json +++ b/Tasks/NuGetToolInstallerV1/task.json @@ -15,7 +15,7 @@ "version": { "Major": 1, "Minor": 153, - "Patch": 0 + "Patch": 1 }, "preview": false, "satisfies": [ diff --git a/Tasks/NuGetToolInstallerV1/task.loc.json b/Tasks/NuGetToolInstallerV1/task.loc.json index df0c51cc011c..6b7f3b385d0c 100644 --- a/Tasks/NuGetToolInstallerV1/task.loc.json +++ b/Tasks/NuGetToolInstallerV1/task.loc.json @@ -15,7 +15,7 @@ "version": { "Major": 1, "Minor": 153, - "Patch": 0 + "Patch": 1 }, "preview": false, "satisfies": [ diff --git a/Tasks/NuGetV0/task.json b/Tasks/NuGetV0/task.json index daf85ec77084..7508da8e474a 100644 --- a/Tasks/NuGetV0/task.json +++ b/Tasks/NuGetV0/task.json @@ -11,7 +11,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/NuGetV0/task.loc.json b/Tasks/NuGetV0/task.loc.json index eb4240c6ac91..6262e42edf50 100644 --- a/Tasks/NuGetV0/task.loc.json +++ b/Tasks/NuGetV0/task.loc.json @@ -11,7 +11,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/PipAuthenticateV0/task.json b/Tasks/PipAuthenticateV0/task.json index f6430f07c356..1cdf832785a3 100644 --- a/Tasks/PipAuthenticateV0/task.json +++ b/Tasks/PipAuthenticateV0/task.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/PipAuthenticateV0/task.loc.json b/Tasks/PipAuthenticateV0/task.loc.json index 10266ae58f45..d96352e2e180 100644 --- a/Tasks/PipAuthenticateV0/task.loc.json +++ b/Tasks/PipAuthenticateV0/task.loc.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/TwineAuthenticateV0/task.json b/Tasks/TwineAuthenticateV0/task.json index 72d18dc36405..461bd5647049 100644 --- a/Tasks/TwineAuthenticateV0/task.json +++ b/Tasks/TwineAuthenticateV0/task.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/TwineAuthenticateV0/task.loc.json b/Tasks/TwineAuthenticateV0/task.loc.json index 0d7d4c60e72c..9a26964c8d3f 100644 --- a/Tasks/TwineAuthenticateV0/task.loc.json +++ b/Tasks/TwineAuthenticateV0/task.loc.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/UniversalPackagesV0/task.json b/Tasks/UniversalPackagesV0/task.json index afc05c0e5431..99c22bdb35be 100644 --- a/Tasks/UniversalPackagesV0/task.json +++ b/Tasks/UniversalPackagesV0/task.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/UniversalPackagesV0/task.loc.json b/Tasks/UniversalPackagesV0/task.loc.json index c2b5127a9d46..0bed9ee23bd3 100644 --- a/Tasks/UniversalPackagesV0/task.loc.json +++ b/Tasks/UniversalPackagesV0/task.loc.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/UseDotNetV2/task.json b/Tasks/UseDotNetV2/task.json index 3502e73be36e..7209fbcdcced 100644 --- a/Tasks/UseDotNetV2/task.json +++ b/Tasks/UseDotNetV2/task.json @@ -15,7 +15,7 @@ "version": { "Major": 2, "Minor": 0, - "Patch": 5 + "Patch": 6 }, "satisfies": [ "DotNetCore" diff --git a/Tasks/UseDotNetV2/task.loc.json b/Tasks/UseDotNetV2/task.loc.json index 141d36e96332..f3c502659e7e 100644 --- a/Tasks/UseDotNetV2/task.loc.json +++ b/Tasks/UseDotNetV2/task.loc.json @@ -15,7 +15,7 @@ "version": { "Major": 2, "Minor": 0, - "Patch": 5 + "Patch": 6 }, "satisfies": [ "DotNetCore" diff --git a/Tasks/UseNodeV1/task.json b/Tasks/UseNodeV1/task.json index 2adb3d7f7d56..83d48712fdcf 100644 --- a/Tasks/UseNodeV1/task.json +++ b/Tasks/UseNodeV1/task.json @@ -17,7 +17,7 @@ "version": { "Major": 1, "Minor": 153, - "Patch": 0 + "Patch": 1 }, "satisfies": [ "Node", diff --git a/Tasks/UseNodeV1/task.loc.json b/Tasks/UseNodeV1/task.loc.json index edb1a18f4724..c02bee2a3b6d 100644 --- a/Tasks/UseNodeV1/task.loc.json +++ b/Tasks/UseNodeV1/task.loc.json @@ -17,7 +17,7 @@ "version": { "Major": 1, "Minor": 153, - "Patch": 0 + "Patch": 1 }, "satisfies": [ "Node", From d5f3738dd2d51f3ba4f302296c631e64c04ddec3 Mon Sep 17 00:00:00 2001 From: Daniel Khodabakhsh Date: Tue, 4 Jun 2019 17:15:36 -0700 Subject: [PATCH 4/8] Remove unused import. --- Tasks/DotNetCoreCLIV2/restorecommand.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/Tasks/DotNetCoreCLIV2/restorecommand.ts b/Tasks/DotNetCoreCLIV2/restorecommand.ts index 14038b84421b..c23ce4907bd7 100644 --- a/Tasks/DotNetCoreCLIV2/restorecommand.ts +++ b/Tasks/DotNetCoreCLIV2/restorecommand.ts @@ -1,4 +1,3 @@ -import * as fs from 'fs'; import * as tl from 'azure-pipelines-task-lib/task'; import * as Q from 'q'; import * as utility from './Common/utility'; From 4165207d9f64a5bf3721566cb3fb45f6017dad5c Mon Sep 17 00:00:00 2001 From: Daniel Khodabakhsh Date: Fri, 7 Jun 2019 11:53:08 -0700 Subject: [PATCH 5/8] Code review changes. --- .../nuget/NuGetConfigHelper2.ts | 31 +++++++++++-------- .../Tests/NuGetConfigHelper-mock.ts | 4 +-- Tasks/DotNetCoreCLIV2/restorecommand.ts | 4 +-- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts b/Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts index e16c05eea811..7f3d6e876794 100644 --- a/Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts +++ b/Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts @@ -19,7 +19,7 @@ const nugetFileName: string = 'nuget.config'; export class NuGetConfigHelper2 { public tempNugetConfigPath = undefined; private nugetXmlHelper: INuGetXmlHelper; - private nuGetFiles: Array; + private rootNuGetFiles: Array; constructor( private nugetPath: string, @@ -161,17 +161,19 @@ export class NuGetConfigHelper2 { return packageSources.map((source) => this.convertToIPackageSource(source)); } - // TODO: Remove this once NuGet issue https://github.com/NuGet/Home/issues/7855 is fixed. - public backupExistingNuGetFiles(): void { - this.nuGetFiles = fs.readdirSync('.').filter((file) => file.toLowerCase() === nugetFileName); - this.nuGetFiles.forEach((file) => fs.renameSync(file, this.temporaryRootNugetName(file))); - fs.writeFileSync(nugetFileName, fs.readFileSync(this.tempNugetConfigPath)); + // TODO: Remove these two methods once NuGet issue https://github.com/NuGet/Home/issues/7855 is fixed. + public backupExistingRootNuGetFiles(): void { + this.rootNuGetFiles = fs.readdirSync('.').filter((file) => file.toLowerCase() === nugetFileName); + if (this.shouldWriteRootNuGetFiles()) { + this.rootNuGetFiles.forEach((file) => fs.renameSync(file, this.temporaryRootNuGetName(file))); + fs.writeFileSync(nugetFileName, fs.readFileSync(this.tempNugetConfigPath)); + } } - - // TODO: Remove this once NuGet issue https://github.com/NuGet/Home/issues/7855 is fixed. - public restoreBackupNuGetFiles(): void { - fs.unlinkSync(nugetFileName); - this.nuGetFiles.forEach((file) => fs.renameSync(this.temporaryRootNugetName(file), file)); + public restoreBackupRootNuGetFiles(): void { + if (this.shouldWriteRootNuGetFiles()) { + fs.unlinkSync(nugetFileName); + this.rootNuGetFiles.forEach((file) => fs.renameSync(this.temporaryRootNuGetName(file), file)); + } } private removeSourceFromTempNugetConfig(packageSource: IPackageSource) { @@ -205,8 +207,11 @@ export class NuGetConfigHelper2 { }; } - // TODO: Remove this once NuGet issue https://github.com/NuGet/Home/issues/7855 is fixed. - private temporaryRootNugetName(nugetFile: string) { + // TODO: Remove these two methods once NuGet issue https://github.com/NuGet/Home/issues/7855 is fixed. + private temporaryRootNuGetName(nugetFile: string): string { return `tempRename_${tl.getVariable('build.buildId')}_${nugetFile}`; } + private shouldWriteRootNuGetFiles(): boolean { + return this.nugetConfigPath.toLocaleLowerCase() == nugetFileName || this.rootNuGetFiles.length == 0; + } } diff --git a/Tasks/DotNetCoreCLIV2/Tests/NuGetConfigHelper-mock.ts b/Tasks/DotNetCoreCLIV2/Tests/NuGetConfigHelper-mock.ts index f438a3348c3d..e8a85791c5e2 100644 --- a/Tasks/DotNetCoreCLIV2/Tests/NuGetConfigHelper-mock.ts +++ b/Tasks/DotNetCoreCLIV2/Tests/NuGetConfigHelper-mock.ts @@ -17,7 +17,7 @@ export class NuGetConfigHelper2 { return tl.getVariable("Agent.HomeDirectory"); } - backupExistingNuGetFiles() {} + backupExistingRootNuGetFiles() {} - restoreBackupNuGetFiles() {} + restoreBackupRootNuGetFiles() {} } \ No newline at end of file diff --git a/Tasks/DotNetCoreCLIV2/restorecommand.ts b/Tasks/DotNetCoreCLIV2/restorecommand.ts index c23ce4907bd7..b2992ef09d2d 100644 --- a/Tasks/DotNetCoreCLIV2/restorecommand.ts +++ b/Tasks/DotNetCoreCLIV2/restorecommand.ts @@ -126,7 +126,7 @@ export async function run(): Promise { const configFile = nuGetConfigHelper.tempNugetConfigPath; - nuGetConfigHelper.backupExistingNuGetFiles(); + nuGetConfigHelper.backupExistingRootNuGetFiles(); const dotnetPath = tl.which('dotnet', true); @@ -137,7 +137,7 @@ export async function run(): Promise { } finally { credCleanup(); - nuGetConfigHelper.restoreBackupNuGetFiles(); + nuGetConfigHelper.restoreBackupRootNuGetFiles(); } tl.setResult(tl.TaskResult.Succeeded, tl.loc('PackagesInstalledSuccessfully')); From 55289c1a2995163e83cbd24f57d6eea85273ae8a Mon Sep 17 00:00:00 2001 From: Daniel Khodabakhsh Date: Fri, 7 Jun 2019 14:04:27 -0700 Subject: [PATCH 6/8] Resolve relative this.nugetConfigPath. --- Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts b/Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts index 7f3d6e876794..44e828e5f1df 100644 --- a/Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts +++ b/Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts @@ -212,6 +212,6 @@ export class NuGetConfigHelper2 { return `tempRename_${tl.getVariable('build.buildId')}_${nugetFile}`; } private shouldWriteRootNuGetFiles(): boolean { - return this.nugetConfigPath.toLocaleLowerCase() == nugetFileName || this.rootNuGetFiles.length == 0; + return path.relative('.', this.nugetConfigPath).toLocaleLowerCase() == nugetFileName || this.rootNuGetFiles.length == 0; } } From d632702e9736907d34ead5fe5057e4fc36f94e76 Mon Sep 17 00:00:00 2001 From: Daniel Khodabakhsh Date: Fri, 7 Jun 2019 14:30:17 -0700 Subject: [PATCH 7/8] Bump versions. --- Tasks/NuGetPublisherV0/task.json | 2 +- Tasks/NuGetPublisherV0/task.loc.json | 2 +- Tasks/NuGetToolInstallerV0/task.json | 2 +- Tasks/NuGetToolInstallerV0/task.loc.json | 2 +- Tasks/NuGetToolInstallerV1/task.json | 2 +- Tasks/NuGetToolInstallerV1/task.loc.json | 2 +- Tasks/UseDotNetV2/task.json | 2 +- Tasks/UseDotNetV2/task.loc.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Tasks/NuGetPublisherV0/task.json b/Tasks/NuGetPublisherV0/task.json index 2841a09d9ea1..1cb925280fd3 100644 --- a/Tasks/NuGetPublisherV0/task.json +++ b/Tasks/NuGetPublisherV0/task.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/NuGetPublisherV0/task.loc.json b/Tasks/NuGetPublisherV0/task.loc.json index 819b33a606de..37516b279052 100644 --- a/Tasks/NuGetPublisherV0/task.loc.json +++ b/Tasks/NuGetPublisherV0/task.loc.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", diff --git a/Tasks/NuGetToolInstallerV0/task.json b/Tasks/NuGetToolInstallerV0/task.json index f5f86ebecdfb..8dd1a02a8f8c 100644 --- a/Tasks/NuGetToolInstallerV0/task.json +++ b/Tasks/NuGetToolInstallerV0/task.json @@ -15,7 +15,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "preview": false, "satisfies": [ diff --git a/Tasks/NuGetToolInstallerV0/task.loc.json b/Tasks/NuGetToolInstallerV0/task.loc.json index e79cf8084ff6..8b195cb5dbd8 100644 --- a/Tasks/NuGetToolInstallerV0/task.loc.json +++ b/Tasks/NuGetToolInstallerV0/task.loc.json @@ -15,7 +15,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "preview": false, "satisfies": [ diff --git a/Tasks/NuGetToolInstallerV1/task.json b/Tasks/NuGetToolInstallerV1/task.json index 94f5e947ee01..c4aaec792fe4 100644 --- a/Tasks/NuGetToolInstallerV1/task.json +++ b/Tasks/NuGetToolInstallerV1/task.json @@ -15,7 +15,7 @@ "version": { "Major": 1, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "preview": false, "satisfies": [ diff --git a/Tasks/NuGetToolInstallerV1/task.loc.json b/Tasks/NuGetToolInstallerV1/task.loc.json index 6b7f3b385d0c..78ca00ba5077 100644 --- a/Tasks/NuGetToolInstallerV1/task.loc.json +++ b/Tasks/NuGetToolInstallerV1/task.loc.json @@ -15,7 +15,7 @@ "version": { "Major": 1, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "preview": false, "satisfies": [ diff --git a/Tasks/UseDotNetV2/task.json b/Tasks/UseDotNetV2/task.json index f7ab53b2fcc0..f9824b8d6ac1 100644 --- a/Tasks/UseDotNetV2/task.json +++ b/Tasks/UseDotNetV2/task.json @@ -15,7 +15,7 @@ "version": { "Major": 2, "Minor": 0, - "Patch": 6 + "Patch": 7 }, "satisfies": [ "DotNetCore" diff --git a/Tasks/UseDotNetV2/task.loc.json b/Tasks/UseDotNetV2/task.loc.json index f3c502659e7e..1e339587b914 100644 --- a/Tasks/UseDotNetV2/task.loc.json +++ b/Tasks/UseDotNetV2/task.loc.json @@ -15,7 +15,7 @@ "version": { "Major": 2, "Minor": 0, - "Patch": 6 + "Patch": 7 }, "satisfies": [ "DotNetCore" From bb84b5464ee42cff6013d37a0f18217f2d08171d Mon Sep 17 00:00:00 2001 From: Daniel Khodabakhsh Date: Tue, 11 Jun 2019 10:49:09 -0700 Subject: [PATCH 8/8] Bump versions. --- Tasks/NpmAuthenticateV0/task.json | 4 ++-- Tasks/NpmAuthenticateV0/task.loc.json | 4 ++-- Tasks/UseDotNetV2/task.json | 4 ++-- Tasks/UseDotNetV2/task.loc.json | 4 ++-- Tasks/UseNodeV1/task.json | 4 ++-- Tasks/UseNodeV1/task.loc.json | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Tasks/NpmAuthenticateV0/task.json b/Tasks/NpmAuthenticateV0/task.json index 01fdc0134672..aacbf50008d0 100644 --- a/Tasks/NpmAuthenticateV0/task.json +++ b/Tasks/NpmAuthenticateV0/task.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 154, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", @@ -66,4 +66,4 @@ "argumentFormat": "" } } -} +} \ No newline at end of file diff --git a/Tasks/NpmAuthenticateV0/task.loc.json b/Tasks/NpmAuthenticateV0/task.loc.json index 1bd98f8a4741..6afbf0531777 100644 --- a/Tasks/NpmAuthenticateV0/task.loc.json +++ b/Tasks/NpmAuthenticateV0/task.loc.json @@ -10,7 +10,7 @@ "version": { "Major": 0, "Minor": 153, - "Patch": 1 + "Patch": 2 }, "runsOn": [ "Agent", @@ -66,4 +66,4 @@ "argumentFormat": "" } } -} +} \ No newline at end of file diff --git a/Tasks/UseDotNetV2/task.json b/Tasks/UseDotNetV2/task.json index 5f2671f3aa3e..94f5c1ea4e44 100644 --- a/Tasks/UseDotNetV2/task.json +++ b/Tasks/UseDotNetV2/task.json @@ -15,7 +15,7 @@ "version": { "Major": 2, "Minor": 0, - "Patch": 7 + "Patch": 8 }, "satisfies": [ "DotNetCore" @@ -153,4 +153,4 @@ "FailureWhileInstallingNuGetVersion": "Failed while installing NuGet version. Error: %s", "SettingUpNugetProxySettings": "Setting up proxy configuration for NuGet." } -} +} \ No newline at end of file diff --git a/Tasks/UseDotNetV2/task.loc.json b/Tasks/UseDotNetV2/task.loc.json index 75801108a187..f605d44bad5e 100644 --- a/Tasks/UseDotNetV2/task.loc.json +++ b/Tasks/UseDotNetV2/task.loc.json @@ -15,7 +15,7 @@ "version": { "Major": 2, "Minor": 0, - "Patch": 7 + "Patch": 8 }, "satisfies": [ "DotNetCore" @@ -153,4 +153,4 @@ "FailureWhileInstallingNuGetVersion": "ms-resource:loc.messages.FailureWhileInstallingNuGetVersion", "SettingUpNugetProxySettings": "ms-resource:loc.messages.SettingUpNugetProxySettings" } -} +} \ No newline at end of file diff --git a/Tasks/UseNodeV1/task.json b/Tasks/UseNodeV1/task.json index 7d1df77e1cad..4261aafbef91 100644 --- a/Tasks/UseNodeV1/task.json +++ b/Tasks/UseNodeV1/task.json @@ -17,7 +17,7 @@ "version": { "Major": 1, "Minor": 154, - "Patch": 0 + "Patch": 1 }, "satisfies": [ "Node", @@ -52,4 +52,4 @@ "messages": { "ToolFailed": "Node install failed: %s" } -} +} \ No newline at end of file diff --git a/Tasks/UseNodeV1/task.loc.json b/Tasks/UseNodeV1/task.loc.json index 8a6eda6b29e2..12ceaf114135 100644 --- a/Tasks/UseNodeV1/task.loc.json +++ b/Tasks/UseNodeV1/task.loc.json @@ -17,7 +17,7 @@ "version": { "Major": 1, "Minor": 154, - "Patch": 0 + "Patch": 1 }, "satisfies": [ "Node", @@ -52,4 +52,4 @@ "messages": { "ToolFailed": "ms-resource:loc.messages.ToolFailed" } -} +} \ No newline at end of file