void GetOwnerSolutionItem(UnitTest t, out IConfigurationTarget c, out string path) { if (OwnerSolutionItem is SolutionEntityItem) { c = OwnerSolutionItem as SolutionEntityItem; path = ""; } else if (parent != null) { parent.GetOwnerSolutionItem(t, out c, out path); if (c == null) { return; } if (path.Length > 0) { path += "/" + t.Name; } else { path = t.Name; } } else { c = null; path = null; } }
public NewConfigurationDialog(IConfigurationTarget item, ItemConfigurationCollection <ItemConfiguration> configurations) { this.Build(); this.configurations = configurations; HashSet <string> configs = new HashSet <string> (); HashSet <string> platforms = new HashSet <string> (); foreach (ItemConfiguration conf in configurations) { if (configs.Add(conf.Name)) { comboName.AppendText(conf.Name); } string plat = MultiConfigItemOptionsPanel.GetPlatformName(conf.Platform); if (platforms.Add(plat)) { comboPlatform.AppendText(plat); } } comboPlatform.Entry.Text = MultiConfigItemOptionsPanel.GetPlatformName(""); if (!(item is Solution)) { createChildrenCheck.Active = false; createChildrenCheck.Visible = false; DefaultHeight = 0; } }
public override ItemConfiguration GetConfiguration(IConfigurationTarget target) { ItemConfiguration sconf; if (target is SolutionEntityItem) { // Get the mapped configuration SolutionEntityItem item = (SolutionEntityItem)target; if (item.ParentSolution != null) { SolutionConfiguration config = item.ParentSolution.Configurations [Id]; if (config != null) { string mc = config.GetMappedConfiguration(item); if (mc != null) { sconf = item.Configurations [mc]; if (sconf != null) { return(sconf); } } } } } return(target.Configurations [Id]); }
public static ItemConfiguration CloneConfiguration(this IConfigurationTarget target, ItemConfiguration configuration, string newId) { var clone = target.CreateConfiguration(newId, ConfigurationKind.Blank); clone.CopyFrom(configuration); return(clone); }
public static void UnBind(this IConfigurationTarget target, IConfigurationObject configObject, string configProp) { if (target.Monitor != null) { var observer = target.Monitor.GetObserver(configObject); observer.UnregisterHandler(configProp); } }
public static void Bind(this IConfigurationTarget target, IConfigurationObject configObject, string configProp, Action <IConfigurationObject> handler) { if (target.Monitor != null) { var observer = target.Monitor.GetObserver(configObject); observer.RegisterHandler(configProp, handler); } }
public MultiConfigItemOptionsDialog (Gtk.Window parentWindow, object dataObject): base (parentWindow, dataObject) { IConfigurationTarget ct = DataObject as IConfigurationTarget; if (ct == null) throw new System.InvalidOperationException ("MultiConfigItemOptionsDialog can only be used for SolutionEntityItem and Solution objects. Invalid data object: " + DataObject); if (ct.DefaultConfiguration != null) { currentConfig = ct.DefaultConfiguration.Name; currentPlatform = ct.DefaultConfiguration.Platform; } }
public ConfigurationData FindConfigurationData (IConfigurationTarget item) { if (this.entry == item) return this; foreach (ConfigurationData data in children) { ConfigurationData ret = data.FindConfigurationData (item); if (ret != null) return ret; } return null; }
public override ItemConfiguration GetConfiguration(IConfigurationTarget target) { var original = configuration.GetConfiguration(target); if (original is DotNetProjectConfiguration itemConfiguration) { return(itemConfiguration.GetConfiguration(framework)); } return(original); }
internal static ConfigurationData Build (IConfigurationTarget entry) { ConfigurationData data = new ConfigurationData (entry); foreach (ItemConfiguration conf in entry.Configurations) { ItemConfiguration copy = (ItemConfiguration) conf.Clone (); data.Configurations.Add (copy); } if (entry is Solution) { foreach (SolutionItem e in ((Solution)entry).Items) { if (e is SolutionEntityItem) data.children.Add (ConfigurationData.Build ((SolutionEntityItem) e)); } } return data; }
public ConfigurationData FindConfigurationData(IConfigurationTarget item) { if (this.entry == item) { return(this); } foreach (ConfigurationData data in children) { ConfigurationData ret = data.FindConfigurationData(item); if (ret != null) { return(ret); } } return(null); }
protected override void Update(CommandArrayInfo info) { IConfigurationTarget ce = IdeApp.ProjectOperations.CurrentSelectedBuildTarget as IConfigurationTarget; if (ce != null) { ItemConfiguration conf = ce.DefaultConfiguration; if (conf != null) { foreach (CustomCommand cmd in conf.CustomCommands) { if (cmd.Type == CustomCommandType.Custom) { info.Add(cmd.Name, cmd); } } } } }
public override ItemConfiguration GetConfiguration (IConfigurationTarget target) { ItemConfiguration sconf; if (target is SolutionEntityItem) { // Get the mapped configuration SolutionEntityItem item = (SolutionEntityItem) target; if (item.ParentSolution != null) { SolutionConfiguration config = item.ParentSolution.Configurations [Id]; if (config != null) { string mc = config.GetMappedConfiguration (item); if (mc != null) { sconf = item.Configurations [mc]; if (sconf != null) return sconf; } } } } return target.Configurations [Id]; }
public NewConfigurationDialog (IConfigurationTarget item, ItemConfigurationCollection<ItemConfiguration> configurations) { this.Build(); this.configurations = configurations; HashSet<string> configs = new HashSet<string> (); HashSet<string> platforms = new HashSet<string> (); foreach (ItemConfiguration conf in configurations) { if (configs.Add (conf.Name)) comboName.AppendText (conf.Name); string plat = MultiConfigItemOptionsPanel.GetPlatformName (conf.Platform); if (platforms.Add (plat)) comboPlatform.AppendText (plat); } comboPlatform.Entry.Text = MultiConfigItemOptionsPanel.GetPlatformName (""); if (!(item is Solution)) { createChildrenCheck.Active = false; createChildrenCheck.Visible = false; DefaultHeight = 0; } }
internal static ConfigurationData Build(IConfigurationTarget entry) { ConfigurationData data = new ConfigurationData(entry); foreach (ItemConfiguration conf in entry.Configurations) { ItemConfiguration copy = entry.CloneConfiguration(conf, conf.Id); data.Configurations.Add(copy); } if (entry is Solution) { foreach (SolutionFolderItem e in ((Solution)entry).Items) { if (e is SolutionItem) { data.children.Add(Build((SolutionItem)e)); } } } return(data); }
public WorkspaceItemCreatedInformation CreateEntry(ProjectCreateInformation projectCreateInformation, string defaultLanguage) { WorkspaceItem workspaceItem = null; if (string.IsNullOrEmpty(type)) { workspaceItem = new Solution(); } else { Type workspaceItemType = addin.GetType(type, false); if (workspaceItemType != null) { workspaceItem = Activator.CreateInstance(workspaceItemType) as WorkspaceItem; } if (workspaceItem == null) { MessageService.ShowError(GettextCatalog.GetString("Can't create solution with type: {0}", type)); return(null); } } var substitution = new string[, ] { { "ProjectName", projectCreateInformation.SolutionName } }; workspaceItem.Name = StringParserService.Parse(name, substitution); string newStartupProjectName = startupProject; if (newStartupProjectName != null) { newStartupProjectName = StringParserService.Parse(startupProject, substitution); } workspaceItem.SetLocation(projectCreateInformation.SolutionPath, workspaceItem.Name); ProjectCreateInformation localProjectCI; if (!string.IsNullOrEmpty(directory) && directory != ".") { localProjectCI = new ProjectCreateInformation(projectCreateInformation); localProjectCI.SolutionPath = Path.Combine(localProjectCI.SolutionPath, directory); localProjectCI.ProjectBasePath = Path.Combine(localProjectCI.ProjectBasePath, directory); if (!Directory.Exists(localProjectCI.SolutionPath)) { Directory.CreateDirectory(localProjectCI.SolutionPath); } if (!Directory.Exists(localProjectCI.ProjectBasePath)) { Directory.CreateDirectory(localProjectCI.ProjectBasePath); } } else { localProjectCI = projectCreateInformation; } var workspaceItemCreatedInfo = new WorkspaceItemCreatedInformation(workspaceItem); Solution solution = workspaceItem as Solution; if (solution != null) { for (int i = 0; i < entryDescriptors.Count; i++) { ProjectCreateInformation entryProjectCI; var entry = entryDescriptors[i] as ICustomProjectCIEntry; if (entry != null) { entryProjectCI = entry.CreateProjectCI(localProjectCI); } else { entryProjectCI = localProjectCI; } var solutionItemDesc = entryDescriptors[i]; SolutionEntityItem info = solutionItemDesc.CreateItem(entryProjectCI, defaultLanguage); if (info == null) { continue; } solutionItemDesc.InitializeItem(solution.RootFolder, entryProjectCI, defaultLanguage, info); IConfigurationTarget configurationTarget = info as IConfigurationTarget; if (configurationTarget != null) { foreach (ItemConfiguration configuration in configurationTarget.Configurations) { bool flag = false; foreach (SolutionConfiguration solutionCollection in solution.Configurations) { if (solutionCollection.Id == configuration.Id) { flag = true; } } if (!flag) { solution.AddConfiguration(configuration.Id, true); } } } if ((info is Project) && (solutionItemDesc is ProjectDescriptor)) { workspaceItemCreatedInfo.AddPackageReferenceForCreatedProject((Project)info, (ProjectDescriptor)solutionItemDesc); } solution.RootFolder.Items.Add(info); if (newStartupProjectName == info.Name) { solution.StartupItem = info; } } } if (!workspaceItem.FileFormat.CanWrite(workspaceItem)) { // The default format can't write solutions of this type. Find a compatible format. FileFormat f = IdeApp.Services.ProjectService.FileFormats.GetFileFormatsForObject(workspaceItem).First(); workspaceItem.ConvertToFormat(f, true); } return(workspaceItemCreatedInfo); }
public int Run(string[] arguments) { Console.WriteLine("MonoDevelop Build Tool"); foreach (string s in arguments) { ReadArgument(s); } if (help) { Console.WriteLine("build [options] [build-file]"); Console.WriteLine("-p --project:PROJECT Name of the project to build."); Console.WriteLine("-t --target:TARGET Name of the target: Build or Clean."); Console.WriteLine("-c --configuration:CONFIGURATION Name of the solution configuration to build."); Console.WriteLine(); Console.WriteLine("Supported targets:"); Console.WriteLine(" {0}: build the project (the default target).", ProjectService.BuildTarget); Console.WriteLine(" {0}: clean the project.", ProjectService.CleanTarget); Console.WriteLine(); return(0); } string solFile = null; string itemFile = null; if (file == null) { string[] files = Directory.GetFiles("."); foreach (string f in files) { if (Services.ProjectService.IsWorkspaceItemFile(f)) { solFile = f; break; } else if (itemFile == null && Services.ProjectService.IsSolutionItemFile(f)) { itemFile = f; } } if (solFile == null && itemFile == null) { Console.WriteLine("Project file not found."); return(1); } } else { if (Services.ProjectService.IsWorkspaceItemFile(file)) { solFile = file; } else if (Services.ProjectService.IsSolutionItemFile(file)) { itemFile = file; } else { Console.WriteLine("File '{0}' is not a project or solution.", file); return(1); } } ConsoleProgressMonitor monitor = new ConsoleProgressMonitor(); IBuildTarget item; if (solFile != null) { item = Services.ProjectService.ReadWorkspaceItem(monitor, solFile); } else { item = Services.ProjectService.ReadSolutionItem(monitor, itemFile); } if (project != null) { Solution solution = item as Solution; item = null; if (solution != null) { item = solution.FindProjectByName(project); } if (item == null) { Console.WriteLine("The project '" + project + "' could not be found in " + file); return(1); } } IConfigurationTarget configTarget = item as IConfigurationTarget; if (config == null && configTarget != null) { config = configTarget.DefaultConfigurationId; } ConfigurationSelector configuration; if (item is SolutionEntityItem) { configuration = new ItemConfigurationSelector(config); } else { configuration = new SolutionConfigurationSelector(config); } monitor = new ConsoleProgressMonitor(); BuildResult res = item.RunTarget(monitor, command, configuration); return((res == null || res.ErrorCount == 0) ? 0 : 1); }
/// <summary> /// Gets the configuration selected by this instance for a given target /// </summary> /// <returns> /// The configuration. /// </returns> /// <param name='target'> /// A target /// </param> public virtual ItemConfiguration GetConfiguration (IConfigurationTarget target) { return null; }
public WorkspaceItem CreateEntry(ProjectCreateInformation projectCreateInformation, string defaultLanguage) { WorkspaceItem workspaceItem = null; if (string.IsNullOrEmpty(type)) { workspaceItem = new Solution(); } else { Type workspaceItemType = addin.GetType(type, false); if (workspaceItemType != null) { workspaceItem = Activator.CreateInstance(workspaceItemType) as WorkspaceItem; } if (workspaceItem == null) { MessageService.ShowError(GettextCatalog.GetString("Can't create solution with type: {0}", type)); return(null); } } workspaceItem.Name = StringParserService.Parse(name, new string[, ] { { "ProjectName", projectCreateInformation.SolutionName } }); workspaceItem.SetLocation(projectCreateInformation.SolutionPath, workspaceItem.Name); ProjectCreateInformation localProjectCI; if (!string.IsNullOrEmpty(directory) && directory != ".") { localProjectCI = new ProjectCreateInformation(projectCreateInformation); localProjectCI.SolutionPath = Path.Combine(localProjectCI.SolutionPath, directory); localProjectCI.ProjectBasePath = Path.Combine(localProjectCI.ProjectBasePath, directory); if (!Directory.Exists(localProjectCI.SolutionPath)) { Directory.CreateDirectory(localProjectCI.SolutionPath); } if (!Directory.Exists(localProjectCI.ProjectBasePath)) { Directory.CreateDirectory(localProjectCI.ProjectBasePath); } } else { localProjectCI = projectCreateInformation; } Solution solution = workspaceItem as Solution; if (solution != null) { for (int i = 0; i < entryDescriptors.Count; i++) { ISolutionItemDescriptor solutionItem = entryDescriptors[i]; SolutionEntityItem info = solutionItem.CreateItem(localProjectCI, defaultLanguage); entryDescriptors[i].InitializeItem(solution.RootFolder, localProjectCI, defaultLanguage, info); IConfigurationTarget configurationTarget = info as IConfigurationTarget; if (configurationTarget != null) { foreach (ItemConfiguration configuration in configurationTarget.Configurations) { bool flag = false; foreach (SolutionConfiguration solutionCollection in solution.Configurations) { if (solutionCollection.Id == configuration.Id) { flag = true; } } if (!flag) { solution.AddConfiguration(configuration.Id, true); } } } solution.RootFolder.Items.Add(info); if (startupProject == info.Name) { solution.StartupItem = info; } } } return(workspaceItem); }
public int Run(string[] arguments) { Console.WriteLine(BrandingService.BrandApplicationName("MonoDevelop Build Tool")); foreach (string s in arguments) { ReadArgument(s); } if (help) { Console.WriteLine("build [options] [build-file]"); Console.WriteLine("-p --project:PROJECT Name of the project to build."); Console.WriteLine("-t --target:TARGET Name of the target: Build or Clean."); Console.WriteLine("-c --configuration:CONFIGURATION Name of the solution configuration to build."); Console.WriteLine("-r --runtime:PREFIX Prefix of the Mono runtime to build against."); Console.WriteLine(); Console.WriteLine("Supported targets:"); Console.WriteLine(" {0}: build the project (the default target).", ProjectService.BuildTarget); Console.WriteLine(" {0}: clean the project.", ProjectService.CleanTarget); Console.WriteLine(); return(0); } string solFile = null; string itemFile = null; if (file == null) { string[] files = Directory.GetFiles("."); foreach (string f in files) { if (Services.ProjectService.IsWorkspaceItemFile(f)) { solFile = f; break; } else if (itemFile == null && Services.ProjectService.IsSolutionItemFile(f)) { itemFile = f; } } if (solFile == null && itemFile == null) { Console.WriteLine("Project file not found."); return(1); } } else { if (Services.ProjectService.IsWorkspaceItemFile(file)) { solFile = file; } else if (Services.ProjectService.IsSolutionItemFile(file)) { itemFile = file; } else { Console.WriteLine("File '{0}' is not a project or solution.", file); return(1); } } IProgressMonitor monitor = new ConsoleProjectLoadProgressMonitor(new ConsoleProgressMonitor()); TargetRuntime targetRuntime = null; TargetRuntime defaultRuntime = Runtime.SystemAssemblyService.DefaultRuntime; if (runtime != null) { targetRuntime = MonoTargetRuntimeFactory.RegisterRuntime(new MonoRuntimeInfo(runtime)); if (targetRuntime != null) { Runtime.SystemAssemblyService.DefaultRuntime = targetRuntime; } } IBuildTarget item; if (solFile != null) { item = Services.ProjectService.ReadWorkspaceItem(monitor, solFile); } else { item = Services.ProjectService.ReadSolutionItem(monitor, itemFile); } using (var readItem = item) { if (project != null) { Solution solution = item as Solution; item = null; if (solution != null) { item = solution.FindProjectByName(project); } if (item == null) { Console.WriteLine("The project '" + project + "' could not be found in " + file); return(1); } } IConfigurationTarget configTarget = item as IConfigurationTarget; if (config == null && configTarget != null) { config = configTarget.DefaultConfigurationId; } monitor = new ConsoleProgressMonitor(); BuildResult res = null; if (item is SolutionEntityItem && ((SolutionEntityItem)item).ParentSolution == null) { ConfigurationSelector configuration = new ItemConfigurationSelector(config); res = item.RunTarget(monitor, command, configuration); } else { ConfigurationSelector configuration = new SolutionConfigurationSelector(config); SolutionEntityItem solutionEntityItem = item as SolutionEntityItem; if (solutionEntityItem != null) { if (command == ProjectService.BuildTarget) { res = solutionEntityItem.Build(monitor, configuration, true); } else if (command == ProjectService.CleanTarget) { solutionEntityItem.Clean(monitor, configuration); } else { res = item.RunTarget(monitor, command, configuration); } } else { res = item.RunTarget(monitor, command, configuration); } } if (targetRuntime != null) { Runtime.SystemAssemblyService.DefaultRuntime = defaultRuntime; MonoTargetRuntimeFactory.UnregisterRuntime((MonoTargetRuntime)targetRuntime); } if (res != null) { foreach (var err in res.Errors) { Console.Error.WriteLine(err); } } return((res == null || res.ErrorCount == 0) ? 0 : 1); } }
internal ConfigurationData(IConfigurationTarget obj) { this.entry = obj; }
public async Task <ProcessedTemplateResult> ProcessTemplate(SolutionTemplate template, NewProjectConfiguration config, SolutionFolder parentFolder) { var solutionTemplate = (MicrosoftTemplateEngineSolutionTemplate)template; var parameters = GetParameters(solutionTemplate, config); var templateInfo = solutionTemplate.templateInfo; var workspaceItems = new List <IWorkspaceFileObject> (); var filesBeforeCreation = Directory.GetFiles(config.ProjectLocation, "*", SearchOption.AllDirectories); var result = await MicrosoftTemplateEngine.InstantiateAsync(templateInfo, config, parameters); if (result.Status != CreationResultStatus.Success) { string message = string.Format("Could not create template. Id='{0}' {1} {2}", template.Id, result.Status, result.Message); throw new InvalidOperationException(message); } var filesToOpen = new List <string> (); foreach (var postAction in result.ResultInfo.PostActions) { switch (postAction.ActionId.ToString().ToUpper()) { case "84C0DA21-51C8-4541-9940-6CA19AF04EE6": if (postAction.Args.TryGetValue("files", out var files)) { foreach (var fi in files.Split(';')) { if (int.TryParse(fi.Trim(), out var i)) { filesToOpen.Add(Path.Combine(config.ProjectLocation, GetPath(result.ResultInfo.PrimaryOutputs [i]))); } } } break; case "D396686C-DE0E-4DE6-906D-291CD29FC5DE": //TODO: Load project files break; } } //TODO: Once templates support "D396686C-DE0E-4DE6-906D-291CD29FC5DE" use that to load projects foreach (var path in result.ResultInfo.PrimaryOutputs) { var fullPath = Path.Combine(config.ProjectLocation, GetPath(path)); if (Services.ProjectService.IsSolutionItemFile(fullPath)) { workspaceItems.Add(await MonoDevelop.Projects.Services.ProjectService.ReadSolutionItem(new Core.ProgressMonitor(), fullPath)); } } var metadata = new TemplateMetadata { Id = templateInfo.Identity, Name = templateInfo.Name, Language = template.Language, Platform = string.Join(";", templateInfo.Classifications) }; TemplateCounter.Inc(1, null, metadata); MicrosoftTemplateEngineProcessedTemplateResult processResult; if (parentFolder == null) { var solution = new Solution(); solution.SetLocation(config.SolutionLocation, config.SolutionName); foreach (var item in workspaceItems.Cast <SolutionFolderItem> ()) { IConfigurationTarget configurationTarget = item as IConfigurationTarget; if (configurationTarget != null) { foreach (ItemConfiguration configuration in configurationTarget.Configurations) { bool flag = false; foreach (SolutionConfiguration solutionCollection in solution.Configurations) { if (solutionCollection.Id == configuration.Id) { flag = true; } } if (!flag) { solution.AddConfiguration(configuration.Id, true); } } } solution.RootFolder.AddItem(item); } processResult = new MicrosoftTemplateEngineProcessedTemplateResult(new [] { solution }, solution.FileName, config.ProjectLocation); } else { processResult = new MicrosoftTemplateEngineProcessedTemplateResult(workspaceItems.ToArray(), parentFolder.ParentSolution.FileName, config.ProjectLocation); } // Format all source files generated during the project creation foreach (var p in workspaceItems.OfType <Project> ()) { foreach (var file in p.Files) { if (!filesBeforeCreation.Contains((string)file.FilePath, FilePath.PathComparer)) //Format only newly created files { if (solutionTemplate.ShouldFormatFile(file.FilePath)) { await MicrosoftTemplateEngine.FormatFile(parentFolder?.Policies ?? p.Policies, file.FilePath); } } } } processResult.SetFilesToOpen(filesToOpen); return(processResult); }
public static void UnBind <T>(this IConfigurationTarget target, IConfigurationObject configObject, Expression <Func <T, object> > sourceProp) { string configProp = sourceProp.GetMemberInfo().Name; UnBind(target, configObject, configProp); }
public override ItemConfiguration GetConfiguration (IConfigurationTarget target) { return target.Configurations [Id]; }
public override ItemConfiguration GetConfiguration (IConfigurationTarget target) { return target.DefaultConfiguration; }
/// <summary> /// Gets the configuration selected by this instance for a given target /// </summary> /// <returns> /// The configuration. /// </returns> /// <param name='target'> /// A target /// </param> public virtual ItemConfiguration GetConfiguration(IConfigurationTarget target) { return(null); }
public async Task <ProcessedTemplateResult> ProcessTemplate(SolutionTemplate template, NewProjectConfiguration config, SolutionFolder parentFolder) { var templateInfo = ((MicrosoftTemplateEngineSolutionTemplate)template).templateInfo; var workspaceItems = new List <IWorkspaceFileObject> (); var result = await templateCreator.InstantiateAsync( templateInfo, config.ProjectName, config.GetValidProjectName(), config.ProjectLocation, new Dictionary <string, string> (), true, false); if (result.ResultInfo.PrimaryOutputs.Any()) { foreach (var res in result.ResultInfo.PrimaryOutputs) { var fullPath = Path.Combine(config.ProjectLocation, res.Path); //This happens if some project is excluded by modifiers, e.g. Test project disabled in wizard settings by user if (!File.Exists(fullPath)) { continue; } workspaceItems.Add(await MonoDevelop.Projects.Services.ProjectService.ReadSolutionItem(new Core.ProgressMonitor(), fullPath)); } } else { //TODO: Remove this code once https://github.com/dotnet/templating/pull/342 is released in NuGet feed and we bump NuGet version of templating engine foreach (var path in Directory.GetFiles(config.ProjectLocation, "*.*proj", SearchOption.AllDirectories)) { if (path.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase) || path.EndsWith(".fsproj", StringComparison.OrdinalIgnoreCase) || path.EndsWith(".vbproj", StringComparison.OrdinalIgnoreCase)) { workspaceItems.Add(await MonoDevelop.Projects.Services.ProjectService.ReadSolutionItem(new Core.ProgressMonitor(), path)); } } } var metadata = new Dictionary <string, string> (); metadata ["Id"] = templateInfo.Identity; metadata ["Name"] = templateInfo.Name; metadata ["Language"] = template.Language; metadata ["Platform"] = string.Join(";", templateInfo.Classifications); TemplateCounter.Inc(1, null, metadata); if (parentFolder == null) { var solution = new Solution(); solution.SetLocation(config.SolutionLocation, config.SolutionName); foreach (var item in workspaceItems.Cast <SolutionFolderItem> ()) { IConfigurationTarget configurationTarget = item as IConfigurationTarget; if (configurationTarget != null) { foreach (ItemConfiguration configuration in configurationTarget.Configurations) { bool flag = false; foreach (SolutionConfiguration solutionCollection in solution.Configurations) { if (solutionCollection.Id == configuration.Id) { flag = true; } } if (!flag) { solution.AddConfiguration(configuration.Id, true); } } } solution.RootFolder.AddItem(item); } return(new MicrosoftTemplateEngineProcessedTemplateResult(new [] { solution }, solution.FileName, config.ProjectLocation)); } else { return(new MicrosoftTemplateEngineProcessedTemplateResult(workspaceItems.ToArray(), parentFolder.ParentSolution.FileName, config.ProjectLocation)); } }
public override ItemConfiguration GetConfiguration(IConfigurationTarget target) { return(target.Configurations [Id]); }
public override ItemConfiguration GetConfiguration(IConfigurationTarget target) { return(target.DefaultConfiguration); }
void GetOwnerSolutionItem (UnitTest t, out IConfigurationTarget c, out string path) { if (OwnerSolutionItem is SolutionEntityItem) { c = OwnerSolutionItem as SolutionEntityItem; path = ""; } else if (parent != null) { parent.GetOwnerSolutionItem (t, out c, out path); if (c == null) return; if (path.Length > 0) path += "/" + t.Name; else path = t.Name; } else { c = null; path = null; } }
internal ConfigurationData (IConfigurationTarget obj) { this.entry = obj; }
public async Task <ProcessedTemplateResult> ProcessTemplate(SolutionTemplate template, NewProjectConfiguration config, SolutionFolder parentFolder) { var solutionTemplate = (MicrosoftTemplateEngineSolutionTemplate)template; var parameters = GetParameters(solutionTemplate, config); var templateInfo = solutionTemplate.templateInfo; var workspaceItems = new List <IWorkspaceFileObject> (); var result = await templateCreator.InstantiateAsync( templateInfo, config.ProjectName, config.GetValidProjectName(), config.ProjectLocation, parameters, true, false, null ); var filesToOpen = new List <string> (); foreach (var postAction in result.ResultInfo.PostActions) { switch (postAction.ActionId.ToString().ToUpper()) { case "84C0DA21-51C8-4541-9940-6CA19AF04EE6": if (postAction.Args.TryGetValue("files", out var files)) { foreach (var fi in files.Split(';')) { if (int.TryParse(fi.Trim(), out var i)) { filesToOpen.Add(Path.Combine(config.ProjectLocation, result.ResultInfo.PrimaryOutputs [i].Path)); } } } break; case "D396686C-DE0E-4DE6-906D-291CD29FC5DE": //TODO: Load project files break; } } //TODO: Once templates support "D396686C-DE0E-4DE6-906D-291CD29FC5DE" use that to load projects foreach (var path in Directory.GetFiles(config.ProjectLocation, "*.*proj", SearchOption.AllDirectories)) { if (path.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase) || path.EndsWith(".fsproj", StringComparison.OrdinalIgnoreCase) || path.EndsWith(".vbproj", StringComparison.OrdinalIgnoreCase)) { workspaceItems.Add(await MonoDevelop.Projects.Services.ProjectService.ReadSolutionItem(new Core.ProgressMonitor(), path)); } } var metadata = new Dictionary <string, string> (); metadata ["Id"] = templateInfo.Identity; metadata ["Name"] = templateInfo.Name; metadata ["Language"] = template.Language; metadata ["Platform"] = string.Join(";", templateInfo.Classifications); TemplateCounter.Inc(1, null, metadata); MicrosoftTemplateEngineProcessedTemplateResult processResult; if (parentFolder == null) { var solution = new Solution(); solution.SetLocation(config.SolutionLocation, config.SolutionName); foreach (var item in workspaceItems.Cast <SolutionFolderItem> ()) { IConfigurationTarget configurationTarget = item as IConfigurationTarget; if (configurationTarget != null) { foreach (ItemConfiguration configuration in configurationTarget.Configurations) { bool flag = false; foreach (SolutionConfiguration solutionCollection in solution.Configurations) { if (solutionCollection.Id == configuration.Id) { flag = true; } } if (!flag) { solution.AddConfiguration(configuration.Id, true); } } } solution.RootFolder.AddItem(item); } processResult = new MicrosoftTemplateEngineProcessedTemplateResult(new [] { solution }, solution.FileName, config.ProjectLocation); } else { processResult = new MicrosoftTemplateEngineProcessedTemplateResult(workspaceItems.ToArray(), parentFolder.ParentSolution.FileName, config.ProjectLocation); } // Format all source files generated during the project creation foreach (var p in workspaceItems.OfType <Project> ()) { foreach (var file in p.Files) { await FormatFile(p, file.FilePath); } } processResult.SetFilesToOpen(filesToOpen); return(processResult); }