Пример #1
0
        public void Alter(TemplatePlan plan)
        {
            this._substitutions.Set("%INSTRUCTIONS%", plan.GetInstructions());
            plan.Logger.StartProject(this._alterations.Count);
            plan.StartProject(this);
            this._substitutions.Trace(plan.Logger);
            SolutionProject reference = plan.Solution.FindProject(this._projectName);

            if (reference == null)
            {
                if (FubuCore.StringExtensions.IsEmpty(this.ProjectTemplateFile))
                {
                    plan.Logger.Trace("Creating project {0} from the default template", new object[]
                    {
                        this._projectName
                    });
                    reference = plan.Solution.AddProject(this._projectName);
                }
                else
                {
                    plan.Logger.Trace("Creating project {0} from template at {1}", new object[]
                    {
                        this._projectName,
                        this.ProjectTemplateFile
                    });
                    reference = plan.Solution.AddProjectFromTemplate(this._projectName, this.ProjectTemplateFile);
                }
                reference.Project.AssemblyName = (reference.Project.RootNamespace = this.ProjectName);
                if (this.DotNetVersion != null)
                {
                    reference.Project.DotNetVersion = this.DotNetVersion;
                }
            }
            string projectDirectory = reference.Project.ProjectDirectory;

            plan.FileSystem.CreateDirectory(projectDirectory);
            this._relativePath = FubuCore.StringExtensions.PathRelativeTo(reference.Project.FileName, plan.Root).Replace("\\", "/");
            this._substitutions.Set("%PROJECT_PATH%", this._relativePath);
            this._substitutions.Set("%PROJECT_FOLDER%", GenericEnumerableExtensions.Join(this._relativePath.Split(new char[]
            {
                '/'
            }).Reverse <string>().Skip(1).Reverse <string>(), "/"));
            GenericEnumerableExtensions.Each <IProjectAlteration>(this._alterations, delegate(IProjectAlteration x)
            {
                plan.Logger.TraceAlteration(this.ApplySubstitutionsRaw(x.ToString(), null));
                x.Alter(reference.Project, this);
            });
            this.Substitutions.WriteTo(FubuCore.StringExtensions.AppendPath(projectDirectory, new string[]
            {
                Substitutions.ConfigFile
            }));
            plan.Logger.EndProject();
        }
Пример #2
0
        public void Alter(TemplatePlan plan)
        {
            // Hokey.
            _substitutions.Set(TemplatePlan.INSTRUCTIONS, plan.GetInstructions());

            plan.Logger.StartProject(_alterations.Count);
            plan.StartProject(this);

            _substitutions.Trace(plan.Logger);

            var reference = plan.Solution.FindProject(_projectName);

            if (reference == null)
            {
                if (ProjectTemplateFile.IsEmpty())
                {
                    plan.Logger.Trace("Creating project {0} from the default template", _projectName);
                    reference = plan.Solution.AddProject(_projectName);
                }
                else
                {
                    plan.Logger.Trace("Creating project {0} from template at {1}", _projectName, ProjectTemplateFile);
                    reference = plan.Solution.AddProjectFromTemplate(_projectName, ProjectTemplateFile);
                }

                reference.Project.AssemblyName = reference.Project.RootNamespace = ProjectName;
                if (DotNetVersion != null)
                {
                    reference.Project.DotNetVersion = DotNetVersion;
                }
            }

            var projectDirectory = reference.Project.ProjectDirectory;

            plan.FileSystem.CreateDirectory(projectDirectory);

            _relativePath = reference.Project.FileName.PathRelativeTo(plan.Root).Replace("\\", "/");
            _substitutions.Set(PROJECT_PATH, _relativePath);
            _substitutions.Set(PROJECT_FOLDER, _relativePath.Split('/').Reverse().Skip(1).Reverse().Join("/"));

            _alterations.Each(x => {
                plan.Logger.TraceAlteration(ApplySubstitutions(x.ToString()));
                x.Alter(reference.Project, this);
            });


            Substitutions.WriteTo(projectDirectory.AppendPath(Substitutions.ConfigFile));

            plan.Logger.EndProject();
        }