public async Task Generate(Preset value) { _logger.LogDebug("Post GenerateProjects"); _keywordReplace.AddKeywords(value.Keywords); _keywordReplace.ReplaceAll(); _logger.LogDebug("Replaced keywords"); /* Copy Project structure from template */ if (!Path.IsPathRooted(value.TemplateOrigin)) { value.TemplateOrigin = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, value.TemplateOrigin); } var templateOriginInfo = new DirectoryInfo(value.TemplateOrigin); if (!templateOriginInfo.Exists) { throw new ArgumentException("Invalid template origin path"); } var copiedFolders = new List <DirectoryInfo>(); var outputFolderPathInfo = new DirectoryInfo(_keywordReplace.Replace(value.OutputFolderPath)); DirectoryCopy(templateOriginInfo.FullName, outputFolderPathInfo.FullName, true, outputFolderPathInfo.FullName, copiedFolders); /* Replace keywords in files matching search pattern */ await ReplaceKeywordsInFiles(value.FileKeywordTypesExtensions, copiedFolders); _logger.LogDebug("Replaced keywords in files"); if (value.AddToSourceControl) { var tfPath = await _appSettingsService.TFPath(); var tf = new TFImpl(tfPath); foreach (var dirInfo in copiedFolders) { /* Add to Source Control */ _logger.LogDebug("Adding project to Source Control"); tf.RunTFCommand(dirInfo.FullName, new[] { "add", "*.*", "/recursive" }); /* Update main solution with new project (Glx/Crm build convention)*/ var buildSolutionDirInfo = dirInfo.Parent.GetDirectories($"Build_*"); if (buildSolutionDirInfo.Length > 0) { var buildSolutionPath = buildSolutionDirInfo[0].GetFiles("*.sln"); if (buildSolutionPath.Length > 0) { _logger.LogDebug("Update main build solution"); tf.RunTFCommand(dirInfo.FullName, new[] { "checkout", buildSolutionPath[0].FullName }); var slnObj = new SolutionParser(buildSolutionPath[0].FullName); slnObj.AddProject(dirInfo.Name); } } } } if (value.AutomationUpdates.UseAutomationUpdates) { _logger.LogDebug("Executing automation toolkit updates"); var handler = new AutomationUpdatesHandler(_logger, value, _keywordReplace); handler.Execute(); } }