Skip to content

Commit f51367f

Browse files
All-in-one NuGet task PR feedback
1 parent dafc900 commit f51367f

33 files changed

+186
-149
lines changed

Tasks/NuGetCommand/Common/INuGetCommandOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {NuGetEnvironmentSettings} from "./NuGetToolRunner";
1+
import { NuGetEnvironmentSettings } from "./NuGetToolRunner";
22

33
export interface INuGetCommandOptions {
44
/** settings used to initialize the environment NuGet.exe is invoked in */

Tasks/NuGetCommand/Common/NuGetConfigHelper.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,24 @@ export class NuGetConfigHelper {
3030

3131
public ensureTempConfigCreated() {
3232
// save nuget config file to agent build directory
33-
console.log("save nuget.config to temp config file");
34-
if (!(fs.existsSync(this.tempNugetConfigDir))) {
35-
fs.mkdirSync(this.tempNugetConfigDir);
33+
console.log(tl.loc("Info_SavingTempConfig"));
34+
35+
if (!tl.exist(this.tempNugetConfigDir)) {
36+
tl.mkdirP(this.tempNugetConfigDir);
3637
}
3738

3839
this.tempNugetConfigPath = path.join(this.tempNugetConfigDir, this.tempNugetConfigFileName);
3940

40-
if (!fs.existsSync(this.tempNugetConfigPath))
41+
if (!tl.exist(this.tempNugetConfigPath))
4142
{
4243
if (this.nugetConfigPath) {
4344
// don't use cp as that copies the read-only flag, and tfvc sets that on files
4445
let content = fs.readFileSync(this.nugetConfigPath);
45-
fs.writeFileSync(this.tempNugetConfigPath, content);
46+
tl.writeFile(this.tempNugetConfigPath, content);
4647
}
4748
else {
4849
// small file, use writeFileSync
49-
fs.writeFileSync(this.tempNugetConfigPath, "<configuration/>");
50+
tl.writeFile(this.tempNugetConfigPath, "<configuration/>");
5051
}
5152
}
5253
}

Tasks/NuGetCommand/Common/NuGetToolRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export async function getNuGetQuirksAsync(nuGetExePath: string): Promise<NuGetQu
143143
// when using the credential provider.
144144
// Unfortunately, on on-premises TFS, we must use credential provider to override NTLM auth with the build
145145
// identity's token.
146-
// Therefore, we are enabling credential provider on on-premises and disabling it on hosted. We allow for test
146+
// Therefore, we are enabling credential provider on on-premises and disabling it on hosted (only when the version of NuGet does not support it). We allow for test
147147
// instances by an override variable.
148148

149149
export function isCredentialProviderEnabled(quirks: NuGetQuirks): boolean {

Tasks/NuGetCommand/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"loc.instanceNameFormat": "NuGet $(command)",
66
"loc.group.displayName.restoreAuth": "Feeds and authentication",
77
"loc.group.displayName.restoreAdvanced": "Advanced",
8-
"loc.group.displayName.pushAuth": "Destination feed and authentication",
98
"loc.group.displayName.pushAdvanced": "Advanced",
109
"loc.group.displayName.packOptions": "Pack options",
1110
"loc.group.displayName.packAdvanced": "Advanced",
@@ -14,9 +13,9 @@
1413
"loc.input.label.solution": "Path to solution, packages.config, or project.json",
1514
"loc.input.help.solution": "The path to the solution, packages.config, or project.json file that references the packages to be restored.",
1615
"loc.input.label.selectOrConfig": "Feeds to use",
17-
"loc.input.help.selectOrConfig": "You can either select feeds from VSTS and/or NuGet.org here, or commit a nuget.config file to your source code repository and set its path here.",
16+
"loc.input.help.selectOrConfig": "You can either select a feed from VSTS and/or NuGet.org here, or commit a nuget.config file to your source code repository and set its path here.",
1817
"loc.input.label.feedRestore": "Use packages from this VSTS/TFS feed",
19-
"loc.input.help.feedRestore": "Include the selected feeds in the generated NuGet.config. You must have Package Management installed and licensed to select a feed here.",
18+
"loc.input.help.feedRestore": "Include the selected feed in the generated NuGet.config. You must have Package Management installed and licensed to select a feed here.",
2019
"loc.input.label.includeNuGetOrg": "Use packages from NuGet.org",
2120
"loc.input.help.includeNuGetOrg": "Include NuGet.org in the generated NuGet.config.",
2221
"loc.input.label.nugetConfigPath": "Path to NuGet.config",
@@ -47,7 +46,7 @@
4746
"loc.input.label.outputDir": "Package Folder",
4847
"loc.input.help.outputDir": "Folder where packages will be created. If empty, packages will be created alongside the csproj or nuspec file.",
4948
"loc.input.label.versioningScheme": "Automatic package versioning",
50-
"loc.input.help.versioningScheme": "Cannot be used with include referenced projects. If you choose 'Use the date and time', this will generate a [SemVer](http://semver.org/spec/v1.0.0.html)-compliant version formatted as `X.Y.Z-ci-datetime` where you choose X, Y, and Z.\n\nIf you choose 'Use an environment variable', you must select an environment variable and ensure it contains the version number you want to use.\n\nIf you choose 'Use the build number', this will use the build number to version you package. **Note:** Under General set the build format to be '[$(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)](https://go.microsoft.com/fwlink/?LinkID=627416)'.",
49+
"loc.input.help.versioningScheme": "Cannot be used with include referenced projects. If you choose 'Use the date and time', this will generate a [SemVer](http://semver.org/spec/v1.0.0.html)-compliant version formatted as `X.Y.Z-ci-datetime` where you choose X, Y, and Z.\n\nIf you choose 'Use an environment variable', you must select an environment variable and ensure it contains the version number you want to use.\n\nIf you choose 'Use the build number', this will use the build number to version your package. **Note:** Under Options set the build number format to be '[$(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)](https://go.microsoft.com/fwlink/?LinkID=627416)'.",
5150
"loc.input.label.includeReferencedProjects": "Include referenced projects",
5251
"loc.input.help.includeReferencedProjects": "Include referenced projects either as dependencies or as part of the package. Cannot be used with automatic package versioning. If a referenced project has a corresponding nuspec file that has the same name as the project, then that referenced project is added as a dependency. Otherwise, the referenced project is added as part of the package. [Learn more](https://docs.nuget.org/consume/command-line-reference#pack-command) at NuGet.org.",
5352
"loc.input.label.versionEnvVar": "Environment variable",
@@ -59,7 +58,7 @@
5958
"loc.input.label.requestedPatchVersion": "Patch",
6059
"loc.input.help.requestedPatchVersion": "The 'Z' in version [X.Y.Z](http://semver.org/spec/v1.0.0.html)",
6160
"loc.input.label.buildProperties": "Additional build properties",
62-
"loc.input.help.buildProperties": "Semicolon delimited list of properties used to build the package.",
61+
"loc.input.help.buildProperties": "Specifies a list of token=value pairs, separated by semicolons, where each occurrence of $token$ in the .nuspec file will be replaced with the given value. Values can be strings in quotation marks.",
6362
"loc.input.label.verbosityPack": "Verbosity",
6463
"loc.input.help.verbosityPack": "Specifies the amount of detail displayed in the output.",
6564
"loc.input.label.arguments": "Command and arguments",
@@ -114,5 +113,7 @@
114113
"loc.messages.Warning_ForceNuGetCannotSkipConflicts": "NuGet.exe was forced to be used for publish, if push conflicts occur it will result in a failure.",
115114
"loc.messages.Info_MatchingUrlWasFoundSettingAuth": "Using authentication information for the following URI: ",
116115
"loc.messages.Error_PushNotARegularFile": "%s is not a file. Check the 'Path/Pattern to nupkg' property of the task.",
117-
"loc.messages.Warning_AllowDuplicatesOnlyAvailableHosted": "The 'Allow duplicates to be skipped' option is currently only available on Visual Studio Team Services. If NuGet.exe encounters a conflict, the task will fail."
116+
"loc.messages.Warning_AllowDuplicatesOnlyAvailableHosted": "The 'Allow duplicates to be skipped' option is currently only available on Visual Studio Team Services. If NuGet.exe encounters a conflict, the task will fail.",
117+
"loc.messages.Info_SavingTempConfig": "Saving NuGet.config to a temporary config file.",
118+
"loc.messages.Error_CommandNotRecognized": "The command %s was not recognized."
118119
}

Tasks/NuGetCommand/Tests/L0.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as path from 'path';
22
import * as assert from 'assert';
33
import * as ttm from 'vsts-task-lib/mock-test';
44

5-
describe('NuGetRestore Suite', function () {
5+
describe('NuGetCommand Suite', function () {
66
before(() => {
77
});
88

@@ -240,7 +240,7 @@ describe('NuGetRestore Suite', function () {
240240

241241
tr.run()
242242
assert(tr.invokedToolCount == 1, 'should have run NuGet once');
243-
assert(tr.ran('c:\\from\\tool\\installer\\nuget.exe pack c:\\agent\\home\\directory\\foo.nuspec -NonInteractive -OutputDirectory C:\\out\\dir -version x.y.z-CI-YYYYMMDD-HHMMSS'), 'it should have run NuGet');
243+
assert(tr.ran('c:\\from\\tool\\installer\\nuget.exe pack c:\\agent\\home\\directory\\foo.nuspec -NonInteractive -OutputDirectory c:\\agent\\home\\directory -Properties -version x.y.z-CI-YYYYMMDD-HHMMSS'), 'it should have run NuGet');
244244
assert(tr.stdOutContained('setting console code page'), 'it should have run chcp');
245245
assert(tr.stdOutContained('NuGet output here'), "should have nuget output");
246246
assert(tr.succeeded, 'should have succeeded');
@@ -256,7 +256,7 @@ describe('NuGetRestore Suite', function () {
256256

257257
tr.run()
258258
assert(tr.invokedToolCount == 1, 'should have run NuGet once');
259-
assert(tr.ran('c:\\from\\tool\\installer\\nuget.exe pack c:\\agent\\home\\directory\\foo.nuspec -NonInteractive -OutputDirectory C:\\out\\dir -version XX.YY.ZZ'), 'it should have run NuGet');
259+
assert(tr.ran('c:\\from\\tool\\installer\\nuget.exe pack c:\\agent\\home\\directory\\foo.nuspec -NonInteractive -OutputDirectory c:\\agent\\home\\directory -Properties -version XX.YY.ZZ'), 'it should have run NuGet');
260260
assert(tr.stdOutContained('setting console code page'), 'it should have run chcp');
261261
assert(tr.stdOutContained('NuGet output here'), "should have nuget output");
262262
assert(tr.succeeded, 'should have succeeded');
@@ -272,7 +272,7 @@ describe('NuGetRestore Suite', function () {
272272

273273
tr.run()
274274
assert(tr.invokedToolCount == 1, 'should have run NuGet once');
275-
assert(tr.ran('c:\\from\\tool\\installer\\nuget.exe pack c:\\agent\\home\\directory\\foo.nuspec -NonInteractive -OutputDirectory C:\\out\\dir -version 1.2.3'), 'it should have run NuGet');
275+
assert(tr.ran('c:\\from\\tool\\installer\\nuget.exe pack c:\\agent\\home\\directory\\foo.nuspec -NonInteractive -OutputDirectory c:\\agent\\home\\directory -Properties -version 1.2.3'), 'it should have run NuGet');
276276
assert(tr.stdOutContained('setting console code page'), 'it should have run chcp');
277277
assert(tr.stdOutContained('NuGet output here'), "should have nuget output");
278278
assert(tr.succeeded, 'should have succeeded');

Tasks/NuGetCommand/Tests/PackTests/packBuildNumber.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
2121
},
2222
"which": {},
2323
"exec": {
24-
"c:\\from\\tool\\installer\\nuget.exe pack c:\\agent\\home\\directory\\foo.nuspec -NonInteractive -OutputDirectory C:\\out\\dir -version 1.2.3": {
24+
"c:\\from\\tool\\installer\\nuget.exe pack c:\\agent\\home\\directory\\foo.nuspec -NonInteractive -OutputDirectory c:\\agent\\home\\directory -Properties -version 1.2.3": {
2525
"code": 0,
2626
"stdout": "NuGet output here",
2727
"stderr": ""
@@ -34,6 +34,9 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
3434
"c:\\agent\\home\\directory\\foo.nuspec": {
3535
"isFile": true
3636
}
37+
},
38+
"findMatch": {
39+
"foo.nuspec" : ["c:\\agent\\home\\directory\\foo.nuspec"]
3740
}
3841
};
3942
nmh.setAnswers(a);

Tasks/NuGetCommand/Tests/PackTests/packEnvVar.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
2222
},
2323
"which": {},
2424
"exec": {
25-
"c:\\from\\tool\\installer\\nuget.exe pack c:\\agent\\home\\directory\\foo.nuspec -NonInteractive -OutputDirectory C:\\out\\dir -version XX.YY.ZZ": {
25+
"c:\\from\\tool\\installer\\nuget.exe pack c:\\agent\\home\\directory\\foo.nuspec -NonInteractive -OutputDirectory c:\\agent\\home\\directory -Properties -version XX.YY.ZZ": {
2626
"code": 0,
2727
"stdout": "NuGet output here",
2828
"stderr": ""
@@ -35,6 +35,9 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
3535
"c:\\agent\\home\\directory\\foo.nuspec": {
3636
"isFile": true
3737
}
38+
},
39+
"findMatch": {
40+
"foo.nuspec" : ["c:\\agent\\home\\directory\\foo.nuspec"]
3841
}
3942
};
4043
nmh.setAnswers(a);

Tasks/NuGetCommand/Tests/PackTests/packPrerelease.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
2424
},
2525
"which": {},
2626
"exec": {
27-
"c:\\from\\tool\\installer\\nuget.exe pack c:\\agent\\home\\directory\\foo.nuspec -NonInteractive -OutputDirectory C:\\out\\dir -version x.y.z-CI-YYYYMMDD-HHMMSS": {
27+
"c:\\from\\tool\\installer\\nuget.exe pack c:\\agent\\home\\directory\\foo.nuspec -NonInteractive -OutputDirectory c:\\agent\\home\\directory -Properties -version x.y.z-CI-YYYYMMDD-HHMMSS": {
2828
"code": 0,
2929
"stdout": "NuGet output here",
3030
"stderr": ""
@@ -37,6 +37,9 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
3737
"c:\\agent\\home\\directory\\foo.nuspec": {
3838
"isFile": true
3939
}
40+
},
41+
"findMatch": {
42+
"foo.nuspec" : ["c:\\agent\\home\\directory\\foo.nuspec"]
4043
}
4144
};
4245
nmh.setAnswers(a);

Tasks/NuGetCommand/Tests/PublishTests/externalFeedNuGet.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let nmh: util.NugetMockHelper = new util.NugetMockHelper(tmr);
99

1010
nmh.setNugetVersionInputDefault();
1111
tmr.setInput('command', 'push');
12-
tmr.setInput('searchPattern', 'foo.nupkg');
12+
tmr.setInput('searchPatternPush', 'foo.nupkg');
1313
tmr.setInput('nuGetFeedType', 'external');
1414
tmr.setInput('connectedServiceName', 'externalNuGetFeed');
1515

@@ -31,6 +31,9 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
3131
"c:\\agent\\home\\directory\\foo.nupkg": {
3232
"isFile": true
3333
}
34+
},
35+
"findMatch": {
36+
"foo.nupkg" : ["c:\\agent\\home\\directory\\foo.nupkg"]
3437
}
3538
};
3639
nmh.setAnswers(a);
@@ -41,6 +44,5 @@ nmh.registerDefaultNugetVersionMock();
4144
nmh.registerToolRunnerMock();
4245
nmh.registerNugetConfigMock();
4346
nmh.RegisterLocationServiceMocks();
44-
//nmh.registerCommonUtilities();
4547

4648
tmr.run();

Tasks/NuGetCommand/Tests/PublishTests/internalFeedNuGet.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let nmh: util.NugetMockHelper = new util.NugetMockHelper(tmr);
99

1010
nmh.setNugetVersionInputDefault();
1111
tmr.setInput('command', 'push');
12-
tmr.setInput('searchPattern', 'foo.nupkg');
12+
tmr.setInput('searchPatternPush', 'foo.nupkg');
1313
tmr.setInput('nuGetFeedType', 'internal');
1414
tmr.setInput('feedPublish', 'FeedFooId');
1515
tmr.setInput('allowPackageConflicts', 'false');
@@ -32,6 +32,9 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
3232
"c:\\agent\\home\\directory\\foo.nupkg": {
3333
"isFile": true
3434
}
35+
},
36+
"findMatch": {
37+
"foo.nupkg" : ["c:\\agent\\home\\directory\\foo.nupkg"]
3538
}
3639
};
3740
nmh.setAnswers(a);

0 commit comments

Comments
 (0)