private string GetPath() { var mePaths = OptionClass.Instance.MEs.Where(me => File.Exists(me.Path)).ToArray(); foreach (var me in mePaths) { var assembly = Mono.Cecil.AssemblyDefinition.ReadAssembly(me.Path); var versionMatch = assembly.VersionMatch(false); if (versionMatch) { return(me.Path); } } if (!mePaths.Any()) { _dte.WriteToOutput("Use setting to add at least one model editor path for each major version"); return(null); } var versionMissMatchPaths = mePaths.Where(me => File.Exists(me.Path)).Select(me => me.Path).ToArray(); var versionMissMatchMessage = versionMissMatchPaths.Any() ? "Version missmatch for:" + Environment.NewLine + string.Join(Environment.NewLine, versionMissMatchPaths) + Environment.NewLine : null; var fileNotFoundPaths = mePaths.Where(me => !File.Exists(me.Path)).Select(me => me.Path).ToArray(); var fileNotFoundMessage = fileNotFoundPaths.Any() ? "File not found:" + Environment.NewLine + string.Join(Environment.NewLine, fileNotFoundPaths) : null; _dte.WriteToOutput(versionMissMatchMessage + fileNotFoundMessage); return(null); }
private static void LoadProjectsCore() { try{ var uihSolutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object as UIHierarchy; if (uihSolutionExplorer == null || uihSolutionExplorer.UIHierarchyItems.Count == 0) { throw new Exception("Nothing selected"); } object[] objects = uihSolutionExplorer.GetReferences <Reference>( ).Cast <object>().ToArray(); object[] references = objects; if (!objects.Any()) { objects = uihSolutionExplorer.GetReferences <object>( ); if (!objects.Any()) { return; } var projectName = (string)objects.First().GetPropertyValue("Project").GetPropertyValue("Name"); var vsProject = (VSProject)DteExtensions.DTE.Solution.Projects().First(project => project.Name == projectName).Object; references = objects.Select(o => vsProject.References.Cast <object>().First(_ => (string)_.GetPropertyValue("Name") == (string)o.GetPropertyValue("Name"))).ToArray(); } foreach (var reference in references) { var path = Regex.Replace(GetPath(reference), @"(\\{2,})", @"\"); DTE.WriteToOutput($"Looking for ${path}"); var projectInfo = OptionClass.Instance.SourceCodeInfos.SelectMany(info => info.ProjectPaths) .FirstOrDefault( info => string.Equals(Regex.Replace(info.OutputPath, @"(\\{2,})", @"\"), path, StringComparison.CurrentCultureIgnoreCase) && AssemblyDefinition.ReadAssembly(info.OutputPath).VersionMatch()); var name = GetName(reference); if (projectInfo != null) { DTE.WriteToOutput($"{name} found at " + projectInfo.OutputPath); if (DTE.Solution.Projects().All(project => project.FullName != projectInfo.Path)) { var project = DTE.Solution.AddFromFile(Path.GetFullPath(projectInfo.Path)); project.SkipBuild(); project.ChangeActiveConfiguration(); } else { DTE.WriteToOutput(projectInfo.Path + " already loaded"); } } else { DTE.WriteToOutput($"{name} not found "); } } } catch (Exception e) { DTE.WriteToOutput(e.ToString()); } }
private static void ChangeActiveConfiguration(Project project) { var solutionConfigurationNames = DTE.Solution.SolutionBuild.SolutionConfigurations.Cast <SolutionConfiguration>() .OrderByDescending(solutionConfiguration => solutionConfiguration == DTE.Solution.SolutionBuild.ActiveConfiguration). ThenByDescending(solutionConfiguration => string.Equals(solutionConfiguration.Name, "debug", StringComparison.CurrentCultureIgnoreCase)). Select(configuration => configuration.Name).ToArray(); var configurationName = solutionConfigurationNames.First(solutionConfigurationName => project.ConfigurationManager.Cast <Configuration>() .Any(configuration => configuration.ConfigurationName == solutionConfigurationName)); var solutionContext = DTE.Solution.SolutionBuild.ActiveConfiguration.SolutionContexts.Cast <SolutionContext>().First(context => Path.GetFileNameWithoutExtension(context.ProjectName) == project.Name); solutionContext.ConfigurationName = !string.IsNullOrEmpty(OptionClass.Instance.DefaultConfiguration) ? OptionClass.Instance.DefaultConfiguration : configurationName; DTE.WriteToOutput(solutionContext.ConfigurationName + " configuration activated"); }
private static OptionClass GetOptionClass() { var optionClass = new OptionClass(); try { var xmlSerializer = new XmlSerializer(typeof(OptionClass)); using (var stream = File.Open(Path, FileMode.OpenOrCreate)){ using (var streamReader = new StreamReader(stream)){ var allText = streamReader.ReadToEnd(); if (!string.IsNullOrWhiteSpace(allText)) { var xmlReader = XmlReader.Create(new StringReader(allText)); if (xmlSerializer.CanDeserialize(xmlReader)) { optionClass = (OptionClass)xmlSerializer.Deserialize(xmlReader); } } } } } catch (Exception e) { DTE.LogError(e.ToString()); DTE.WriteToOutput(e.ToString()); } return(optionClass); }
private void LoadProject(ProjectItemWrapper projectItemWrapper) { _dte.InitOutputCalls("LoadProject"); try{ if (!File.Exists(projectItemWrapper.FullPath)) { _dte.WriteToOutput($"NOT FOUND {projectItemWrapper.FullPath}"); } var project = DteExtensions.DTE.Solution.AddFromFile(projectItemWrapper.FullPath); project.SkipBuild(); project.ChangeActiveConfiguration(); } catch (Exception e) { _dte.WriteToOutput(e.ToString()); } }
static void Drop() { DTE.InitOutputCalls("Dropdatabase"); Task.Factory.StartNew(() => { var startUpProject = DTE.Solution.FindStartUpProject(); var configItem = startUpProject.ProjectItems.Cast <ProjectItem>() .FirstOrDefault(item => new[] { "app.config", "web.config" }.Contains(item.Name.ToLower())); if (configItem == null) { DTE.WriteToOutput("Startup project " + startUpProject.Name + " does not contain a config file"); return; } foreach (ConnectionString optionsConnectionString in OptionClass.Instance.ConnectionStrings) { if (!string.IsNullOrEmpty(optionsConnectionString.Name)) { var connectionStringSettings = GetConnectionStringSettings(configItem, optionsConnectionString.Name); if (connectionStringSettings != null) { try { if (DbExist(connectionStringSettings)) { DropSqlServerDatabase(connectionStringSettings); } } catch (Exception e) { DTE.WriteToOutput(connectionStringSettings.ConnectionString + Environment.NewLine + e); } } } } DTE.WriteToOutput("Dropdatabase finished"); }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); }
void StartMEProcess(ProjectItemWrapper projectItemWrapper, string outputFileName, string path) { try{ var fullPath = projectItemWrapper.FullPath; string assemblyPath = Path.Combine(fullPath, Path.Combine(projectItemWrapper.OutputPath, outputFileName)); if (!File.Exists(assemblyPath)) { MessageBox.Show($@"Assembly {assemblyPath} not found", null, MessageBoxButtons.OK); return; } var destFileName = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(assemblyPath) + "", Path.GetFileName(path) + "")); KillProcess(destFileName); if (!string.Equals(path, destFileName, StringComparison.OrdinalIgnoreCase)) { File.Copy(path, destFileName, true); var configPath = Path.Combine(Path.GetDirectoryName(path) + "", Path.GetFileName(path) + ".config"); if (File.Exists(configPath)) { _dte.WriteToOutput($"Copying App.config"); File.Copy(configPath, Path.Combine(Path.GetDirectoryName(destFileName) + "", Path.GetFileName(configPath)), true); } } string debugMe = OptionClass.Instance.DebugME ? "d":null; string arguments = String.Format("{0} {4} \"{1}\" \"{3}\" \"{2}\"", debugMe, Path.GetFullPath(assemblyPath), fullPath, projectItemWrapper.LocalPath, projectItemWrapper.IsApplicationProject); if (File.Exists(destFileName)) { try{ _dte.WriteToOutput($"Starting {destFileName} with arguments {arguments}"); Process.Start(destFileName, arguments); } catch (IOException) { MessageBox.Show(@"You have probably open the same model from another ME instance. If not please report this with reproduction details in eXpandFramework bugs forum"); } } else { MessageBox.Show($@"Model editor not found at {destFileName}"); } } catch (Exception e) { MessageBox.Show(e.ToString()); } }
private static void RunTestCore(bool debug) { var lastBuildStatusArgs = new LastBuildStatusArgs(); OnQueryLastBuildStatus(lastBuildStatusArgs); try { DTE.WriteToOutput("Building EasyTest/Debug Configuration"); if (DTE.Solution.BuildSolution()) { var activeFileName = DTE.ActiveDocument.FullName; var testLogPath = Path.Combine(Path.GetDirectoryName(activeFileName) + "", "Testslog.xml"); if (File.Exists(testLogPath)) { File.Delete(testLogPath); } var debugSwitch = WriteToOutput(debug, activeFileName); var testExecutorPath = GetTestExecutorPath(); if (!File.Exists(testExecutorPath)) { throw new FileNotFoundException( "Use plugin options to assign a valid path for the standalond TestExecutor. Or leave it blank for auto detection."); } var processStartInfo = new ProcessStartInfo(testExecutorPath) { Arguments = $@"""{activeFileName}""{debugSwitch}", UseShellExecute = debug, RedirectStandardOutput = !debug, CreateNoWindow = !debug }; var process = System.Diagnostics.Process.Start(processStartInfo); Debug.Assert(process != null, "process != null"); process.WaitForExit(); if (File.Exists(testLogPath)) { var document = XDocument.Load(File.OpenRead(testLogPath)); var errorElement = document.Descendants().FirstOrDefault(element => element.Name.LocalName == "Error"); if (errorElement != null) { var messageElement = errorElement.Descendants("Message").First(); DTE.WriteToOutput(messageElement.Value); } else { DTE.WriteToOutput("EasyTest Passed!"); } } } else { DTE.WriteToOutput("EasyTest build failed"); } } catch (Exception e) { DTE.WriteToOutput(e.ToString()); } }
private void OpenModelEditor(ProjectItemWrapper projectItemWrapper) { _dte.InitOutputCalls("OpenModelEditor"); try{ new ModelEditorRunner().Start(projectItemWrapper); } catch (Exception e) { _dte.WriteToOutput(e.ToString()); } }
private void LoadConfiguration(SolutionConfiguration configuration) { try{ configuration.Configuration.Activate(); SetDataSource(); DTE.InitOutputCalls($"Configuration {configuration.Name} loaded"); } catch (Exception e) { DTE.WriteToOutput(e.ToString()); } }
private IObservable <Unit> OpenModelEditor() { var projectItemWrapper = (ProjectItemWrapper)gridView1.GetRow(gridView1.FocusedRowHandle); _dte.InitOutputCalls("OpenModelEditor"); return(new ModelEditorRunner().Start(projectItemWrapper) .Catch <Unit, Exception>(e => { _dte.WriteToOutput(e.ToString()); return Observable.Empty <Unit>(); })); }
public static void Convert() { _dte.InitOutputCalls("ConvertProject"); string path = GetProjectConverterPath(); string token = OptionClass.Instance.Token; if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(token)) { var directoryName = Path.GetDirectoryName(_dte.Solution.FileName); _dte.WriteToOutput("Project Converter Started !!!"); var userName = $"/sc /k:{token} \"{directoryName}\""; Process.Start(path, userName); } }
public static void InitOutputCalls(this DTE2 dte, string text) { dte.WriteToOutput(Environment.NewLine + "------------------" + text + "------------------" + Environment.NewLine); }