示例#1
0
        public void ResponseFileEntireCommandLine(bool useShortSwitchNames)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                NoLogo        = true,
                ResponseFiles =
                {
                    Path.GetTempFileName()
                },
            };

            string responseFilePath = Path.GetTempFileName();

            try
            {
                commandLineArguments.ToString(responseFilePath, useShortSwitchNames).ShouldBe($"@\"{responseFilePath}\"");

                string responseFileContents = File.ReadAllText(responseFilePath);

                responseFileContents.ShouldBe($"/NoLogo @\"{commandLineArguments.ResponseFiles.First()}\"");
            }
            finally
            {
                foreach (string file in commandLineArguments.ResponseFiles.Concat(new[] { responseFilePath }))
                {
                    File.Delete(file);
                }
            }
        }
        public void LoggerParametersMultipleTest(bool useShortSwitchNames)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments();

            commandLineArguments.DistributedLoggers.Add(new MSBuildDistributedLoggerParameters
            {
                CentralLogger = new MSBuildLoggerParameters
                {
                    Assembly   = "MyLogger,Version=1.0.2,Culture=neutral",
                    ClassName  = "XMLLogger",
                    Parameters = "1 2 3",
                },
                ForwardingLogger = new MSBuildLoggerParameters
                {
                    Assembly  = "ForwardingLogger,Version=1.0,Culture=neutral",
                    ClassName = "XMLLogger",
                }
            });

            commandLineArguments.DistributedLoggers.Add(new MSBuildDistributedLoggerParameters
            {
                CentralLogger = new MSBuildLoggerParameters
                {
                    Assembly  = "MyLogger2,Version=1.0.3,Culture=neutral",
                    ClassName = "XMLLogger3",
                },
                ForwardingLogger = new MSBuildLoggerParameters
                {
                    Assembly  = "ForwardingLogger2,Version=1.0.0,Culture=neutral",
                    ClassName = "XMLLogger2",
                }
            });

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"\"/{GetSwitchName(useShortSwitchNames)}:{commandLineArguments.DistributedLoggers.First().CentralLogger.ClassName},{commandLineArguments.DistributedLoggers.First().CentralLogger.Assembly};{commandLineArguments.DistributedLoggers.First().CentralLogger.Parameters}*{commandLineArguments.DistributedLoggers.First().ForwardingLogger.ClassName},{commandLineArguments.DistributedLoggers.First().ForwardingLogger.Assembly}\" \"/{GetSwitchName(useShortSwitchNames)}:{commandLineArguments.DistributedLoggers.Last().CentralLogger.ClassName},{commandLineArguments.DistributedLoggers.Last().CentralLogger.Assembly}*{commandLineArguments.DistributedLoggers.Last().ForwardingLogger.ClassName},{commandLineArguments.DistributedLoggers.Last().ForwardingLogger.Assembly}\"");
        }
示例#3
0
        public void ResponseFileSingleTest()
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments();

            commandLineArguments.ResponseFiles.Add(@"C:\foo bar\bar.txt");

            commandLineArguments.ToString().ShouldBe($"@\"{commandLineArguments.ResponseFiles.First()}\"");
        }
        public void IgnoreProjectExtensionsSingle(bool useShortSwitchNames)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments();

            commandLineArguments.IgnoreProjectExtensions.Add(".sln");

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}:{String.Join(";", commandLineArguments.IgnoreProjectExtensions)}");
        }
示例#5
0
        public void PreProcessCustom(bool useShortSwitchNames)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                PreProcess = "Custom.xml",
            };

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}:{commandLineArguments.PreProcess}");
        }
示例#6
0
        public void NoAutoResponseFalse()
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                NoAutoResponse = false,
            };

            commandLineArguments.ToString().ShouldBeEmpty();
        }
示例#7
0
        public void MaxCpuCountZeroAndNegative(bool useShortSwitchNames, int maxCpuCount)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                MaxCpuCount = maxCpuCount
            };

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}");
        }
示例#8
0
        public void MaxCpuCountPositiveNumber(bool useShortSwitchNames, int maxCpuCount)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                MaxCpuCount = maxCpuCount
            };

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}:{maxCpuCount}");
        }
示例#9
0
        public void ConsoleLoggerParametersNotNullButEmpty()
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                ConsoleLoggerParameters = new MSBuildConsoleLoggerParameters(),
            };

            commandLineArguments.ToString().ShouldBe("");
        }
示例#10
0
        public void DetailedSummaryTrue(bool useShortSwitchNames)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                DetailedSummary = true,
            };

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}");
        }
