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.
|
|
|
|
|
|
2017-02-22 18:43:05 +00:00
|
|
|
|
using FluentAssertions;
|
2017-04-10 19:24:52 +00:00
|
|
|
|
using Microsoft.DotNet.Tools.Store;
|
2017-02-22 23:49:39 +00:00
|
|
|
|
using System.IO;
|
2017-04-10 19:24:52 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using Xunit;
|
2017-02-22 18:43:05 +00:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|
|
|
|
{
|
2017-04-07 19:15:38 +00:00
|
|
|
|
public class GivenDotnetStoreInvocation
|
2017-02-22 18:43:05 +00:00
|
|
|
|
{
|
2018-04-02 22:14:32 +00:00
|
|
|
|
const string ExpectedPrefix = "exec <msbuildpath> -maxcpucount -verbosity:m -target:ComposeStore <project>";
|
|
|
|
|
static readonly string[] ArgsPrefix = { "--manifest", "<project>" };
|
2017-02-22 23:49:39 +00:00
|
|
|
|
|
|
|
|
|
[Theory]
|
2017-04-07 19:15:38 +00:00
|
|
|
|
[InlineData("-m")]
|
|
|
|
|
[InlineData("--manifest")]
|
2017-02-22 23:49:39 +00:00
|
|
|
|
public void ItAddsProjectToMsbuildInvocation(string optionName)
|
|
|
|
|
{
|
|
|
|
|
var msbuildPath = "<msbuildpath>";
|
|
|
|
|
string[] args = new string[] { optionName, "<project>" };
|
2017-04-07 19:15:38 +00:00
|
|
|
|
StoreCommand.FromArgs(args, msbuildPath)
|
2017-02-22 23:49:39 +00:00
|
|
|
|
.GetProcessStartInfo().Arguments.Should().Be($"{ExpectedPrefix}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
2018-04-26 17:53:54 +00:00
|
|
|
|
[InlineData(new string[] { "-f", "<tfm>" }, @"-property:TargetFramework=\""<tfm>\""")]
|
|
|
|
|
[InlineData(new string[] { "--framework", "<tfm>" }, @"-property:TargetFramework=\""<tfm>\""")]
|
|
|
|
|
[InlineData(new string[] { "-r", "<rid>" }, @"-property:RuntimeIdentifier=\""<rid>\""")]
|
|
|
|
|
[InlineData(new string[] { "--runtime", "<rid>" }, @"-property:RuntimeIdentifier=\""<rid>\""")]
|
|
|
|
|
[InlineData(new string[] { "--manifest", "one.xml", "--manifest", "two.xml", "--manifest", "three.xml" }, @"-property:AdditionalProjects=\""one.xml%3Btwo.xml%3Bthree.xml\""")]
|
2017-02-22 23:49:39 +00:00
|
|
|
|
public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs)
|
2017-02-22 18:43:05 +00:00
|
|
|
|
{
|
2017-02-22 23:49:39 +00:00
|
|
|
|
args = ArgsPrefix.Concat(args).ToArray();
|
|
|
|
|
expectedAdditionalArgs = (string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}");
|
|
|
|
|
|
|
|
|
|
var msbuildPath = "<msbuildpath>";
|
2017-04-07 19:15:38 +00:00
|
|
|
|
StoreCommand.FromArgs(args, msbuildPath)
|
2017-02-22 23:49:39 +00:00
|
|
|
|
.GetProcessStartInfo().Arguments.Should().Be($"{ExpectedPrefix}{expectedAdditionalArgs}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData("-o")]
|
|
|
|
|
[InlineData("--output")]
|
|
|
|
|
public void ItAddsOutputPathToMsBuildInvocation(string optionName)
|
|
|
|
|
{
|
2017-03-17 06:15:45 +00:00
|
|
|
|
string path = "/some/path";
|
2017-02-22 23:49:39 +00:00
|
|
|
|
var args = ArgsPrefix.Concat(new string[] { optionName, path }).ToArray();
|
|
|
|
|
|
2017-02-22 18:43:05 +00:00
|
|
|
|
var msbuildPath = "<msbuildpath>";
|
2017-04-07 19:15:38 +00:00
|
|
|
|
StoreCommand.FromArgs(args, msbuildPath)
|
2018-04-26 17:53:54 +00:00
|
|
|
|
.GetProcessStartInfo().Arguments.Should().Be($"{ExpectedPrefix} -property:ComposeDir=\\\"{Path.GetFullPath(path)}\\\"");
|
2017-02-22 18:43:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|