Skip to content

Commit

Permalink
Merge branch 'daveMueller-GH2459_ExtendingNuGetRestoreSettings' into …
Browse files Browse the repository at this point in the history
…develop

* daveMueller-GH2459_ExtendingNuGetRestoreSettings:
  Rename to MSBuildPath
  Extended NuGetRestoreSettings and added Tests
  • Loading branch information
devlead committed Feb 20, 2019
2 parents 9f3a653 + b188a5e commit 9719d60
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,20 @@ public void Should_Add_MSBuildVersion_To_Arguments_If_Set(NuGetMSBuildVersion ms
// Then
Assert.Equal(expected, result.Args);
}

[Fact]
public void Should_Add_MSBuildPath_To_Arguments_If_Set()
{
// Given
var fixture = new NuGetRestorerFixture();
fixture.Settings.MSBuildPath = "MSBuild/15.0/Bin";

// When
var result = fixture.Run();

// Then
Assert.Equal("restore \"/Working/project.sln\" -MSBuildPath \"/Working/MSBuild/15.0/Bin\" -NonInteractive", result.Args);
}
}
}
}
7 changes: 7 additions & 0 deletions src/Cake.Common/Tools/NuGet/Restore/NuGetRestorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ private ProcessArgumentBuilder GetArguments(FilePath targetFilePath, NuGetRestor
builder.Append(settings.MSBuildVersion.Value.GetNuGetMSBuildVersionString());
}

// MSBuildPath
if (settings.MSBuildPath != null)
{
builder.Append("-MSBuildPath");
builder.AppendQuoted(settings.MSBuildPath.MakeAbsolute(_environment).FullPath);
}

// NonInteractive?
if (settings.NonInteractive)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Cake.Common/Tools/NuGet/Restore/NugetRestoreSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public sealed class NuGetRestoreSettings : ToolSettings
/// <value>The version of MSBuild to be used with this command.</value>
public NuGetMSBuildVersion? MSBuildVersion { get; set; }

/// <summary>
/// Gets or sets the path of MSBuild to use.
/// This setting takes precedence over <c>-MSBuildVersion</c> and requires NuGet V4 or later.
/// </summary>
public DirectoryPath MSBuildPath { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not NuGet suppresses prompts for user input or confirmations.
/// </summary>
Expand Down

0 comments on commit 9719d60

Please sign in to comment.