public IList<ProjectTemplatePackageReference> GetPackageReferences (ProjectCreateInformation projectCreateInformation) { return packageReferences .Where (packageReference => projectCreateInformation.ShouldCreate (packageReference.CreateCondition)) .ToList (); }
public bool ShouldCreateProject (ProjectCreateInformation projectCreateInformation) { return projectCreateInformation.ShouldCreate (createCondition); }
public void InitializeItem (SolutionFolderItem policyParent, ProjectCreateInformation projectCreateInformation, string defaultLanguage, SolutionItem item) { MonoDevelop.Projects.Project project = item as MonoDevelop.Projects.Project; if (project == null) { MessageService.ShowError (GettextCatalog.GetString ("Can't create project with type: {0}", type)); return; } // Set the file before setting the name, to make sure the file extension is kept project.FileName = Path.Combine (projectCreateInformation.ProjectBasePath, projectCreateInformation.ProjectName); project.Name = projectCreateInformation.ProjectName; var dnp = project as DotNetProject; if (dnp != null) { if (policyParent.ParentSolution != null && !policyParent.ParentSolution.FileFormat.SupportsFramework (dnp.TargetFramework)) { SetClosestSupportedTargetFramework (policyParent.ParentSolution.FileFormat, dnp); } var substitution = new string[,] { { "ProjectName", GetProjectNameForSubstitution (projectCreateInformation) } }; foreach (var desc in references) { if (!projectCreateInformation.ShouldCreate (desc.CreateCondition)) continue; var pr = desc.Create (); if (pr.ReferenceType == ReferenceType.Project) { string referencedProjectName = ReplaceParameters (pr.Reference, substitution, projectCreateInformation); var parsedReference = ProjectReference.RenameReference (pr, referencedProjectName); dnp.References.Add (parsedReference); } else dnp.References.Add (pr); } } foreach (SingleFileDescriptionTemplate resourceTemplate in resources) { try { if (!projectCreateInformation.ShouldCreate (resourceTemplate.CreateCondition)) continue; var projectFile = new ProjectFile (resourceTemplate.SaveFile (policyParent, project, defaultLanguage, project.BaseDirectory, null)); projectFile.BuildAction = BuildAction.EmbeddedResource; project.Files.Add (projectFile); } catch (Exception ex) { if (!IdeApp.IsInitialized) throw; MessageService.ShowError (GettextCatalog.GetString ("File {0} could not be written.", resourceTemplate.Name), ex); } } foreach (FileDescriptionTemplate fileTemplate in files) { try { if (!projectCreateInformation.ShouldCreate (fileTemplate.CreateCondition)) continue; fileTemplate.SetProjectTagModel (projectCreateInformation.Parameters); fileTemplate.AddToProject (policyParent, project, defaultLanguage, project.BaseDirectory, null); } catch (Exception ex) { if (!IdeApp.IsInitialized) throw; MessageService.ShowError (GettextCatalog.GetString ("File {0} could not be written.", fileTemplate.Name), ex); } finally { fileTemplate.SetProjectTagModel (null); } } }