Skip to content

Commit

Permalink
[xaprepare] Use NuGet binary we download (#3308)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
grendello authored and jonpryor committed Jun 30, 2019
1 parent db61ce4 commit 6ac1aab
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
16 changes: 16 additions & 0 deletions build-tools/xaprepare/xaprepare/Application/ProcessRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ public ProcessRunner (string command, bool ignoreEmptyArguments, params string[]
throw new ArgumentException ("must not be null or empty", nameof (command));

this.command = command;
AddArgumentsInternal (ignoreEmptyArguments, arguments);
}

public ProcessRunner AddArguments (params string[] arguments)
{
return AddArguments (true, arguments);
}

public ProcessRunner AddArguments (bool ignoreEmptyArguments, params string[] arguments)
{
AddArgumentsInternal (ignoreEmptyArguments, arguments);
return this;
}

void AddArgumentsInternal (bool ignoreEmptyArguments, params string[] arguments)
{
if (arguments == null)
return;

Expand Down
2 changes: 1 addition & 1 deletion build-tools/xaprepare/xaprepare/ToolRunners/NuGetRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ partial class NuGetRunner : ToolRunner
protected override string ToolName => "NuGet";

public NuGetRunner (Context context, Log log = null, string nugetPath = null)
: base (context, log, nugetPath)
: base (context, log, nugetPath ?? Configurables.Paths.LocalNugetPath)
{}

public async Task<bool> Restore (string solutionFilePath)
Expand Down
3 changes: 2 additions & 1 deletion build-tools/xaprepare/xaprepare/ToolRunners/ToolRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected virtual ProcessRunner CreateProcessRunner (params string[] initialPara
if (managedRunner != null)
managedRunner = Context.OS.Which (managedRunner);

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

runner.AddArguments (initialParams);
return runner;
}

Expand Down

0 comments on commit 6ac1aab

Please sign in to comment.