Example #1
0
        private static void StartService(ITestOutputHelper testOutputHelper, Options options)
        {
            if (serviceProcess != null)
            {
                StopService();
            }

            // First make sure another instance is not already running (because we don't know which version is running)
            foreach (var process in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(ClousotServiceHostExe)))
            {
                process.CloseMainWindow();
                if (!process.WaitForExit(1000))
                {
                    process.Kill();
                }
            }

            var serviceHostDir = options.MakeAbsolute(Path.GetDirectoryName(ClousotServiceHostExe));

            // note: we do not want to use ClousotServiceHostExe from the deployment directory because the app.config will be missing
            serviceProcess = StartServiceProcess(serviceHostDir, options.MakeAbsolute(ClousotServiceHostExe), "", Output.Ignore(testOutputHelper));
        }