2017-03-03 05:04:03 +00:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using Microsoft.DotNet.Tools.Restore;
|
2017-02-22 18:43:05 +00:00
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Xunit;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|
|
|
|
{
|
|
|
|
|
public class GivenDotnetRestoreInvocation
|
|
|
|
|
{
|
2017-05-18 21:13:01 +00:00
|
|
|
|
private const string ExpectedPrefix =
|
2018-04-02 22:14:32 +00:00
|
|
|
|
"exec <msbuildpath> -maxcpucount -verbosity:m -nologo -target:Restore";
|
2017-05-18 21:13:01 +00:00
|
|
|
|
|
2017-02-22 18:43:05 +00:00
|
|
|
|
[Theory]
|
2017-02-22 19:43:03 +00:00
|
|
|
|
[InlineData(new string[] { }, "")]
|
2018-04-26 17:53:54 +00:00
|
|
|
|
[InlineData(new string[] { "-s", "<source>" }, @"-property:RestoreSources=\""<source>\""")]
|
|
|
|
|
[InlineData(new string[] { "--source", "<source>" }, @"-property:RestoreSources=\""<source>\""")]
|
|
|
|
|
[InlineData(new string[] { "-s", "<source0>", "-s", "<source1>" }, @"-property:RestoreSources=\""<source0>%3B<source1>\""")]
|
|
|
|
|
[InlineData(new string[] { "-r", "<runtime>" }, @"-property:RuntimeIdentifiers=\""<runtime>\""")]
|
|
|
|
|
[InlineData(new string[] { "--runtime", "<runtime>" }, @"-property:RuntimeIdentifiers=\""<runtime>\""")]
|
|
|
|
|
[InlineData(new string[] { "-r", "<runtime0>", "-r", "<runtime1>" }, @"-property:RuntimeIdentifiers=\""<runtime0>%3B<runtime1>\""")]
|
|
|
|
|
[InlineData(new string[] { "--packages", "<packages>" }, @"-property:RestorePackagesPath=\""<packages>\""")]
|
|
|
|
|
[InlineData(new string[] { "--disable-parallel" }, @"-property:RestoreDisableParallel=\""true\""")]
|
|
|
|
|
[InlineData(new string[] { "--configfile", "<config>" }, @"-property:RestoreConfigFile=\""<config>\""")]
|
|
|
|
|
[InlineData(new string[] { "--no-cache" }, @"-property:RestoreNoCache=\""true\""")]
|
|
|
|
|
[InlineData(new string[] { "--ignore-failed-sources" }, @"-property:RestoreIgnoreFailedSources=\""true\""")]
|
|
|
|
|
[InlineData(new string[] { "--no-dependencies" }, @"-property:RestoreRecursive=\""false\""")]
|
2018-04-02 21:44:43 +00:00
|
|
|
|
[InlineData(new string[] { "-v", "minimal" }, @"-verbosity:minimal")]
|
|
|
|
|
[InlineData(new string[] { "--verbosity", "minimal" }, @"-verbosity:minimal")]
|
2017-10-24 22:04:24 +00:00
|
|
|
|
public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs)
|
2017-02-22 18:43:05 +00:00
|
|
|
|
{
|
2017-02-22 19:43:03 +00:00
|
|
|
|
expectedAdditionalArgs = (string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}");
|
|
|
|
|
|
2017-02-22 18:43:05 +00:00
|
|
|
|
var msbuildPath = "<msbuildpath>";
|
2017-02-22 19:43:03 +00:00
|
|
|
|
RestoreCommand.FromArgs(args, msbuildPath)
|
2017-05-18 21:13:01 +00:00
|
|
|
|
.GetProcessStartInfo().Arguments
|
|
|
|
|
.Should().Be($"{ExpectedPrefix}{expectedAdditionalArgs}");
|
2017-02-22 18:43:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|