Defines the ProjectTemplateInfo type.
Inheritance: BaseTemplateInfo
コード例 #1
0
 /// <summary>
 /// Adds the project if.
 /// </summary>
 /// <param name="condition">if set to <c>true</c> [condition].</param>
 /// <param name="projectTemplateInfo">The project template information.</param>
 protected void AddProjectIf(
     bool condition,
     ProjectTemplateInfo projectTemplateInfo)
 {
     if (condition)
     {
         this.ProjectTemplateInfos.Add(projectTemplateInfo);
     }
 }
コード例 #2
0
        public void TestGetRequiredTemplate()
        {
            ProjectTemplateInfo templateInfo = new ProjectTemplateInfo();
            templateInfo.NugetCommands = new List<string> { "testCommand" };

            this.presenter.GetRequiredTemplate("projectName", templateInfo);

            string command = templateInfo.NugetCommands[0];

            Assert.IsTrue(command == "testCommand projectName");
        }
コード例 #3
0
        /// <summary>
        /// Translates the specified from.
        /// </summary>
        /// <param name="from">From.</param>
        /// <returns>A ProjectTemplateInfo.</returns>
        public ProjectTemplateInfo Translate(XElement from)
        {
            string projectName = from.GetSafeAttributeStringValue("Name");

            ProjectTemplateInfo projectTemplateInfo = new ProjectTemplateInfo
            {
                Name = projectName,
                ItemTemplates = this.GetTextTemplates(projectName, projectName, from)
            };

            return projectTemplateInfo;
        }
コード例 #4
0
        /// <summary>
        /// Adds the project.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="projectInfo">The project info.</param>
        internal void TryToAddProject(
            string path,
            ProjectTemplateInfo projectInfo)
        {
            TraceService.WriteLine("ProjectsService::TryToAddProject  project=" + projectInfo.Name);

            //// Project may actually already exist - if so just skip it!

            string projectPath = $@"{path}\{projectInfo.Name}\";

            if (this.FileSystem.Directory.Exists(projectPath) == false)
            {
                TraceService.WriteDebugLine(projectInfo.Name + " " + projectPath + " added to the solution.");

                this.AddProject(projectInfo, projectPath);
            }
            else
            {
                TraceService.WriteError("Directory " + projectPath + " not empty");
            }
        }
コード例 #5
0
        /// <summary>
        /// Adds the project.
        /// </summary>
        /// <param name="projectInfo">The project info.</param>
        /// <param name="projectPath">The project path.</param>
        internal void AddProject(
            ProjectTemplateInfo projectInfo,
            string projectPath)
        {
            TraceService.WriteLine("ProjectsService::AddProject projectPath=" + projectPath + "templateName = " + projectInfo.TemplateName);

            try
            {
                string template = this.visualStudioService.SolutionService.GetProjectTemplate(projectInfo.TemplateName);

                TraceService.WriteLine("Template=" + template);

                //// add to TestProjects subfolder if applicable,
                if (this.SettingsService.CreateTestProjectsSolutionFolder && projectInfo.Name.EndsWith("Tests"))
                {
                    this.visualStudioService.SolutionService.AddProjectToSubFolder(
                        this.SettingsService.TestProjectsSolutionFolderName,
                        projectPath,
                        template,
                        projectInfo.Name);
                }
                else
                {
                    this.visualStudioService.SolutionService.AddProjectToSolution(projectPath, template, projectInfo.Name);
                }

                this.Messages.Add(projectInfo.Name + " project successfully added. (template " + projectInfo.TemplateName + ")");
            }
            catch (Exception exception)
            {
                TraceService.WriteError("error adding project exception=" + exception.Message);
                TraceService.WriteError("projectPath=" + projectPath);
                TraceService.WriteError("projectInfo.TemplateName=" + projectInfo.TemplateName);

                this.Messages.Add("ERROR " + projectInfo.Name + " not added. exception " + exception.Message + " (template " + projectInfo.TemplateName + ")");
            }
        }
