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

Strip quotes from nuget.exe path #2289

Merged
merged 1 commit into from
Aug 22, 2016
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
8 changes: 7 additions & 1 deletion Tasks/Common/nuget-task-common/NuGetToolRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import * as os from 'os';
import * as path from 'path';
import * as url from 'url';

import * as ngutil from "./Utility";

interface EnvironmentDictionary { [key: string]: string }

export interface NuGetEnvironmentSettings {
Expand Down Expand Up @@ -139,7 +141,11 @@ function locateTool(tool: string, opts?: LocateOptions) {

export function locateNuGetExe(userNuGetExePath: string): string {
if (userNuGetExePath) {
tl.debug(`using user-supplied NuGet path ${userNuGetExePath}`)
if (os.platform() === "win32") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is likely fine in your case. We discussed for lib and the reason we didn't do it there is double quote is valid in OSX and Linux in a dir name. So we can't blindly do it in a base lib.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, this is literally just to resolve that one break and even then only on windows.

userNuGetExePath = ngutil.stripLeadingAndTrailingQuotes(userNuGetExePath);
}

tl.debug(`using user-supplied NuGet path ${userNuGetExePath}`);
tl.checkPath(userNuGetExePath, 'NuGet');
return userNuGetExePath;
}
Expand Down
21 changes: 20 additions & 1 deletion Tasks/Common/nuget-task-common/Utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,23 @@ export function resolveWildcardPath(pattern: string, allowEmptyWildcardMatch?: b
{
return filesList.map(file => file.split("/").join("\\"));
}
}
}

export function stripLeadingAndTrailingQuotes(path: string): string {
if (path.length == 0) {
return path;
}

let left = 0;
if (path.charAt(left) == '"') {
++left;
}

let right = path.length - 1;
if (path.charAt(right) == '"') {
--right;
}

// substring returns a value *not* including the character at right
return path.substring(left, right + 1);
}
2 changes: 1 addition & 1 deletion Tasks/Common/nuget-task-common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"target": "es6",
"noImplicitAny": false,
"sourceMap": false
},
Expand Down
4 changes: 3 additions & 1 deletion Tasks/NuGetInstaller/nugetinstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ if (!tl.filePathSupplied('nugetConfigPath')) {
nugetConfigPath = null;
}

var userNuGetPath = tl.getPathInput('nuGetPath', false, true);
// due to a bug where we accidentally allowed nuGetPath to be surrounded by quotes before,
// locateNuGetExe() will strip them and check for existence there.
var userNuGetPath = tl.getPathInput('nuGetPath', false, false);
if (!tl.filePathSupplied('nuGetPath')) {
userNuGetPath = null;
}
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NuGetInstaller/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 7
"Patch": 10
},
"minimumAgentVersion": "1.83.0",
"groups": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NuGetInstaller/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 7
"Patch": 10
},
"minimumAgentVersion": "1.83.0",
"groups": [
Expand Down
4 changes: 3 additions & 1 deletion Tasks/NugetPublisher/nugetpublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ if (!normalizedNuGetFeedType) {

nuGetFeedType = normalizedNuGetFeedType;

var userNuGetPath = tl.getPathInput('nuGetPath', false, true);
// due to a bug where we accidentally allowed nuGetPath to be surrounded by quotes before,
// locateNuGetExe() will strip them and check for existence there.
var userNuGetPath = tl.getPathInput('nuGetPath', false, false);
if (!tl.filePathSupplied('nuGetPath')) {
userNuGetPath = null;
}
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NugetPublisher/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 9
"Patch": 10
},
"demands": [
"Cmd"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NugetPublisher/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 9
"Patch": 10
},
"demands": [
"Cmd"
Expand Down
1 change: 1 addition & 0 deletions definitions/nuget-task-common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,6 @@ declare module 'nuget-task-common/Utility' {
/// <reference path="../../../definitions/Q.d.ts" />
export function resolveFilterSpec(filterSpec: string, basePath?: string, allowEmptyMatch?: boolean): string[];
export function resolveWildcardPath(pattern: string, allowEmptyWildcardMatch?: boolean): string[];
export function stripLeadingAndTrailingQuotes(path: string): string;

}