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
|
|
|
|
{
|
2017-04-10 19:24:52 +00:00
|
|
|
|
const string ExpectedPrefix = "exec <msbuildpath> /m /v:m /t:ComposeStore <project>";
|
2017-04-07 19:15:38 +00:00
|
|
|
|
static readonly string[] ArgsPrefix = { "-m", "<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]
|
2017-03-10 01:20:00 +00:00
|
|
|
|
[InlineData(new string[] { "-f", "<tfm>" }, @"/p:TargetFramework=<tfm>")]
|
|
|
|
|
[InlineData(new string[] { "--framework", "<tfm>" }, @"/p:TargetFramework=<tfm>")]
|
|
|
|
|
[InlineData(new string[] { "-r", "<rid>" }, @"/p:RuntimeIdentifier=<rid>")]
|
|
|
|
|
[InlineData(new string[] { "--runtime", "<rid>" }, @"/p:RuntimeIdentifier=<rid>")]
|
2017-04-07 19:15:38 +00:00
|
|
|
|
[InlineData(new string[] { "--manifest", "one.xml", "--manifest", "two.xml", "--manifest", "three.xml" }, @"/p: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)
|
2017-02-22 23:49:39 +00:00
|
|
|
|
.GetProcessStartInfo().Arguments.Should().Be($"{ExpectedPrefix} /p:ComposeDir={Path.GetFullPath(path)}");
|
2017-02-22 18:43:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|