コード例 #6
0
        /// <summary>
        /// Adds the project.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="projectInfo">The project information.</param>
        internal void AddProject(
            string path,
            ProjectTemplateInfo projectInfo)
        {
            string message = $"ProjectsService::AddProjectIf project {projectInfo.Name}";

            TraceService.WriteLine(message);

            this.SettingsService.ActiveProject = projectInfo.FriendlyName;

            this.TryToAddProject(path, projectInfo);

            //// add reference to core project

            IProjectService coreProjectService = this.visualStudioService.CoreProjectService;

            IProjectService projectService = this.visualStudioService.GetProjectServiceBySuffix(projectInfo.ProjectSuffix);

            if (coreProjectService != null &&
                projectService != null &&
                projectInfo.ReferenceCoreProject)
            {
                if (projectService.Name != coreProjectService.Name)
                {
                    projectService.AddProjectReference(coreProjectService);
                }
                else
                {
                    TraceService.WriteError("Attemped to reference project to its self project=" + projectService.Name);
                }
            }

            //// now add references to xamarin forms if required.

            if (projectInfo.ReferenceXamarinFormsProject)
            {
                IProjectService formsProjectService = this.visualStudioService.XamarinFormsProjectService;

                if (formsProjectService != null &&
                    projectService != null)
                {
                    if (projectService.Name != formsProjectService.Name)
                    {
                        projectService.AddProjectReference(formsProjectService);
                    }
                    else
                    {
                        TraceService.WriteError("Attemped to reference project to its self project=" + projectService.Name);
                    }
                }
            }

            //// now add reference to the plaform project from the test platform project

            if (projectInfo.ReferencePlatformProject)
            {
                //// TODO : tidy this up a little bit!
                IProjectService platformProjectService = this.visualStudioService.GetProjectServiceBySuffix(
                    projectInfo.ProjectSuffix.Replace(".Tests", string.Empty));

                if (platformProjectService != null &&
                    projectService != null)
                {
                    //// for some reason cant add project reference to windows store project !!
                    //// as no one is developing mvvmcross windows store apps dont worry about it :-)
                    try
                    {
                        projectService.AddProjectReference(platformProjectService);
                    }
                    catch (Exception exception)
                    {
                        TraceService.WriteError("Unable to add project reference to " + platformProjectService.Name + " exception=" + exception.Message);
                    }
                }
            }

            if (projectInfo.ItemTemplates != null &&
                projectInfo.ItemTemplates.Any() &&
                projectService != null)
            {
                foreach (TextTemplateInfo textTemplateInfo in projectInfo.ItemTemplates)
                {
                    textTemplateInfo.Tokens = this.tokensTranslator.Translate(projectService);
                }

                this.textTemplatingService.AddTextTemplates(
                        "Adding items to project " + projectService.Name,
                        projectInfo.ItemTemplates);
            }
        }
コード例 #7
0
 /// <summary>
 /// Adds the template.
 /// </summary>
 /// <param name="projectTemplateInfo">The project template info.</param>
 public void AddTemplate(ProjectTemplateInfo projectTemplateInfo)
 {
     this.mvxListView1.AddTemplate(projectTemplateInfo);
 }
コード例 #8
0
        /// <summary>
        /// Gets the required template.
        /// </summary>
        /// <param name="projectName">Name of the project.</param>
        /// <param name="projectInfo">The project info.</param>
        internal void GetRequiredTemplate(
            string projectName, 
            ProjectTemplateInfo projectInfo)
        {
            projectInfo.Name = projectName + projectInfo.ProjectSuffix;
            projectInfo.UseNuget = this.view.UseNuget;

            if (projectInfo.NugetCommands != null)
            {
                List<string> newCommands =
                    projectInfo.NugetCommands.Select(
                        nugetCommand => string.Format("{0} {1}", nugetCommand, projectInfo.Name)).ToList();

                projectInfo.NugetCommands = newCommands;
            }
        }
