Ejemplo n.º 1
0
		public void AddProjectReference(VSProject project)
		{
			XmlElement refElem = (XmlElement) projectReferencesGroup.AppendChild(document.CreateElement("ProjectReference", ns));
			refElem.SetAttribute("Include", project.FileName);

			refElem.AppendChild(document.CreateElement("Project", ns)).AppendChild(document.CreateTextNode(project.Id.ToString("P")));
			refElem.AppendChild(document.CreateElement("Name", ns)).AppendChild(document.CreateTextNode(project.Name));
		}
Ejemplo n.º 2
0
		public void Add(VSProject project)
		{
			projects.Add(project);
		}
Ejemplo n.º 3
0
		public static VSProject Create(string name, string folder, ProjectType type, XmlDocument templateFile)
		{
			Guid id = Guid.NewGuid();

			VSProject project = new VSProject(id, name, Path.Combine(folder, name + ".csproj"), templateFile);

			ImportExistingFilesFromFolder(project, folder, templateFile);

			SetUpProject(id, name, type, templateFile);

			return project;
		}
Ejemplo n.º 4
0
		private static void ImportExistingFilesFromFolder(VSProject project, string folder, XmlDocument templateFile)
		{
			project.referencesGroup = templateFile.CreateElement("ItemGroup", ns);
			project.contentGroup = templateFile.CreateElement("ItemGroup", ns);
			project.compileGroup = templateFile.CreateElement("ItemGroup", ns);
			project.projectReferencesGroup = templateFile.CreateElement("ItemGroup", ns);
			project.foldersGroup = templateFile.CreateElement("ItemGroup", ns);

			templateFile.DocumentElement.AppendChild(project.referencesGroup);
			templateFile.DocumentElement.AppendChild(project.contentGroup);
			templateFile.DocumentElement.AppendChild(project.compileGroup);
			templateFile.DocumentElement.AppendChild(project.projectReferencesGroup);
			templateFile.DocumentElement.AppendChild(project.foldersGroup);

			List<string> entries = new List<string>();
			entries.AddRange(Directory.GetDirectories(folder, "*", SearchOption.AllDirectories));
			entries.AddRange(Directory.GetFiles(folder, "*", SearchOption.AllDirectories));

			foreach(string entry in entries)
			{
				string nodeName;
				XmlElement targetNode;
				string relativeFilePath = entry.Substring(folder.Length + 1);
				FileType fileType = ResolveFileType(entry);

				switch(fileType)
				{
					case FileType.StaticContent:
						nodeName = "Content";
						targetNode = project.contentGroup;
						break;
					case FileType.SourceCode:
						nodeName = "Compile";
						targetNode = project.compileGroup;
						break;
					case FileType.Folder:
						nodeName = "Folder";
						targetNode = project.foldersGroup;
						break;
					case FileType.None:
						nodeName = "None";
						targetNode = project.contentGroup;
						break;
					default:
						continue;
				}

				XmlElement item = templateFile.CreateElement(nodeName, ns);
				item.SetAttribute("Include", relativeFilePath);
				targetNode.AppendChild(item);
			}
		}