private void CompileButton_OnClick(object s, RoutedEventArgs e) { string selectedConfiguration = ConfigurationsDropdown.SelectedItem == null ? Config.ProjectFile.Configurations.First() : ConfigurationsDropdown.SelectedItem.ToString(); string selectedPlatform = PlatformsDropdown.SelectedItem == null ? Config.ProjectFile.Platforms.First() : PlatformsDropdown.SelectedItem.ToString(); var bw = new BackgroundWorker(); bw.DoWork += delegate { Application.Current.Dispatcher.Invoke( () => OnProgressStart(CompileButton, CompileLog, () => CompileProgress)); Utility.ClearDirectory(_logDir); if (Directory.Exists(_repositoryDir)) { List <string> projectFiles = GetProjectFiles(); if (!projectFiles.Any()) { Utility.Log(LogStatus.Error, "No *.csproj files found", CompileLog); } Application.Current.Dispatcher.Invoke(() => CompileMaximum = projectFiles.Count()); foreach (string projectFile in projectFiles) { var pf = new ProjectFile(projectFile, CompileLog) { Configuration = selectedConfiguration, PlatformTarget = selectedPlatform, ReferencesPath = Config.Settings.References.NewPath, UpdateReferences = Config.Settings.References.Update, PostbuildEvent = true, PrebuildEvent = true }; pf.Change(); string logFile = Path.Combine(_logDir, Utility.MakeValidFileName(Path.ChangeExtension(pf.Project.FullPath, "txt") .Remove(0, _repositoryDir.Length))); Compiler.Compile(pf.Project, logFile, CompileLog); MoveCompiledFile(Compiler.GetOutputFilePath(pf.Project)); Application.Current.Dispatcher.Invoke(() => CompileProgress++); } } else { Utility.Log(LogStatus.Error, "No *.csproj files found", CompileLog); } }; bw.RunWorkerCompleted += (sender, args) => { ProjectCollection.GlobalProjectCollection.UnloadAllProjects(); OnProgressFinish(CompileButton, "Compile"); }; bw.RunWorkerAsync(); }
private void UpdateFile(FileSystemEventArgs e) { if (!_filterHelper.IsMatch(e.FullPath)) { ProjectFile file = LoadOrCreateFile(e.FullPath); FileContent fileContent = file.Change(e.ChangeType); _repository.Save(file); _repository.Save(fileContent); } }