private BindingRedirectsExecutionResult GenerateBindingRedirects(string appConfigFile, string targetAppConfigFile, params ITaskItem[] suggestedRedirects) { // Create the engine. MockEngine engine = new MockEngine(_output); string outputAppConfig = string.IsNullOrEmpty(targetAppConfigFile) ? _env.ExpectFile(".config").Path : targetAppConfigFile; GenerateBindingRedirects bindingRedirects = new GenerateBindingRedirects { BuildEngine = engine, SuggestedRedirects = suggestedRedirects ?? new ITaskItem[] { }, AppConfigFile = new TaskItem(appConfigFile), OutputAppConfigFile = new TaskItem(outputAppConfig) }; bool executionResult = bindingRedirects.Execute(); return(new BindingRedirectsExecutionResult { ExecuteResult = executionResult, Engine = engine, SourceAppConfigContent = File.ReadAllText(appConfigFile), TargetAppConfigContent = File.ReadAllText(outputAppConfig), TargetAppConfigFilePath = outputAppConfig }); }
private static BindingRedirectsExecutionResult GenerateBindingRedirects(string appConfigFile, params TaskItemMock[] suggestedRedirects) { // Create the engine. MockEngine engine = new MockEngine(); string outputAppConfig = FileUtilities.GetTemporaryFile(); GenerateBindingRedirects bindingRedirects = new GenerateBindingRedirects(); bindingRedirects.BuildEngine = engine; bindingRedirects.SuggestedRedirects = suggestedRedirects ?? new ITaskItem[] { }; bindingRedirects.AppConfigFile = new TaskItem(appConfigFile); bindingRedirects.OutputAppConfigFile = new TaskItem(outputAppConfig); try { bool executionResult = bindingRedirects.Execute(); return(new BindingRedirectsExecutionResult { ExecuteResult = executionResult, Engine = engine, SourceAppConfigContent = File.ReadAllText(appConfigFile), TargetAppConfigContent = File.ReadAllText(outputAppConfig), }); } finally { CleanupNoThrow(bindingRedirects); } }
private static void CleanupNoThrow(GenerateBindingRedirects redirects) { if (redirects.AppConfigFile != null && redirects.AppConfigFile.ItemSpec != null) { FileUtilities.DeleteNoThrow(redirects.AppConfigFile.ItemSpec); } if (redirects.OutputAppConfigFile != null && redirects.OutputAppConfigFile.ItemSpec != null) { FileUtilities.DeleteNoThrow(redirects.OutputAppConfigFile.ItemSpec); } }
private static void CleanupNoThrow(GenerateBindingRedirects redirects) { if (redirects.AppConfigFile != null && redirects.AppConfigFile.ItemSpec != null) { FileUtilities.DeleteNoThrow(redirects.AppConfigFile.ItemSpec); } if (redirects.OutputAppConfigFile != null && redirects.OutputAppConfigFile.ItemSpec != null) { FileUtilities.DeleteNoThrow(redirects.OutputAppConfigFile.ItemSpec); } }
private static BindingRedirectsExecutionResult GenerateBindingRedirects(string appConfigFile, params TaskItemMock[] suggestedRedirects) { // Create the engine. MockEngine engine = new MockEngine(); string outputAppConfig = FileUtilities.GetTemporaryFile(); GenerateBindingRedirects bindingRedirects = new GenerateBindingRedirects(); bindingRedirects.BuildEngine = engine; bindingRedirects.SuggestedRedirects = suggestedRedirects ?? new ITaskItem[] { }; bindingRedirects.AppConfigFile = new TaskItem(appConfigFile); bindingRedirects.OutputAppConfigFile = new TaskItem(outputAppConfig); try { bool executionResult = bindingRedirects.Execute(); return new BindingRedirectsExecutionResult { ExecuteResult = executionResult, Engine = engine, SourceAppConfigContent = File.ReadAllText(appConfigFile), TargetAppConfigContent = File.ReadAllText(outputAppConfig), }; } finally { CleanupNoThrow(bindingRedirects); } }