private void btnDebug_Click(object sender, RoutedEventArgs e) { ProjectFileInfo file = this._ProjectItem as ProjectFileInfo; if (file == null) { return; } SelectTridionDebugDialogWindow dialog = new SelectTridionDebugDialogWindow(); dialog.TbbTcmId = file.TcmId; dialog.TestItemTcmId = file.TestItemTcmId; dialog.TestTemplateTcmId = file.TestTemplateTcmId; dialog.CurrentMapping = this.CurrentMapping; bool res = dialog.ShowDialog() == true; if (res) { file.TestItemTcmId = dialog.TestItemTcmId; file.TestTemplateTcmId = dialog.TestTemplateTcmId; this.btnDebug.Foreground = new SolidColorBrush(Colors.Green); } }
private void btnDebug_Click(object sender, RoutedEventArgs e) { ProjectFileInfo file = this._ProjectItem as ProjectFileInfo; if (file == null) return; SelectTridionDebugDialogWindow dialog = new SelectTridionDebugDialogWindow(); dialog.TbbTcmId = file.TcmId; dialog.TestItemTcmId = file.TestItemTcmId; dialog.TestTemplateTcmId = file.TestTemplateTcmId; dialog.CurrentMapping = this.CurrentMapping; bool res = dialog.ShowDialog() == true; if (res) { file.TestItemTcmId = dialog.TestItemTcmId; file.TestTemplateTcmId = dialog.TestTemplateTcmId; this.btnDebug.Foreground = new SolidColorBrush(Colors.Green); } }
public static void RunFile(string filePath, Project project, Solution solution) { string rootPath = Path.GetDirectoryName(project.FileName); RootPath = rootPath; Project = project; Configuration configuration = Service.GetConfiguration(rootPath, "TridionRazorMapping.xml"); MappingInfo mapping = configuration.FirstOrDefault(x => x.Name == (configuration.DefaultConfiguration ?? "Default")); if (mapping == null) { MessageBox.Show("Configuration doesn't contain default mapping. Please edit configuration.", "Configuration Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } List<ProjectFileInfo> files = mapping.GetFiles(filePath); List<ProjectFolderInfo> folders = mapping.GetFolders(filePath); if (files == null || files.Count == 0 || folders.Count == 0) { MessageBox.Show("Item '" + filePath + "' is not mapped. Please edit mapping.", "Configuration Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (files.Count > 1 || folders.Count > 1) { MessageBox.Show("Item '" + filePath + "' is mapped to more than one item. Please edit mapping.", "Configuration Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } ProjectFileInfo file = files[0]; file.Parent = folders[0]; if (string.IsNullOrEmpty(file.TestItemTcmId) || string.IsNullOrEmpty(file.TestTemplateTcmId)) { SelectTridionDebugDialogWindow dialog = new SelectTridionDebugDialogWindow(); dialog.TbbTcmId = file.TcmId; dialog.TestItemTcmId = file.TestItemTcmId; dialog.TestTemplateTcmId = file.TestTemplateTcmId; dialog.CurrentMapping = mapping; bool res = dialog.ShowDialog() == true; if (!res) { return; } file.TestItemTcmId = dialog.TestItemTcmId; file.TestTemplateTcmId = dialog.TestTemplateTcmId; SaveConfiguration(rootPath, "TridionRazorMapping.xml", configuration); } string fileName = Path.GetFileNameWithoutExtension(filePath); string testItem = file.TestItemTcmId.Replace("tcm:", ""); string testTemplate = file.TestTemplateTcmId.Replace("tcm:", ""); //set start .cshtml string baseUrl = project.Properties.Item("WebApplication.BrowseURL").Value.ToString().TrimEnd('/'); project.Properties.Item("WebApplication.StartExternalURL").Value = baseUrl + "/"+ fileName + "/"+ testItem + "/" + testTemplate; project.Properties.Item("WebApplication.DebugStartAction").Value = 3; //set start project solution.Properties.Item("StartupProject").Value = project.Name; //run debugger SolutionBuild sb = solution.SolutionBuild; sb.Debug(); }