private void CreateMetadataXMLFile(string dirNameVersion, string installPath, string repoName, PSResourceInfo pkg, bool isScript) { // Script will have a metadata file similar to: "TestScript_InstalledScriptInfo.xml" // Modules will have the metadata file: "PSGetModuleInfo.xml" var metadataXMLPath = isScript ? Path.Combine(dirNameVersion, (pkg.Name + "_InstalledScriptInfo.xml")) : Path.Combine(dirNameVersion, "PSGetModuleInfo.xml"); pkg.InstalledDate = DateTime.Now; pkg.InstalledLocation = installPath; // Write all metadata into metadataXMLPath if (!pkg.TryWrite(metadataXMLPath, out string error)) { var message = string.Format("Error parsing metadata into XML: '{0}'", error); var ex = new ArgumentException(message); var ErrorParsingMetadata = new ErrorRecord(ex, "ErrorParsingMetadata", ErrorCategory.ParserError, null); WriteError(ErrorParsingMetadata); } }
private void CreateMetadataXMLFile(string dirNameVersion, string installPath, PSResourceInfo pkg, bool isModule) { // Script will have a metadata file similar to: "TestScript_InstalledScriptInfo.xml" // Modules will have the metadata file: "PSGetModuleInfo.xml" var metadataXMLPath = isModule ? Path.Combine(dirNameVersion, "PSGetModuleInfo.xml") : Path.Combine(dirNameVersion, (pkg.Name + "_InstalledScriptInfo.xml")); pkg.InstalledDate = DateTime.Now; pkg.InstalledLocation = installPath; // Write all metadata into metadataXMLPath if (!pkg.TryWrite(metadataXMLPath, out string error)) { var message = string.Format("{0} package could not be installed with error: Error parsing metadata into XML: '{1}'", pkg.Name, error); var ex = new ArgumentException(message); var ErrorParsingMetadata = new ErrorRecord(ex, "ErrorParsingMetadata", ErrorCategory.ParserError, null); _cmdletPassedIn.WriteError(ErrorParsingMetadata); _pkgNamesToInstall.RemoveAll(x => x.Equals(pkg.Name, StringComparison.InvariantCultureIgnoreCase)); } }