using Microsoft.DotNet.Tools.Build; using FluentAssertions; using Xunit; namespace Microsoft.DotNet.Cli.MSBuild.Tests { public class GivenDotnetBuildInvocation { [Theory] [InlineData(new string[] { }, @"exec /m /v:m /t:Build /clp:Summary")] [InlineData(new string[] { "-o", "foo" }, @"exec /m /v:m /t:Build /p:OutputPath=foo /clp:Summary")] [InlineData(new string[] { "--output", "foo" }, @"exec /m /v:m /t:Build /p:OutputPath=foo /clp:Summary")] [InlineData(new string[] { "-o", "foo1 foo2" }, @"exec /m /v:m /t:Build ""/p:OutputPath=foo1 foo2"" /clp:Summary")] [InlineData(new string[] { "--no-incremental" }, @"exec /m /v:m /t:Rebuild /clp:Summary")] [InlineData(new string[] { "-f", "framework" }, @"exec /m /v:m /t:Build /p:TargetFramework=framework /clp:Summary")] [InlineData(new string[] { "--framework", "framework" }, @"exec /m /v:m /t:Build /p:TargetFramework=framework /clp:Summary")] [InlineData(new string[] { "-r", "runtime" }, @"exec /m /v:m /t:Build /p:RuntimeIdentifier=runtime /clp:Summary")] [InlineData(new string[] { "--runtime", "runtime" }, @"exec /m /v:m /t:Build /p:RuntimeIdentifier=runtime /clp:Summary")] [InlineData(new string[] { "-c", "configuration" }, @"exec /m /v:m /t:Build /p:Configuration=configuration /clp:Summary")] [InlineData(new string[] { "--configuration", "configuration" }, @"exec /m /v:m /t:Build /p:Configuration=configuration /clp:Summary")] [InlineData(new string[] { "--version-suffix", "mysuffix" }, @"exec /m /v:m /t:Build /p:VersionSuffix=mysuffix /clp:Summary")] [InlineData(new string[] { "--no-dependencies" }, @"exec /m /v:m /t:Build /p:BuildProjectReferences=false /clp:Summary")] [InlineData(new string[] { "-v", "verbosity" }, @"exec /m /v:m /t:Build /verbosity:verbosity /clp:Summary")] [InlineData(new string[] { "--verbosity", "verbosity" }, @"exec /m /v:m /t:Build /verbosity:verbosity /clp:Summary")] [InlineData(new string[] { "--no-incremental", "-o", "myoutput", "-r", "myruntime", "-v", "diag" }, @"exec /m /v:m /t:Rebuild /p:OutputPath=myoutput /p:RuntimeIdentifier=myruntime /verbosity:diag /clp:Summary")] public void MsbuildInvocationIsCorrect(string[] args, string expectedCommand) { var msbuildPath = ""; BuildCommand.FromArgs(args, msbuildPath) .GetProcessStartInfo().Arguments.Should().Be(expectedCommand); } } }