コード例 #1
0
        public static void MoveArtifactsToTestResults(this TestLauncher build, bool DotCover, bool Server, bool Studio, string JobName)
        {
            string testsResultsPath = build.TestRunner.TestsResultsPath;

            if (Directory.Exists(testsResultsPath))
            {
                foreach (var FullTRXFilePath in Directory.GetFiles(testsResultsPath, "*.trx"))
                {
                    XmlDocument trxContent = new XmlDocument();
                    trxContent.Load(FullTRXFilePath);
                    var namespaceManager = new XmlNamespaceManager(trxContent.NameTable);
                    namespaceManager.AddNamespace("a", "http://microsoft.com/schemas/VisualStudio/TeamTest/2010");
                    if (trxContent.DocumentElement.SelectSingleNode("/a:TestRun/a:ResultSummary", namespaceManager).Attributes["outcome"].Value != "Completed")
                    {
                        WriteFailingTestPlaylist($"{build.TestRunner.TestsResultsPath}\\{JobName} Failures.playlist", FullTRXFilePath, trxContent, namespaceManager);
                    }
                }
            }

            string containerLogFile = Environment.ExpandEnvironmentVariables(@"%ProgramData%\Warewolf\Server Log\Container Launcher.log");

            if (File.Exists(containerLogFile))
            {
                WaitForFileUnlock(containerLogFile);
                MoveFileToTestResults(containerLogFile, $"{JobName} Container Launcher.log", build.TestRunner.TestsResultsPath);
            }

            if (Studio)
            {
                string studioLogFile = Environment.ExpandEnvironmentVariables(@"%LocalAppData%\Warewolf\Studio Logs\Warewolf Studio.log");
                WaitForFileUnlock(studioLogFile);
                MoveFileToTestResults(studioLogFile, $"{JobName} Studio.log", build.TestRunner.TestsResultsPath);
            }
            if (Studio && DotCover)
            {
                var StudioSnapshot = Environment.ExpandEnvironmentVariables(@"%LocalAppData%\Warewolf\Studio Logs\dotCover.dcvr");
                Console.WriteLine($"Trying to move Studio coverage snapshot file from {StudioSnapshot} to {build.TestRunner.TestsResultsPath}\\{JobName} Studio DotCover.dcvr");
                var exists = WaitForFileExist(StudioSnapshot);
                if (exists)
                {
                    var locked = WaitForFileUnlock(StudioSnapshot);
                    if (!(locked))
                    {
                        Console.WriteLine($"Moving Studio coverage snapshot file from StudioSnapshot to {build.TestRunner.TestsResultsPath}\\{JobName} Studio DotCover.dcvr");
                        CopyOnWrite($"{build.TestRunner.TestsResultsPath}\\{JobName} Studio DotCover.dcvr");
                        File.Move(StudioSnapshot, $"{build.TestRunner.TestsResultsPath}\\{JobName} Studio DotCover.dcvr");
                    }
                    else
                    {
                        Console.WriteLine("Studio Coverage Snapshot File is locked.");
                    }
                }
                else
                {
                    throw new FileNotFoundException($"Studio coverage snapshot not found at {StudioSnapshot}");
                }
                if (File.Exists(Environment.ExpandEnvironmentVariables(@"%LocalAppData%\Warewolf\Studio Logs\dotCover.log")))
                {
                    MoveFileToTestResults(Environment.ExpandEnvironmentVariables(@"%LocalAppData%\Warewolf\Studio Logs\dotCover.log"), $"{JobName} Studio DotCover.log", build.TestRunner.TestsResultsPath);
                }
            }
            if (Server)
            {
                string serverLogFile = Environment.ExpandEnvironmentVariables(@"%ProgramData%\Warewolf\Server Log\wareWolf-Server.log");
                WaitForFileUnlock(serverLogFile);
                MoveFileToTestResults(serverLogFile, $"{JobName} Server.log", build.TestRunner.TestsResultsPath);

                string myWarewolfIoLogFile = Environment.ExpandEnvironmentVariables(@"%ProgramData%\Warewolf\Server Log\my.warewolf.io.log");
                WaitForFileUnlock(serverLogFile);
                MoveFileToTestResults(myWarewolfIoLogFile, $"{JobName} my.warewolf.io Server.log", build.TestRunner.TestsResultsPath);

                string myWarewolfIoErrorsLogFile = Environment.ExpandEnvironmentVariables(@"%ProgramData%\Warewolf\Server Log\my.warewolf.io.errors.log");
                WaitForFileUnlock(myWarewolfIoErrorsLogFile);
                MoveFileToTestResults(myWarewolfIoErrorsLogFile, $"{JobName} my.warewolf.io Server Errors.log", build.TestRunner.TestsResultsPath);
            }
            if (Server && DotCover)
            {
                var ServerSnapshot = Environment.ExpandEnvironmentVariables(@"%ProgramData%\Warewolf\Server Log\dotCover.dcvr");
                Console.WriteLine($"Trying to move Server coverage snapshot file from {ServerSnapshot} to {build.TestRunner.TestsResultsPath}\\{JobName} Server DotCover.dcvr");
                var exists = WaitForFileExist(ServerSnapshot);
                if (exists)
                {
                    var locked = WaitForFileUnlock(ServerSnapshot);
                    if (!locked)
                    {
                        Console.WriteLine($"Moving Server coverage snapshot file from {ServerSnapshot} to {build.TestRunner.TestsResultsPath}\\{JobName} Server DotCover.dcvr");
                        MoveFileToTestResults(ServerSnapshot, $"{JobName} Server DotCover.dcvr", build.TestRunner.TestsResultsPath);
                    }
                    else
                    {
                        Console.WriteLine("Server Coverage Snapshot File still locked after retrying for 2 minutes.");
                    }
                }
                if (File.Exists(Environment.ExpandEnvironmentVariables(@"%ProgramData%\Warewolf\Server Log\dotCover.log")))
                {
                    MoveFileToTestResults(Environment.ExpandEnvironmentVariables(@"%ProgramData%\Warewolf\Server Log\dotCover.log"), $"{JobName} Server DotCover.log", build.TestRunner.TestsResultsPath);
                }
                if (File.Exists(Environment.ExpandEnvironmentVariables(@"%ProgramData%\Warewolf\Server Log\my.warewolf.io.log")))
                {
                    MoveFileToTestResults(Environment.ExpandEnvironmentVariables(@"%ProgramData%\Warewolf\Server Log\my.warewolf.io.log"), $"{JobName} my.warewolf.io.log", build.TestRunner.TestsResultsPath);
                }
                if (File.Exists(Environment.ExpandEnvironmentVariables(@"%ProgramData%\Warewolf\Server Log\my.warewolf.io.errors.log")))
                {
                    MoveFileToTestResults(Environment.ExpandEnvironmentVariables(@"%ProgramData%\Warewolf\Server Log\my.warewolf.io.errors.log"), $"{JobName} my.warewolf.io Errors.log", build.TestRunner.TestsResultsPath);
                }
            }
            if (Server && Studio && DotCover)
            {
                build.TestCoverageMerger.MergeCoverageSnapshots(new List <string> {
                    Path.Combine(build.TestRunner.TestsResultsPath, $"{JobName} Server DotCover.dcvr"), Path.Combine(build.TestRunner.TestsResultsPath, $"{JobName} Studio DotCover.dcvr")
                }, Path.Combine(build.TestRunner.TestsResultsPath, $"{JobName} Merged Server and Studio DotCover"), Path.Combine(build.TestRunner.TestsResultsPath, "ServerAndStudioDotCoverSnapshot"), build.DotCoverPath);
            }
            if (build.RecordScreen != null)
            {
                MoveScreenRecordingsToTestResults(build.TestRunner.TestsResultsPath);
            }
            foreach (var scriptFile in Directory.GetFiles(Path.GetDirectoryName(build.TestRunner.TestsResultsPath)))
            {
                if (Path.GetFileName(scriptFile).StartsWith("Run ") && Path.GetExtension(scriptFile) == ".bat")
                {
                    MoveFileToTestResults(scriptFile, Path.GetFileName(scriptFile), build.TestRunner.TestsResultsPath);
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: pyrodc/Warewolf
        public static void Main(string[] args)
        {
            using (WindowsIdentity identity = WindowsIdentity.GetCurrent())
            {
                WindowsPrincipal principal = new WindowsPrincipal(identity);
                if (!principal.IsInRole(WindowsBuiltInRole.Administrator))
                {
                    var exeName = Process.GetCurrentProcess().MainModule.FileName;
                    ProcessStartInfo startInfo = new ProcessStartInfo(exeName)
                    {
                        Verb      = "runas",
                        Arguments = string.Join(" ", args)
                    };
                    Process.Start(startInfo);
                    return;
                }
            }

            TestLauncher build = null;

            try
            {
                build          = Options.PargeArgs(args);
                build.JobSpecs = Job_Definitions.GetJobDefinitions();

                build.ServerExeName   = "Warewolf Server.exe";
                build.ServerPathSpecs = new List <string>
                {
                    build.ServerExeName,
                    "Server\\" + build.ServerExeName,
                    "DebugServer\\" + build.ServerExeName,
                    "ReleaseServer\\" + build.ServerExeName,
                    "Dev2.Server\\bin\\Debug\\" + build.ServerExeName,
                    "Bin\\Server\\" + build.ServerExeName,
                    "Dev2.Server\\bin\\Release\\" + build.ServerExeName,
                    "*Server.zip"
                };

                build.StudioExeName   = "Warewolf Studio.exe";
                build.StudioPathSpecs = new List <string>
                {
                    build.StudioExeName,
                    "Studio\\" + build.StudioExeName,
                    "DebugStudio\\" + build.StudioExeName,
                    "ReleaseStudio\\" + build.StudioExeName,
                    "Dev2.Studio\\bin\\Debug\\" + build.StudioExeName,
                    "Bin\\Studio\\" + build.StudioExeName,
                    "Dev2.Studio\\bin\\Release\\" + build.StudioExeName,
                    "*Studio.zip"
                };

                if (build.JobName != null && build.JobName.Contains(" DotCover"))
                {
                    build.ApplyDotCover = true;
                    build.JobName       = build.JobName.Replace(" DotCover", "");
                }
                else
                {
                    build.ApplyDotCover = !string.IsNullOrEmpty(build.DotCoverPath);
                }

                if (!string.IsNullOrEmpty(build.TestRunner.TestsPath) && build.TestRunner.TestsPath.StartsWith(".."))
                {
                    build.TestRunner.TestsPath = Path.Combine(Environment.CurrentDirectory, build.TestRunner.TestsPath);
                }

                if (!string.IsNullOrEmpty(build.TestRunner.TestsResultsPath) && build.TestRunner.TestsResultsPath.StartsWith(".."))
                {
                    build.TestRunner.TestsResultsPath = Path.Combine(Environment.CurrentDirectory, build.TestRunner.TestsResultsPath);
                }

                if (!string.IsNullOrEmpty(build.ServerPath) && build.ServerPath.StartsWith(".."))
                {
                    build.ServerPath = Path.Combine(Environment.CurrentDirectory, build.ServerPath);
                }

                if (!string.IsNullOrEmpty(build.StudioPath) && build.StudioPath.StartsWith(".."))
                {
                    build.StudioPath = Path.Combine(Environment.CurrentDirectory, build.StudioPath);
                }

                if (!string.IsNullOrEmpty(build.TestRunner.TestList))
                {
                    build.TestRunner.TestList = build.TestRunner.TestList.Trim();
                }

                if (!File.Exists(build.TestRunner.TestsResultsPath))
                {
                    Directory.CreateDirectory(build.TestRunner.TestsResultsPath);
                }

                if (build.MergeDotCoverSnapshotsInDirectory != null)
                {
                    build.MergeDotCoverSnapshots();
                }

                if (!build.Cleanup)
                {
                    if (!string.IsNullOrEmpty(build.JobName) && string.IsNullOrEmpty(build.AssemblyFileVersionsTest) && string.IsNullOrEmpty(build.RunWarewolfServiceTests) && string.IsNullOrEmpty(build.MergeDotCoverSnapshotsInDirectory))
                    {
                        build.RunTestJobs();
                    }
                }
                else
                {
                    build.CleanupServerStudio(!build.ApplyDotCover);
                    if (string.IsNullOrEmpty(build.JobName))
                    {
                        if (!string.IsNullOrEmpty(build.ProjectName))
                        {
                            build.JobName = build.ProjectName;
                        }
                        else
                        {
                            build.JobName = "Manual Tests";
                        }
                    }
                    build.MoveArtifactsToTestResults(build.ApplyDotCover, File.Exists(Environment.ExpandEnvironmentVariables("%ProgramData%\\Warewolf\\Server Log\\wareWolf-Server.log")), File.Exists(Environment.ExpandEnvironmentVariables("%LocalAppData\\Warewolf\\Studio Logs\\Warewolf Studio.log")), build.JobName);
                }

                if (!string.IsNullOrEmpty(build.AssemblyFileVersionsTest))
                {
                    Console.WriteLine("Testing Warewolf assembly file versions...");
                    var HighestReadVersion = "0.0.0.0";
                    var LastReadVersion    = "0.0.0.0";
                    foreach (var file in Directory.GetFiles(build.TestRunner.TestsPath, "*", SearchOption.AllDirectories))
                    {
                        if ((file.EndsWith(".dll") || (file.EndsWith(".exe") && !file.EndsWith(".vshost.exe"))) && (file.StartsWith("Dev2.") || file.StartsWith("Warewolf.") || file.StartsWith("WareWolf")))
                        {
                            // Get version.
                            var ReadVersion = FileVersionInfo.GetVersionInfo(file).FileVersion;

                            // Find highest version
                            var SeperateVersionNumbers = ReadVersion.Split('.');

                            var SeperateVersionNumbersHighest = HighestReadVersion.Split('.');
                            if (Convert.ToInt32(SeperateVersionNumbers[0], 10) > Convert.ToInt32(SeperateVersionNumbersHighest[0], 10) || Convert.ToInt32(SeperateVersionNumbers[1], 10) > Convert.ToInt32(SeperateVersionNumbersHighest[1], 10) || Convert.ToInt32(SeperateVersionNumbers[2], 10) > Convert.ToInt32(SeperateVersionNumbersHighest[2], 10) || Convert.ToInt32(SeperateVersionNumbers[3], 10) > Convert.ToInt32(SeperateVersionNumbersHighest[3], 10))
                            {
                                HighestReadVersion = ReadVersion;
                            }

                            // Check for invalid.
                            if (ReadVersion.StartsWith("0.0.") || (LastReadVersion != ReadVersion && LastReadVersion != "0.0.0.0"))
                            {
                                throw new Exception("ERROR! \"" + file + " " + ReadVersion + "\" is either an invalid version or not equal to \"" + LastReadVersion + "\". All Warewolf assembly versions in \"" + build.TestRunner.TestsPath + "\" must conform and cannot start with 0.0. or end with .0");
                            }
                            LastReadVersion = ReadVersion;
                        }
                    }
                    File.WriteAllText("FullVersionString", "FullVersionString=" + HighestReadVersion);
                }

                if (!build.Cleanup && string.IsNullOrEmpty(build.AssemblyFileVersionsTest) && string.IsNullOrEmpty(build.JobName) && string.IsNullOrEmpty(build.RunWarewolfServiceTests) && string.IsNullOrEmpty(build.MergeDotCoverSnapshotsInDirectory))
                {
                    if (build.AdminMode)
                    {
                        AdminMode.Run(build);
                    }
                    else
                    {
                        ManualMode.Run(build);
                    }
                }
            }
            finally
            {
                if (build != null)
                {
                    build.Dispose();
                }
            }
        }
コード例 #3
0
        public static void CleanupServerStudio(this TestLauncher build, bool Force = true, string JobName = "")
        {
            if (!string.IsNullOrEmpty(build.ServerPath) && File.Exists(build.ServerPath))
            {
                string serverStartedFile = Path.Combine(Path.GetDirectoryName(build.ServerPath), "ServerStarted");
                if (File.Exists(serverStartedFile))
                {
                    File.Delete(serverStartedFile);
                }
            }

            //Find Webs
            if (string.IsNullOrEmpty(build.WebsPath))
            {
                build.WebsPath = Path.Combine(build.TestRunner.TestsPath, "_PublishedWebsites", "Dev2.Web");
                if (!File.Exists(build.WebsPath) && !String.IsNullOrEmpty(build.ServerPath))
                {
                    build.WebsPath = Path.Combine(Path.GetDirectoryName(build.ServerPath), "_PublishedWebsites", "Dev2.Web");
                }
            }
            else
            {
                if (!Directory.Exists(build.WebsPath))
                {
                    throw new ArgumentException("No webs folder found at " + build.WebsPath);
                }
            }

            //Find Studio
            if (string.IsNullOrEmpty(build.StudioPath))
            {
                bool foundStudio = build.TryFindWarewolfStudioExe(out string studioPath);
                if (foundStudio)
                {
                    build.StudioPath = studioPath;
                }
            }
            else
            {
                if (!File.Exists(build.StudioPath))
                {
                    throw new ArgumentException("No studio found at " + build.StudioPath);
                }
            }
            if (!string.IsNullOrEmpty(build.StudioPath))
            {
                string studioStartedFile = Path.Combine(Path.GetDirectoryName(build.StudioPath), "StudioStarted");
                if (File.Exists(studioStartedFile))
                {
                    File.Delete(studioStartedFile);
                }
            }

            int WaitForCloseTimeout    = Force ? 10 : 1800;
            int WaitForCloseRetryCount = Force ? 1 : 10;

            //Stop Studio
            Process process = ProcessUtils.StartProcess("taskkill", "/im \"Warewolf Studio.exe\"");
            var     Output  = process.StandardOutput.ReadToEnd() + process.StandardError.ReadToEnd();

            //Soft Kill
            int    i = 0;
            string WaitTimeoutMessage = "This command stopped operation because process ";
            string WaitOutput         = WaitTimeoutMessage;

            while (!(Output.StartsWith("ERROR: ")) && WaitOutput.StartsWith(WaitTimeoutMessage) && i < WaitForCloseRetryCount)
            {
                i++;
                Console.WriteLine(Output);
                Process.GetProcessesByName("Warewolf Studio")[0].WaitForExit(WaitForCloseTimeout);
                var FormatWaitForCloseTimeoutMessage = WaitOutput.Replace(WaitTimeoutMessage, "");
                if (FormatWaitForCloseTimeoutMessage != "" && !(FormatWaitForCloseTimeoutMessage.StartsWith("Cannot find a process with the name ")))
                {
                    Console.WriteLine(FormatWaitForCloseTimeoutMessage);
                }
                process.Start();
                process.WaitForExit();
                Output = process.StandardOutput.ReadToEnd() + process.StandardError.ReadToEnd();
            }

            //Force Kill
            process.StartInfo.Arguments = "/im \"Warewolf Studio.exe\" /f";
            process.Start();
            process.WaitForExit();
            Output = process.StandardOutput.ReadToEnd() + process.StandardError.ReadToEnd();
            if (!(Output.StartsWith("ERROR: ")))
            {
                Console.WriteLine(Output);
            }

            //Stop my.warewolf.io
            process.StartInfo.Arguments = "/im iisexpress.exe /f";
            process.Start();
            process.WaitForExit();
            Output = process.StandardOutput.ReadToEnd() + process.StandardError.ReadToEnd();
            if (!(Output.StartsWith("ERROR: ")))
            {
                Console.WriteLine(Output);
            }

            if (!build.StartServerAsConsole)
            {
                //Stop Server
                var stopServerService = new Process();
                stopServerService.StartInfo.UseShellExecute        = false;
                stopServerService.StartInfo.RedirectStandardOutput = true;
                stopServerService.StartInfo.RedirectStandardError  = true;
                stopServerService.StartInfo.FileName  = "sc.exe";
                stopServerService.StartInfo.Arguments = "stop \"Warewolf Server\"";
                stopServerService.Start();
                stopServerService.WaitForExit();
                var ServiceOutput = stopServerService.StandardOutput.ReadToEnd() + stopServerService.StandardError.ReadToEnd();
                if (ServiceOutput != "[SC] ControlService FAILED 1062:\r\n\r\nThe service has not been started.\r\n\r\n")
                {
                    Console.WriteLine(ServiceOutput.TrimStart('\n'));
                    var allServerProcesses = Process.GetProcessesByName("Warewolf Server");
                    if (allServerProcesses.Length > 0)
                    {
                        allServerProcesses[0].WaitForExit(WaitForCloseTimeout);
                    }
                }
            }
            process.StartInfo.Arguments = "/im \"Warewolf Server.exe\" /f";
            process.Start();
            process.StartInfo.Arguments = "/im \"operadriver.exe\" /f";
            process.Start();
            process.StartInfo.Arguments = "/im \"geckodriver.exe\" /f";
            process.Start();
            process.StartInfo.Arguments = "/im \"IEDriverServer.exe\" /f";
            process.Start();

            //Delete Certain Studio and Server Resources
            foreach (var FileOrFolder in ToClean)
            {
                var ActualPath = Environment.ExpandEnvironmentVariables(FileOrFolder);
                if (File.Exists(ActualPath))
                {
                    WaitForFileUnlock(ActualPath);
                    File.Delete(ActualPath);
                }
                if (Directory.Exists(ActualPath))
                {
                    WaitForFolderUnlock(ActualPath);
                    Directory.Delete(ActualPath, true);
                }
                if ((File.Exists(FileOrFolder) || Directory.Exists(FileOrFolder)))
                {
                    Console.Error.WriteLine("Cannot delete " + FileOrFolder);
                }
            }

            if (String.IsNullOrEmpty(JobName))
            {
                JobName = "Test Run";
            }

            //Publish Certain Studio and Server Resources
            foreach (var FileOrFolder in ToPublish)
            {
                var ActualPath = Environment.ExpandEnvironmentVariables(FileOrFolder);
                if (Directory.Exists(ActualPath))
                {
                    MoveFolderToTestResults(Environment.ExpandEnvironmentVariables(ActualPath), $"{JobName} Server {Path.GetFileName(ActualPath)} Folder", build.TestRunner.TestsResultsPath);
                }
            }
        }
コード例 #4
0
ファイル: Options.cs プロジェクト: hathanhhung/Warewolf
        public static TestLauncher PargeArgs(string[] args)
        {
            var testLauncher = new TestLauncher();
            var parser       = new Parser(with => with.EnableDashDash = true);
            var parserResult = parser.ParseArguments <Options>(args);

            if (args.Length > 0 && parserResult.Tag == ParserResultType.NotParsed)
            {
                throw new ArgumentException("Syntax Error in Args \"" + string.Join(" ", args) + "\". Some args take a string value for example: --ServerPath 'C:\\Builds\\Warewolf Server.exe'");
            }
            var result = parserResult.WithParsed(options =>
            {
                if (options.DoServerStart)
                {
                    Console.WriteLine("Doing Server Start.");
                    testLauncher.DoServerStart = "true";
                }
                if (options.DoStudioStart)
                {
                    Console.WriteLine("Doing Studio Start.");
                    testLauncher.DoStudioStart = "true";
                }
                if (options.ServerPath != null)
                {
                    Console.WriteLine("ServerPath: " + options.ServerPath);
                    testLauncher.ServerPath = options.ServerPath;
                }
                if (options.StudioPath != null)
                {
                    Console.WriteLine("StudioPath: " + options.StudioPath);
                    testLauncher.StudioPath = options.StudioPath;
                }
                if (options.ResourcesType != null)
                {
                    Console.WriteLine("ResourcesType: " + options.ResourcesType);
                    testLauncher.ResourcesType = options.ResourcesType;
                }
                if (options.VSTest)
                {
                    Console.WriteLine("Test Runner: VSTest");
                }
                if (options.VSTest || (!options.MSTest && !options.VSTest))
                {
                    testLauncher.TestRunner = new VSTestRunner();
                }
                if (options.MSTest)
                {
                    Console.WriteLine("Test Runner: MSTest");
                    testLauncher.TestRunner = new MSTestRunner();
                }
                if (options.DotCoverPath != null)
                {
                    Console.WriteLine("DotCoverPath: " + options.DotCoverPath);
                    testLauncher.DotCoverPath = options.DotCoverPath;
                }
                if (options.ServerUsername != null)
                {
                    testLauncher.ServerUsername = options.ServerUsername;
                }
                if (options.ServerPassword != null)
                {
                    Console.WriteLine("ServerPassword: ****");
                    testLauncher.ServerPassword = options.ServerPassword;
                }
                if (options.RunAllJobs)
                {
                    Console.WriteLine("RunAllJobs");
                    testLauncher.RunAllJobs = "true";
                }
                if (options.Cleanup)
                {
                    Console.WriteLine("Cleaning Up.");
                    testLauncher.Cleanup = true;
                }
                if (options.AssemblyFileVersionsTest != null)
                {
                    Console.WriteLine("AssemblyFileVersionsTest: " + options.AssemblyFileVersionsTest);
                    testLauncher.AssemblyFileVersionsTest = options.AssemblyFileVersionsTest;
                }
                if (options.RecordScreen)
                {
                    Console.WriteLine("Recording Screen.");
                    testLauncher.RecordScreen = "true";
                }
                if (options.Category != null)
                {
                    Console.WriteLine("Category: " + options.Category);
                    testLauncher.Category = options.Category;
                }
                if (options.ProjectName != null)
                {
                    Console.WriteLine("ProjectName: " + options.ProjectName);
                    testLauncher.ProjectName = options.ProjectName;
                }
                if (options.RunAllUnitTests)
                {
                    Console.WriteLine("Running All Unit Tests.");
                    testLauncher.RunAllUnitTests = "true";
                }
                if (options.RunAllServerTests)
                {
                    Console.WriteLine("Running All Server Tests.");
                    testLauncher.RunAllServerTests = "true";
                }
                if (options.RunAllReleaseResourcesTests)
                {
                    Console.WriteLine("Running All Release Resources Tests.");
                    testLauncher.RunAllReleaseResourcesTests = "true";
                }
                if (options.RunAllDesktopUITests)
                {
                    Console.WriteLine("Running All Desktop UI Tests.");
                    testLauncher.RunAllDesktopUITests = "true";
                }
                if (options.RunAllWebUITests)
                {
                    Console.WriteLine("Running All Web UI Tests.");
                    testLauncher.RunAllWebUITests = "true";
                }
                if (options.RunWarewolfServiceTests)
                {
                    Console.WriteLine("Running Warewolf Service Tests.");
                    testLauncher.RunWarewolfServiceTests = "true";
                }
                if (options.DomywarewolfioStart)
                {
                    Console.WriteLine("Doing my.warewolf.io Start.");
                    testLauncher.DomywarewolfioStart = "true";
                }
                if (options.TestsPath != null)
                {
                    Console.WriteLine("TestsPath: " + options.TestsPath);
                    testLauncher.TestRunner.TestsPath        = options.TestsPath;
                    testLauncher.TestRunner.TestsResultsPath = testLauncher.TestRunner.TestsPath + "\\TestResults";
                }
                if (options.JobName != null)
                {
                    Console.WriteLine("JobName: " + options.JobName);
                    testLauncher.JobName = options.JobName;
                }
                if (options.TestList != null)
                {
                    Console.WriteLine("TestList: " + options.TestList);
                    testLauncher.TestRunner.TestList = options.TestList;
                }
                if (options.MergeDotCoverSnapshotsInDirectory != null)
                {
                    Console.WriteLine("Merging DotCover Snapshots In Directory: " + options.MergeDotCoverSnapshotsInDirectory);
                    testLauncher.MergeDotCoverSnapshotsInDirectory = options.MergeDotCoverSnapshotsInDirectory;
                }
                if (options.TestsResultsPath != null)
                {
                    Console.WriteLine("TestsResultsPath: " + options.TestsResultsPath);
                    testLauncher.TestRunner.TestsResultsPath = options.TestsResultsPath;
                }
                if (options.VSTestPath != null)
                {
                    Console.WriteLine("VSTestPath: " + options.VSTestPath);
                    testLauncher.TestRunner.Path = options.VSTestPath;
                }
                if (options.MSTestPath != null)
                {
                    Console.WriteLine("MSTestPath: " + options.MSTestPath);
                    testLauncher.TestRunner.Path = options.MSTestPath;
                }
                if (options.RetryCount != null)
                {
                    Console.WriteLine("RetryCount: Re-trying failures " + options.RetryCount + " number of times.");
                    if (int.TryParse(options.RetryCount, out int retryCount))
                    {
                        testLauncher.RetryCount = retryCount;
                    }
                    else
                    {
                        Console.WriteLine("RetryCount: Expects a number of times to re-try failing tests. Cannot parse " + options.RetryCount);
                    }
                }
                if (options.RetryFile != null)
                {
                    Console.WriteLine("Retrying all failures in file: " + options.RetryFile);
                    testLauncher.RetryFile = options.RetryFile;
                }
                if (options.ConsoleServer)
                {
                    Console.WriteLine("ConsoleServer: Starting the server in a console window.");
                    testLauncher.StartServerAsConsole = true;
                }
                if (options.AdminMode)
                {
                    testLauncher.AdminMode = true;
                }
            }).WithNotParsed(errs =>
            {
                foreach (var err in errs)
                {
                    if (err.Tag != ErrorType.MissingValueOptionError)
                    {
                        throw new ArgumentException(err.Tag.ToString());
                    }
                }
            });

            return(testLauncher);
        }