Exemple #1
0
        /// <summary>
        /// Creates a new project with the specified parameters.
        /// </summary>
        /// <param name="ProjectName">The name of the new package project.</param>
        /// <param name="ProjectLocation">The location in which to create the new package project.</param>
        /// <param name="ProjectType">The type of package project to create.</param>
        public void CreateNewProject(string ProjectName, string ProjectLocation, PackageType ProjectType)
        {
            PackageProject project     = new PackageProject();
            string         projectRoot = ProjectLocation + "\\" + ProjectName;

            // Set the basic project properties
            project.ProjectName   = ProjectName;
            project.RootDirectory = projectRoot;

            // Create the project directory structure
            Directory.CreateDirectory(projectRoot);              // Create the project root folder
            Directory.CreateDirectory(projectRoot + "\\Builds"); // Create the builds folder

            ProjectFolder fileSystemRoot = new ProjectFolder();  // Create the folder that represents the root of the project file system

            fileSystemRoot.Name = "{FSROOT}";                    // Set the FSROOT tag. Not meant for end-user display
            fileSystemRoot.Path = projectRoot;
            fileSystemRoot.ChildFolders.Add(CreateDefaultContentFolder(projectRoot));

            project.FileSystem = fileSystemRoot;

            // Create the project file itself
            XmlDocument projectFile = GenerateProjectFile(project);

            projectFile.Save(projectRoot + "\\" + project.ProjectName + ".pkgprj");

            OnProjectCreated(new EventArgs());
        }
Exemple #2
0
        /// <summary>
        /// Generates the XmlDocument representation of the project file.
        /// </summary>
        public System.Xml.XmlDocument GenerateProjectFile(PackageProject packageProject)
        {
            XmlDocument doc = new XmlDocument();

            XmlElement   root        = doc.CreateElement("PackageProject");
            XmlAttribute rootGenVers = doc.CreateAttribute("GeneratorVersion");

            XmlElement project     = doc.CreateElement("Project");
            XmlElement projectName = doc.CreateElement("Name");
            XmlElement projectType = doc.CreateElement("Type");

            XmlElement fileSystem = doc.CreateElement("FileSystem");

            rootGenVers.Value = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            // <Project> child nodes
            projectName.InnerText = packageProject.ProjectName;

            switch (packageProject.PackageType)
            {
            case PackageType.Compiled:
                projectType.InnerText = "CompiledPackage";
                break;

            case PackageType.FreeStanding:
                projectType.InnerText = "FreeStandingPackage";
                break;
            }

            project.AppendChild(projectName);
            project.AppendChild(projectType);

            // <FileSystem> child nodes
            foreach (ProjectFolder folder in packageProject.FileSystem.ChildFolders)
            {
                fileSystem.AppendChild(GetProjectFolderXmlElement(doc, folder));
            }

            // <PackageProject> child nodes
            root.AppendChild(project);
            root.AppendChild(fileSystem);
            root.Attributes.Append(rootGenVers);

            // Add everything to the document
            doc.AppendChild(root);

            return(doc);
        }