/// <summary> /// Parses the contents of the <see cref="FileName"/> and returns the /// details to the caller. /// </summary> /// <returns>The relevant properties from the project files.</returns> internal override ProjectFileProperties ParseProject() { XmlDocument projectFile = new XmlDocument(); projectFile.Load(this.FileName); XmlNamespaceManager namespaceManager = new XmlNamespaceManager(projectFile.NameTable); XmlNode projectNode = null; foreach (XmlNode topChild in projectFile) { if (topChild.Name == "Project") { projectNode = topChild; } } namespaceManager.AddNamespace("pr", projectNode.NamespaceURI); // DocumentationFile XmlNode assemblyNode = projectFile.SelectSingleNode(@"/pr:Project/pr:PropertyGroup/pr:AssemblyName", namespaceManager); XmlNode outputTypeNode = projectFile.SelectSingleNode(@"/pr:Project/pr:PropertyGroup/pr:OutputType", namespaceManager); XmlNodeList conditionalGroups = projectFile.SelectNodes(@"/pr:Project/pr:PropertyGroup[@Condition]", namespaceManager); XmlNodeList ouputPathNodes = projectFile.SelectNodes(@"/pr:Project/pr:PropertyGroup[@Condition]/pr:OutputPath", namespaceManager); XmlNode parentPropertyGroup = assemblyNode.ParentNode; string outputExtension = string.Empty; string libraryName = assemblyNode.InnerText; string outputPath = string.Empty; string documentationPath = string.Empty; foreach (XmlNode currentNode in conditionalGroups) { foreach (XmlAttribute attribute in currentNode.Attributes) { if (attribute.Name == "Condition" && (attribute.Value.IndexOf(this.BuildConfiguration, StringComparison.InvariantCultureIgnoreCase) != -1)) { XmlNode outPath = currentNode.SelectSingleNode("pr:OutputPath", namespaceManager); XmlNode docPath = currentNode.SelectSingleNode("pr:DocumentationFile", namespaceManager); if (outPath != null) { outputPath = outPath.InnerText; } if (docPath != null) { documentationPath = docPath.InnerText; } } } } ProjectFileProperties properties = new ProjectFileProperties(); properties.OutputType = outputTypeNode.InnerText; properties.LibraryName = libraryName; properties.OutputPath = outputPath; properties.DocumentationFile = documentationPath; return(properties); }
internal override ProjectFileProperties ParseProject() { ProjectFileProperties properties = new ProjectFileProperties(); properties.DocumentationFile = readDocumentationFile(); properties.LibraryName = readLibraryName(); properties.OutputType = readOutputType(); properties.OutputPath = readOutputPath(); return(properties); }
/// <summary> /// Reads the contents of the project file and returns the details of the /// output assembly for this project /// </summary> /// <returns>An array of assembly files, although there will only ever be one from here.</returns> public override List <DocumentedAssembly> Read() { ProjectFileProperties properties = this.ParseProject(); if (!string.IsNullOrEmpty(properties.OutputPath)) { string outputFile = string.Format(@"{0}\{1}{2}.{3}", System.IO.Path.GetDirectoryName(this.FileName), properties.OutputPath, properties.LibraryName, properties.GetOutputExtension()); string documentation = string.Empty; if (!string.IsNullOrEmpty(properties.DocumentationFile)) { if (System.IO.Path.IsPathRooted(properties.DocumentationFile)) { documentation = properties.DocumentationFile; } else { // We need to check if the file is relative to the project file or simply output // in the output directory documentation = System.IO.Path.GetFullPath(System.IO.Path.GetDirectoryName(this.FileName) + "\\" + properties.DocumentationFile); if (!System.IO.File.Exists(documentation)) { documentation = System.IO.Path.GetFullPath(System.IO.Path.GetDirectoryName(this.FileName) + "\\" + properties.OutputPath + "\\" + properties.DocumentationFile); } } } return(new List <DocumentedAssembly>() { new DocumentedAssembly(outputFile, documentation) }); } else { throw new InvalidOperationException(); } }
private ProjectFile CreateDMSFile(MockContext context, DataMigrationServiceClient client, ResourceGroup resourceGroup, DataMigrationService service, string dmsProjectName, string dmsFileName) { var fileProps = new ProjectFileProperties { FilePath = "NorthWind.sql" }; return(client.Files.CreateOrUpdate( new ProjectFile { Properties = fileProps }, resourceGroup.Name, service.Name, dmsProjectName, dmsFileName)); }
internal override ProjectFileReader.ProjectFileProperties ParseProject() { XmlDocument projectFile = new XmlDocument(); projectFile.Load(this.FileName); XmlNamespaceManager namespaceManager = new XmlNamespaceManager(projectFile.NameTable); XmlNode projectNode = null; foreach (XmlNode topChild in projectFile) { if (topChild.Name == "VisualStudioProject") { projectNode = topChild; } } // DocumentationFile XmlNode settings = projectFile.SelectSingleNode(@"/VisualStudioProject/*/Build/Settings"); XmlNode debugNode = projectFile.SelectSingleNode(@"/VisualStudioProject/*/Build/Settings/Config[@Name='" + this.BuildConfiguration + "']"); string outputExtension = string.Empty; string libraryName = settings.Attributes["AssemblyName"].Value; string outputPath = debugNode.Attributes["OutputPath"].Value; string documentationFile = string.Empty; if (debugNode.Attributes["DocumentationFile"] != null) { documentationFile = debugNode.Attributes["DocumentationFile"].Value; } ProjectFileProperties properties = new ProjectFileProperties(); properties.OutputType = settings.Attributes["OutputType"].Value; properties.LibraryName = libraryName; properties.OutputPath = outputPath; properties.DocumentationFile = documentationFile; return(properties); }
internal static string GetCustomToolNamespace([CanBeNull] this IProjectFile projectFile) { ProjectFileProperties properties = TryGetProperties(projectFile); return(properties != null ? properties.CustomToolNamespace : null); }