示例#11
0
        public void ProjectNull()
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                Project = null,
            };

            commandLineArguments.ToString().ShouldBeEmpty();
        }
示例#12
0
        public void ProjectSpecifiedWithSpaces()
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                Project = @"C:\path to\a\project file\foo.csproj",
            };

            commandLineArguments.ToString().ShouldBe($"\"{commandLineArguments.Project}\"");
        }
示例#13
0
        public void ProjectSpecified()
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                Project = @"C:\path\to\a\project\file\foo.csproj",
            };

            commandLineArguments.ToString().ShouldBe($"{commandLineArguments.Project}");
        }
示例#14
0
        public void ValidateCustom(bool useShortSwitchNames)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                Validate = "Custom.xsd",
            };

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}:{commandLineArguments.Validate}");
        }
示例#15
0
        public void VersionFalse()
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                Version = false,
            };

            commandLineArguments.ToString().ShouldBeEmpty();
        }
示例#16
0
        public void DetailedSummaryFalse()
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                DetailedSummary = false,
            };

            commandLineArguments.ToString().ShouldBeEmpty();
        }
示例#17
0
        public void PreProcessDefault(bool useShortSwitchNames)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                PreProcess = String.Empty,
            };

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}");
        }
示例#18
0
        public void NoAutoResponseTrue(bool useShortSwitchNames)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                NoAutoResponse = true,
            };

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}");
        }
示例#19
0
        public void VersionTrue(bool useShortSwitchNames)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                Version = true,
            };

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}");
        }
示例#20
0
        public void DistributedFileLoggerTrue(bool useShortSwitchNames)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                DistributedFileLogger = true
            };

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}");
        }
示例#21
0
        public void DistributedFileLoggerFalse()
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                DistributedFileLogger = false
            };

            commandLineArguments.ToString().ShouldBeEmpty();
        }
示例#22
0
        public void BinaryLoggerParametersNotNullButEmpty(bool useShortSwitchNames)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                BinaryLogger = new MSBuildBinaryLoggerParameters(),
            };

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}");
        }
示例#23
0
        public void NoConsoleLoggerFalse()
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                NoConsoleLogger = false,
            };

            commandLineArguments.ToString().ShouldBeEmpty();
        }
示例#24
0
        public void NoLogoTrue()
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                NoLogo = true,
            };

            commandLineArguments.ToString().ShouldBe("/NoLogo");
        }
示例#25
0
        public void NodeReuse(bool useShortSwitchNames, bool nodeResuse)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                NodeReuse = nodeResuse,
            };

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}:{nodeResuse}");
        }
示例#26
0
        public void ResponseFileMultipleTest()
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments();

            commandLineArguments.ResponseFiles.Add(@"C:\foo bar\bar1.txt");
            commandLineArguments.ResponseFiles.Add(@"C:\foo bar\bar2.txt");
            commandLineArguments.ResponseFiles.Add(@"C:\foo bar\bar3.txt");

            commandLineArguments.ToString().ShouldBe($"@\"{String.Join("\" @\"", commandLineArguments.ResponseFiles)}\"");
        }
示例#27
0
        public void TargetSingle(bool useShortSwitchNames)
        {
            const string target = "Test";

            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments();

            commandLineArguments.Targets.Add(target);

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}:{target}");
        }
        public void FileLoggerSingleEncoding(bool useShortSwitchNames)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments();

            commandLineArguments.FileLoggers.Add(new MSBuildFileLoggerParameters
            {
                Encoding = "Unicode"
            });

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)} /{GetSecondarySwitchName(useShortSwitchNames)}:Encoding={commandLineArguments.FileLoggers.First().Encoding}");
        }
示例#29
0
        public void ToolsVersion(bool useShortSwitchNames)
        {
            const string toolsVersion = "Test";

            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments
            {
                ToolsVersion = toolsVersion,
            };

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)}:{toolsVersion}");
        }
        public void FileLoggerSingleLogFile(bool useShortSwitchNames)
        {
            MSBuildCommandLineArguments commandLineArguments = new MSBuildCommandLineArguments();

            commandLineArguments.FileLoggers.Add(new MSBuildFileLoggerParameters
            {
                LogFile = "my log.log"
            });

            commandLineArguments.ToString(useShortSwitchNames: useShortSwitchNames).ShouldBe($"/{GetSwitchName(useShortSwitchNames)} /{GetSecondarySwitchName(useShortSwitchNames)}:\"LogFile={commandLineArguments.FileLoggers.First().LogFile}\"");
        }