private async Task PreRunConditions(WorkerRuntime workerRuntime) { if (workerRuntime == WorkerRuntime.python) { await PythonHelpers.VerifyPythonVersions(setWorkerExecutable : true); // We need to update the PYTHONPATH to add worker's dependencies var pythonPath = Environment.GetEnvironmentVariable("PYTHONPATH") ?? string.Empty; var pythonWorkerDeps = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "workers", "python", "deps"); if (!pythonPath.Contains(pythonWorkerDeps)) { Environment.SetEnvironmentVariable("PYTHONPATH", $"{pythonWorkerDeps}{Path.PathSeparator}{pythonPath}", EnvironmentVariableTarget.Process); } if (StaticSettings.IsDebug) { ColoredConsole.WriteLine($"PYTHONPATH for the process is: {Environment.GetEnvironmentVariable("PYTHONPATH")}"); } } else if (workerRuntime == WorkerRuntime.dotnet && !NoBuild) { if (DotnetHelpers.CanDotnetBuild()) { var outputPath = Path.Combine("bin", "output"); await DotnetHelpers.BuildDotnetProject(outputPath, string.Empty); Environment.CurrentDirectory = Path.Combine(Environment.CurrentDirectory, outputPath); } else if (StaticSettings.IsDebug) { ColoredConsole.WriteLine("Could not find a valid .csproj file. Skipping the build."); } } if (!NetworkHelpers.IsPortAvailable(Port)) { throw new CliException($"Port {Port} is unavailable. Close the process using that port, or specify another port using --port [-p]."); } }