private static SdkResolverManifest ParseSdkResolverElement(XmlReader reader) { SdkResolverManifest manifest = new SdkResolverManifest(); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: { switch (reader.Name) { case "Path": manifest.Path = reader.ReadElementContentAsString(); break; default: throw new XmlException(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("UnrecognizedElement", reader.Name)); } } break; default: throw new XmlException(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("UnrecognizedElement", reader.Name)); } } return(manifest); }
private bool TryAddAssemblyFromManifest(string pathToManifest, string manifestFolder, List <string> assembliesList, ElementLocation location) { if (!string.IsNullOrEmpty(pathToManifest) && !FileUtilities.FileExistsNoThrow(pathToManifest)) { return(false); } string path = null; try { // <SdkResolver> // <Path>...</Path> // </SdkResolver> var manifest = SdkResolverManifest.Load(pathToManifest); if (manifest == null || string.IsNullOrEmpty(manifest.Path)) { ProjectFileErrorUtilities.ThrowInvalidProjectFile(new BuildEventFileInfo(location), "SdkResolverDllInManifestMissing", pathToManifest, string.Empty); } path = FileUtilities.FixFilePath(manifest.Path); } catch (XmlException e) { // Note: Not logging e.ToString() as most of the information is not useful, the Message will contain what is wrong with the XML file. ProjectFileErrorUtilities.ThrowInvalidProjectFile(new BuildEventFileInfo(location), e, "SdkResolverManifestInvalid", pathToManifest, e.Message); } if (!Path.IsPathRooted(path)) { path = Path.Combine(manifestFolder, path); path = Path.GetFullPath(path); } if (!TryAddAssembly(path, assembliesList)) { ProjectFileErrorUtilities.ThrowInvalidProjectFile(new BuildEventFileInfo(location), "SdkResolverDllInManifestMissing", pathToManifest, path); } return(true); }