Skip to content

Commit 6ac1aab

Browse files
grendellojonpryor
authored andcommitted
[xaprepare] Use NuGet binary we download (#3308)
`NuGetRunner` doesn't properly specify full path to the nuget binary we download as part of the prepare run and, thus, it depends on any random version of the utility in the user's `$PATH` (if at all) which may lead to random errors depending on the nuget version. Fix the issue by passing the full path to the downloaded binary. Additionally, fix `ToolRunner` to properly add arguments when managed runtime (`mono`) is used on Unix. Until now any initial arguments were passed to **mono** in such cases, instead of to the managed executable. Doh.
1 parent db61ce4 commit 6ac1aab

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

build-tools/xaprepare/xaprepare/Application/ProcessRunner.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,22 @@ public ProcessRunner (string command, bool ignoreEmptyArguments, params string[]
8787
throw new ArgumentException ("must not be null or empty", nameof (command));
8888

8989
this.command = command;
90+
AddArgumentsInternal (ignoreEmptyArguments, arguments);
91+
}
92+
93+
public ProcessRunner AddArguments (params string[] arguments)
94+
{
95+
return AddArguments (true, arguments);
96+
}
97+
98+
public ProcessRunner AddArguments (bool ignoreEmptyArguments, params string[] arguments)
99+
{
100+
AddArgumentsInternal (ignoreEmptyArguments, arguments);
101+
return this;
102+
}
103+
104+
void AddArgumentsInternal (bool ignoreEmptyArguments, params string[] arguments)
105+
{
90106
if (arguments == null)
91107
return;
92108

build-tools/xaprepare/xaprepare/ToolRunners/NuGetRunner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ partial class NuGetRunner : ToolRunner
1010
protected override string ToolName => "NuGet";
1111

1212
public NuGetRunner (Context context, Log log = null, string nugetPath = null)
13-
: base (context, log, nugetPath)
13+
: base (context, log, nugetPath ?? Configurables.Paths.LocalNugetPath)
1414
{}
1515

1616
public async Task<bool> Restore (string solutionFilePath)

build-tools/xaprepare/xaprepare/ToolRunners/ToolRunner.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected virtual ProcessRunner CreateProcessRunner (params string[] initialPara
8787
if (managedRunner != null)
8888
managedRunner = Context.OS.Which (managedRunner);
8989

90-
var runner = new ProcessRunner (managedRunner ?? FullToolPath, initialParams) {
90+
var runner = new ProcessRunner (managedRunner ?? FullToolPath) {
9191
ProcessTimeout = ProcessTimeout,
9292
EchoCmdAndArguments = EchoCmdAndArguments,
9393
EchoStandardError = EchoStandardError,
@@ -103,6 +103,7 @@ protected virtual ProcessRunner CreateProcessRunner (params string[] initialPara
103103
if (managedRunner != null)
104104
runner.AddQuotedArgument (FullToolPath);
105105

106+
runner.AddArguments (initialParams);
106107
return runner;
107108
}
108109

0 commit comments

Comments
 (0)