private static void Main(string[] args) { try { if (args == null || args.Length == 0 || _consoleArgsReader.ContainsHelpParam(args)) { ShowHelp(); return; } if (_consoleArgsReader.ContainsGetCwdParam(args)) { string cwd = _fileSystem.GetCurrentDirectory(); _logger.Log($"Current working directory is: {cwd}"); return; } bool verbose = _consoleArgsReader.ContainsVerboseParam(args); string[] projectFolders = _consoleArgsReader.GetProjectFolders(args).ToArray(); string[] configPaths = _consoleArgsReader.GetConfigPaths(args).ToArray(); for (var i = 0; i < projectFolders.Length; i++) { string projectFolder = projectFolders[i]; string configPath = configPaths.HasIndex(i) ? configPaths[i] : null; _assemblyResolver = new AssemblyResolver(_fileSystem, projectFolder); _logger.Log($"Generating files for project \"{projectFolder}\"..."); Generate(projectFolder, configPath, verbose); _logger.Log($"Files for project \"{projectFolder}\" generated successfully.", ""); } } catch (Exception e) when(e is CliException || e is CoreException) { _logger.Log($"APPLICATION ERROR: {e.Message}", e.StackTrace); } catch (AssemblyResolutionException e) { string message = e.Message + "Consider adding any external assembly directories in the externalAssemblyPaths parameter. " + "If you're using ASP.NET Core, add your NuGet directory to externalAssemblyPaths parameter (you can use global NuGet packages directory alias: \"<global-packages>\")"; _logger.Log(message, e.StackTrace); } catch (ReflectionTypeLoadException e) { foreach (Exception loaderException in e.LoaderExceptions) { _logger.Log($"TYPE LOAD ERROR: {loaderException.Message}", e.StackTrace); } } catch (Exception e) { _logger.Log($"GENERIC ERROR: {e.Message}", e.StackTrace); } }
private static void Main(string[] args) { try { InitializeServices(args); if (args == null || args.Length == 0 || _consoleArgsReader.ContainsHelpOption(args) || _consoleArgsReader.ContainsAnyCommand(args) == false) { ShowHelp(); return; } if (_consoleArgsReader.ContainsGetCwdCommand(args)) { string cwd = _fileSystem.GetCurrentDirectory(); Console.WriteLine($"Current working directory is: {cwd}"); return; } string[] configPaths = _consoleArgsReader.GetConfigPaths(args).ToArray(); string[] projectFolders = _consoleArgsReader.ContainsProjectFolderOption(args) ? _consoleArgsReader.GetProjectFolders(args).ToArray() : new [] { "." }; for (var i = 0; i < projectFolders.Length; i++) { string projectFolder = projectFolders[i]; string configPath = configPaths.HasIndex(i) ? configPaths[i] : null; _assemblyResolver = new AssemblyResolver(_fileSystem, _logger, projectFolder); Generate(projectFolder, configPath); } } catch (Exception e) when(e is CliException || e is CoreException) { _logger.Log($"APPLICATION ERROR: {e.Message}{Environment.NewLine}{e.StackTrace}", LogLevel.Error); } catch (AssemblyResolutionException e) { string message = e.Message + "Consider adding any external assembly directories in the externalAssemblyPaths parameter. " + "If you're using ASP.NET Core, add your NuGet directory to externalAssemblyPaths parameter (you can use global NuGet packages directory alias: \"<global-packages>\")"; _logger.Log($"{message}{Environment.NewLine}{e.StackTrace}", LogLevel.Error); } catch (ReflectionTypeLoadException e) { foreach (Exception loaderException in e.LoaderExceptions) { _logger.Log($"TYPE LOAD ERROR: {loaderException.Message}{Environment.NewLine}{e.StackTrace}", LogLevel.Error); } } catch (Exception e) { _logger.Log($"GENERIC ERROR: {e.Message}{Environment.NewLine}{e.StackTrace}", LogLevel.Error); } }
public void GetProjectFolders_Test(string[] args, IEnumerable <string> expectedResult) { IEnumerable <string> actualResult = _consoleArgsReader.GetProjectFolders(args); Assert.Equal(expectedResult, actualResult); }