public BuildServerShutdownCommand( AppliedOption options, ParseResult result, IBuildServerProvider serverProvider = null, bool useOrderedWait = false, IReporter reporter = null) : base(result) { bool msbuild = options.ValueOrDefault <bool>("msbuild"); bool vbcscompiler = options.ValueOrDefault <bool>("vbcscompiler"); bool razor = options.ValueOrDefault <bool>("razor"); bool all = !msbuild && !vbcscompiler && !razor; _enumerationFlags = ServerEnumerationFlags.None; if (msbuild || all) { _enumerationFlags |= ServerEnumerationFlags.MSBuild; } if (vbcscompiler || all) { _enumerationFlags |= ServerEnumerationFlags.VBCSCompiler; } if (razor || all) { _enumerationFlags |= ServerEnumerationFlags.Razor; } _serverProvider = serverProvider ?? new BuildServerProvider(); _useOrderedWait = useOrderedWait; _reporter = reporter ?? Reporter.Output; _errorReporter = reporter ?? Reporter.Error; }
public BuildServerShutdownCommand( ParseResult result, IBuildServerProvider serverProvider = null, bool useOrderedWait = false, IReporter reporter = null) : base(result) { bool msbuild = result.GetValueForOption(ServerShutdownCommandParser.MSBuildOption); bool vbcscompiler = result.GetValueForOption(ServerShutdownCommandParser.VbcsOption); bool razor = result.GetValueForOption(ServerShutdownCommandParser.RazorOption); bool all = !msbuild && !vbcscompiler && !razor; _enumerationFlags = ServerEnumerationFlags.None; if (msbuild || all) { _enumerationFlags |= ServerEnumerationFlags.MSBuild; } if (vbcscompiler || all) { _enumerationFlags |= ServerEnumerationFlags.VBCSCompiler; } if (razor || all) { _enumerationFlags |= ServerEnumerationFlags.Razor; } _serverProvider = serverProvider ?? new BuildServerProvider(); _useOrderedWait = useOrderedWait; _reporter = reporter ?? Reporter.Output; _errorReporter = reporter ?? Reporter.Error; }
private Tools.BuildServer.Shutdown.BuildServerShutdownCommand CreateCommand( string options = "", IBuildServerProvider serverProvider = null, IEnumerable <IBuildServer> buildServers = null, ServerEnumerationFlags expectedFlags = ServerEnumerationFlags.None) { ParseResult result = Parser.Instance.Parse($"dotnet build-server shutdown {options}".Trim()); return(new Tools.BuildServer.Shutdown.BuildServerShutdownCommand( result: result, serverProvider: serverProvider, useOrderedWait: true, reporter: _reporter)); }
private BuildServerShutdownCommand CreateCommand( string options = "", IBuildServerProvider serverProvider = null, IEnumerable <IBuildServer> buildServers = null, ServerEnumerationFlags expectedFlags = ServerEnumerationFlags.None) { ParseResult result = Parser.Instance.Parse("dotnet build-server shutdown " + options); return(new BuildServerShutdownCommand( options: result["dotnet"]["build-server"]["shutdown"], result: result, serverProvider: serverProvider, useOrderedWait: true, reporter: _reporter)); }
public IEnumerable <IBuildServer> EnumerateBuildServers(ServerEnumerationFlags flags = ServerEnumerationFlags.All) { if ((flags & ServerEnumerationFlags.MSBuild) == ServerEnumerationFlags.MSBuild) { // Yield a single MSBuild server (handles server discovery itself) // TODO: use pid file enumeration when supported by the server (https://github.com/dotnet/cli/issues/9113) yield return(new MSBuildServer()); } if ((flags & ServerEnumerationFlags.VBCSCompiler) == ServerEnumerationFlags.VBCSCompiler) { // Yield a single VB/C# compiler (handles server discovery itself) // TODO: use pid file enumeration when supported by the server (https://github.com/dotnet/cli/issues/9112) yield return(new VBCSCompilerServer()); } // TODO: remove or amend this check when the following issues are resolved: // https://github.com/dotnet/cli/issues/9112 // https://github.com/dotnet/cli/issues/9113 if ((flags & ServerEnumerationFlags.Razor) != ServerEnumerationFlags.Razor) { yield break; } var directory = GetPidFileDirectory(); if (!_fileSystem.Directory.Exists(directory.Value)) { yield break; } foreach (var path in _fileSystem.Directory.EnumerateFiles(directory.Value, "*")) { if ((flags & ServerEnumerationFlags.Razor) == ServerEnumerationFlags.Razor && Path.GetFileName(path).StartsWith(RazorPidFile.FilePrefix)) { var file = ReadRazorPidFile(new FilePath(path)); if (file != null) { yield return(new RazorServer(file)); } } } }