コード例 #9
0
        /// <summary>
        /// Adds the project.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="projectInfo">The project information.</param>
        internal void AddProject(
            string path,
            ProjectTemplateInfo projectInfo)
        {
            string message = string.Format("ProjectsService::AddProjectIf project {0}", projectInfo.Name);

            TraceService.WriteLine(message);

            this.settingsService.ActiveProject = projectInfo.FriendlyName;

            this.TryToAddProject(path, projectInfo);

            //// add reference to core project

            IProjectService coreProjectService = this.visualStudioService.CoreProjectService;

            IProjectService projectService = this.visualStudioService.GetProjectServiceBySuffix(projectInfo.ProjectSuffix);

            if (coreProjectService != null &&
                projectService != null &&
                projectInfo.ReferenceCoreProject)
            {
                projectService.AddProjectReference(coreProjectService);
            }

            //// now add references to xamarin forms if required.

            if (projectInfo.ReferenceXamarinFormsProject)
            {
                IProjectService formsProjectService = this.visualStudioService.XamarinFormsProjectService;

                if (formsProjectService != null &&
                    projectService != null )
                {
                    projectService.AddProjectReference(formsProjectService);
                }
            }

            //// now add reference to the plaform project from the test platform project

            if (projectInfo.ReferencePlatformProject)
            {
                //// TODO : tidy this up a little bit!
                IProjectService platformProjectService = this.visualStudioService.GetProjectServiceBySuffix(
                    projectInfo.ProjectSuffix.Replace(".Tests", string.Empty));

                if (platformProjectService != null &&
                    projectService != null)
                {
                    //// for some reason cant add project reference to windows store project !!
                    //// as no one is developing mvvmcross windows store apps dont worry about it :-)
                    try
                    {
                        projectService.AddProjectReference(platformProjectService);

                    }
                    catch (Exception exception)
                    {
                        TraceService.WriteError("Unable to add project reference to " + platformProjectService.Name);
                    }
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// References the first project.
        /// </summary>
        /// <param name="projectInfo">The project info.</param>
        /// <param name="firstProjectService">The first project service.</param>
        /// <returns>The project.</returns>
        internal IProjectService ReferenceFirstProject(
            ProjectTemplateInfo projectInfo, 
            IProjectService firstProjectService)
        {
            TraceService.WriteLine("ProjectsService::ReferenceFirstProject");

            IProjectService projectService = this.visualStudioService.SolutionService.GetProjectService(projectInfo.Name);

            if (projectService != null)
            {
                if (firstProjectService == null)
                {
                    firstProjectService = projectService;
                }
                else
                {
                    projectService.AddProjectReference(firstProjectService);
                }
            }

            return firstProjectService;
        }
コード例 #11
0
        /// <summary>
        /// Deletes the lib folder.
        /// </summary>
        /// <param name="projectInfo">The project info.</param>
        internal void DeleteLibFolder(ProjectTemplateInfo projectInfo)
        {
            TraceService.WriteLine("ProjectsService::DeleteLibFolder");

            IProjectService projectService = this.visualStudioService.SolutionService.GetProjectService((projectInfo.Name));

            if (projectService != null)
            {
                IProjectItemService projectItemService = projectService.RemoveFolder("Lib");

                //// remove the local files if we are going to use nuget.
                if (projectInfo.UseNuget)
                {
                    projectItemService.DeleteFolder(projectInfo.NonMvxAssemblies);
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// Adds the project.
        /// </summary>
        /// <param name="includeLibFolderInProjects">if set to <c>true</c> [include lib folder in projects].</param>
        /// <param name="projectInfo">The project info.</param>
        /// <param name="projectPath">The project path.</param>
        internal void AddProject(
            bool includeLibFolderInProjects,
            ProjectTemplateInfo projectInfo,
            string projectPath)
        {
            TraceService.WriteLine("ProjectsService::AddProject");

            try
            {
                string template = this.visualStudioService.SolutionService.GetProjectTemplate(projectInfo.TemplateName);

                this.visualStudioService.SolutionService.AddProjectToSolution(projectPath, template, projectInfo.Name);

                //// remove the lib folder if that's what the developer wants to happen.
                //// if the develop has selected use nuget then also remove the project
                if (includeLibFolderInProjects == false ||
                    projectInfo.UseNuget)
                {
                    this.DeleteLibFolder(projectInfo);
                }

                this.Messages.Add(projectInfo.Name + " project successfully added.");
            }
            catch (Exception exception)
            {
                TraceService.WriteError("error adding project " + projectPath + " exception=" + exception.Message);
            }
        }
コード例 #13
0
        /// <summary>
        /// Adds the project.
        /// </summary>
        /// <param name="projectInfo">The project info.</param>
        /// <param name="projectPath">The project path.</param>
        internal void AddProject(
            ProjectTemplateInfo projectInfo,
            string projectPath)
        {
            TraceService.WriteLine("ProjectsService::AddProject project=" + projectInfo.Name);

            try
            {
                string template = this.visualStudioService.SolutionService.GetProjectTemplate(projectInfo.TemplateName);

                TraceService.WriteLine("Template=" + template);

                this.visualStudioService.SolutionService.AddProjectToSolution(projectPath, template, projectInfo.Name);

                this.Messages.Add(projectInfo.Name + " project successfully added.");
            }
            catch (Exception exception)
            {
                TraceService.WriteError("error adding project " + projectPath + " exception=" + exception.Message);
            }
        }
コード例 #14
0
        /// <summary>
        /// Adds the project.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="projectInfo">The project info.</param>
        internal void TryToAddProject(
            string path,
            ProjectTemplateInfo projectInfo)
        {
            TraceService.WriteLine("ProjectsService::TryToAddProject  project=" + projectInfo.Name);

            //// Project may actually already exist - if so just skip it!

            string projectPath = string.Format(@"{0}\{1}\", path, projectInfo.Name);

            if (this.FileSystem.Directory.Exists(projectPath) == false)
            {
                this.AddProject(projectInfo, projectPath);
            }

            else
            {
                TraceService.WriteError("Directory " + projectPath + " not empty");
            }
        }
コード例 #15
0
        /// <summary>
        /// Adds the project.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="referenceFirstProject">if set to <c>true</c> [reference first project].</param>
        /// <param name="includeLibFolderInProjects">if set to <c>true</c> [include lib folder in projects].</param>
        /// <param name="projectInfo">The project info.</param>
        /// <param name="firstProjectService">The first project service.</param>
        /// <returns>The project service.</returns>
        internal IProjectService TryToAddProject(
            string path,
            bool referenceFirstProject,
            bool includeLibFolderInProjects,
            ProjectTemplateInfo projectInfo,
            IProjectService firstProjectService)
        {
            TraceService.WriteLine("ProjectsService::TryToAddProject");

            //// Project may actually already exist - if so just skip it!

            string projectPath = string.Format(@"{0}\{1}\", path, projectInfo.Name);

            if (this.FileSystem.Directory.Exists(projectPath) == false)
            {
                this.AddProject(includeLibFolderInProjects, projectInfo, projectPath);
            }

            if (referenceFirstProject)
            {
                firstProjectService = this.ReferenceFirstProject(projectInfo, firstProjectService);
            }

            return firstProjectService;
        }
コード例 #16
0
        /// <summary>
        /// Fixes the information p list.
        /// </summary>
        /// <param name="projectTemplateInfo">The project template information.</param>
        public void FixInfoPList(ProjectTemplateInfo projectTemplateInfo)
        {
            TraceService.WriteLine("ApplicationService::FixInfoPlist");

            IProjectService iosProjectService = this.visualStudioService.iOSProjectService;

            if (iosProjectService != null)
            {
                if (projectTemplateInfo != null)
                {
                    IProjectItemService projectItemService = iosProjectService.GetProjectItem("Info.plist");

                    if (projectItemService != null)
                    {
                        XDocument doc = XDocument.Load(projectItemService.FileName);

                        if (doc.Root != null)
                        {
                            XElement element = doc.Root.Element("dict");

                            if (element != null)
                            {
                                //// first look for the elements

                                XElement childElement = element.Elements("key").FirstOrDefault(x => x.Value == "CFBundleDisplayName");

                                if (childElement == null)
                                {
                                    element.Add(new XElement("key", "CFBundleDisplayName"));
                                    element.Add(new XElement("string", iosProjectService.Name));
                                }

                                childElement = element.Elements("key").FirstOrDefault(x => x.Value == "CFBundleVersion");

                                if (childElement == null)
                                {
                                    element.Add(new XElement("key", "CFBundleVersion"));
                                    element.Add(new XElement("string", "1.0"));
                                }

                                childElement = element.Elements("key").FirstOrDefault(x => x.Value == "CFBundleIdentifier");

                                if (childElement == null)
                                {
                                    element.Add(new XElement("key", "CFBundleIdentifier"));
                                    element.Add(new XElement("string", "1"));
                                }
                            }

                            doc.Save(projectItemService.FileName);
                        }
                    }
                }
            }
        }
コード例 #17
0
 /// <summary>
 /// Gets the required template.
 /// </summary>
 /// <param name="projectInfo">The project info.</param>
 internal void GetRequiredTemplate(ProjectTemplateInfo projectInfo)
 {
     projectInfo.Name = this.Project + projectInfo.ProjectSuffix;
 }