private async Task DoOnSolutionReadyOrChange() { if (!File.Exists(_workspace.CurrentSolution.FilePath)) { LogWarn("Could not find solution."); return; } if (!CurrentSolutionHasBitConfigV1JsonFile()) { LogWarn("Could not find BitConfigV1.json file."); return; } _outputPane.Clear(); DefaultBitConfigProvider configProvider = new DefaultBitConfigProvider(); BitConfig config = null; try { config = configProvider.GetConfiguration(_workspace.CurrentSolution, Enumerable.Empty <Project>().ToList()); foreach (BitCodeGeneratorMapping mapping in config.BitCodeGeneratorConfigs.BitCodeGeneratorMappings) { if (!_workspace.CurrentSolution.Projects.Any(p => p.Name == mapping.DestinationProject.Name && p.Language == LanguageNames.CSharp)) { throw new InvalidOperationException($"No project found named {mapping.DestinationProject.Name}"); } foreach (BitTools.Core.Model.ProjectInfo proj in mapping.SourceProjects) { if (!_workspace.CurrentSolution.Projects.Any(p => p.Name == proj.Name && p.Language == LanguageNames.CSharp)) { throw new InvalidOperationException($"No project found named {proj.Name}"); } } } } catch (Exception ex) { LogException("Parse BitConfigV1.json failed.", ex); return; } try { InitHtmlElements(config); } catch (Exception ex) { LogException("Init html elements failed.", ex); } _shouldGeneratedProjects = new List <Project> { }; generateCodesForTheFirstTimeExecuted = false; thereWasAnErrorInBuild = false; }
private void DoOnSolutionReadyOrChange() { if (!File.Exists(_visualStudioWorkspace.CurrentSolution.FilePath)) { LogWarn("Could not find solution."); return; } if (!WorkspaceHasBitConfigV1JsonFile()) { LogWarn("Could not find BitConfigV1.json file."); return; } if (Environment.Version < new Version("4.0.30319.42000")) { ShowInitialLoadProblem("To develop bit projects, you've to install .NET 4.7.1 Developer Pack"); } _outputPane.Clear(); DefaultBitConfigProvider configProvider = new DefaultBitConfigProvider(); BitConfig config = null; try { config = configProvider.GetConfiguration(_visualStudioWorkspace.CurrentSolution.FilePath); foreach (BitCodeGeneratorMapping mapping in config.BitCodeGeneratorConfigs.BitCodeGeneratorMappings) { if (!_visualStudioWorkspace.CurrentSolution.Projects.Any(p => p.Name == mapping.DestinationProject.Name && p.Language == LanguageNames.CSharp)) { throw new InvalidOperationException($"No project found named {mapping.DestinationProject.Name}"); } foreach (BitTools.Core.Model.ProjectInfo proj in mapping.SourceProjects) { if (!_visualStudioWorkspace.CurrentSolution.Projects.Any(p => p.Name == proj.Name && p.Language == LanguageNames.CSharp)) { throw new InvalidOperationException($"No project found named {proj.Name}"); } } } } catch (Exception ex) { LogException("Parse BitConfigV1.json failed.", ex); return; } try { InitHtmlElements(config); } catch (Exception ex) { LogException("Init html elements failed.", ex); } _shouldGeneratedProjectNames = new List <string> { }; needsFirstTimeGenerateCode = true; lastActionWasClean = false; thereWasAnErrorInLastBuild = false; }
private async System.Threading.Tasks.Task DoOnSolutionReadyOrChange() { if (!File.Exists(_visualStudioWorkspace.CurrentSolution.FilePath)) { LogWarn("Could not find solution."); return; } if (!WorkspaceHasBitConfigV1JsonFile()) { LogWarn("Could not find BitConfigV1.json file."); return; } _outputPane.OutputString("__________----------__________ \n"); DefaultBitConfigProvider configProvider = new DefaultBitConfigProvider(); try { BitConfig config = configProvider.GetConfiguration(_visualStudioWorkspace); foreach (BitCodeGeneratorMapping mapping in config.BitCodeGeneratorConfigs.BitCodeGeneratorMappings) { if (!_visualStudioWorkspace.CurrentSolution.Projects.Any(p => p.Name == mapping.DestinationProject.Name && p.Language == LanguageNames.CSharp)) { LogWarn($"No project found named {mapping.DestinationProject.Name}"); } foreach (BitTools.Core.Model.ProjectInfo proj in mapping.SourceProjects) { if (!_visualStudioWorkspace.CurrentSolution.Projects.Any(p => p.Name == proj.Name && p.Language == LanguageNames.CSharp)) { LogWarn($"No project found named {proj.Name}"); } } } } catch (Exception ex) { LogException("Parse BitConfigV1.json failed.", ex); return; } try { bitWorkspaceIsPrepared = thereWasAnErrorInLastBuild = lastActionWasClean = false; Log("Preparing bit workspace... This includes restoring nuget packages, building your solution and generating codes."); _applicationObject.Solution.SolutionBuild.Build(WaitForBuildToFinish: true); } catch (Exception ex) { LogException("Bit workspace preparation failed", ex); } finally { bitWorkspaceIsPrepared = true; await CallGenerateCodes(); Log("Bit workspace gets prepared", activatePane: true); } }
private async void DoOnSolutionReadyOrChange() { if (!File.Exists(_visualStudioWorkspace.CurrentSolution.FilePath)) { LogWarn("Could not find solution."); return; } if (!WorkspaceHasBitConfigV1JsonFile()) { LogWarn("Could not find BitConfigV1.json file."); return; } _outputPane.Clear(); DefaultBitConfigProvider configProvider = new DefaultBitConfigProvider(); BitConfig config; try { config = configProvider.GetConfiguration(_visualStudioWorkspace.CurrentSolution.FilePath); foreach (BitCodeGeneratorMapping mapping in config.BitCodeGeneratorConfigs.BitCodeGeneratorMappings) { if (!_visualStudioWorkspace.CurrentSolution.Projects.Any(p => p.Name == mapping.DestinationProject.Name && p.Language == LanguageNames.CSharp)) { LogWarn($"No project found named {mapping.DestinationProject.Name}"); } foreach (BitTools.Core.Model.ProjectInfo proj in mapping.SourceProjects) { if (!_visualStudioWorkspace.CurrentSolution.Projects.Any(p => p.Name == proj.Name && p.Language == LanguageNames.CSharp)) { LogWarn($"No project found named {proj.Name}"); } } } } catch (Exception ex) { LogException("Parse BitConfigV1.json failed.", ex); return; } try { InitHtmlElements(config); } catch (Exception ex) { LogException("Init html elements failed.", ex); } try { bitWorkspaceIsPrepared = thereWasAnErrorInLastBuild = lastActionWasClean = false; Log("Preparing bit workspace... This includes restoring nuget packages, building your solution and generating codes."); using (System.Diagnostics.Process dotnetBuildProcess = new System.Diagnostics.Process()) { dotnetBuildProcess.StartInfo.UseShellExecute = false; dotnetBuildProcess.StartInfo.RedirectStandardOutput = true; dotnetBuildProcess.StartInfo.FileName = @"dotnet"; dotnetBuildProcess.StartInfo.Arguments = "build"; dotnetBuildProcess.StartInfo.CreateNoWindow = true; dotnetBuildProcess.StartInfo.WorkingDirectory = Directory.GetParent(_visualStudioWorkspace.CurrentSolution.FilePath).FullName; dotnetBuildProcess.Start(); await dotnetBuildProcess.StandardOutput.ReadToEndAsync(); dotnetBuildProcess.WaitForExit(); } } catch (Exception ex) { LogException("Bit workspace preparation failed", ex); } finally { bitWorkspaceIsPrepared = true; await CallGenerateCodes(); Log("Bit workspace gets prepared", activatePane: true); } }