Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/code/InstallHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,18 @@ private List<PSResourceInfo> InstallPackage(
continue;
}

if (!Utils.TryParsePSDataFile(moduleManifest, _cmdletPassedIn, out Hashtable parsedMetadataHashtable))
if (!Utils.TryReadManifestFile(
manifestFilePath: moduleManifest,
manifestInfo: out Hashtable parsedMetadataHashtable,
error: out Exception manifestReadError))
{
// Ran into errors parsing the module manifest file which was found in Utils.ParseModuleManifest() and written.
WriteError(
new ErrorRecord(
exception: manifestReadError,
errorId: "ManifestFileReadParseError",
errorCategory: ErrorCategory.ReadError,
this));

continue;
}

Expand Down
29 changes: 18 additions & 11 deletions src/code/InstallPSResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,25 @@ protected override void ProcessRecord()
Hashtable pkgsInFile = null;
try
{
if (_resourceFileType.Equals(ResourceFileType.JsonFile))
switch (_resourceFileType)
{
pkgsInFile = Utils.ConvertJsonToHashtable(this, requiredResourceFileStream);
}
else
{
// must be a .psd1 file
if (!Utils.TryParsePSDataFile(_requiredResourceFile, this, out pkgsInFile))
{
// Ran into errors parsing the .psd1 file which was found in Utils.TryParsePSDataFile() and written.
return;
}
case ResourceFileType.JsonFile:
pkgsInFile = Utils.ConvertJsonToHashtable(this, requiredResourceFileStream);
break;

case ResourceFileType.PSDataFile:
if (!Utils.TryReadRequiredResourceFile(
resourceFilePath: _requiredResourceFile,
out pkgsInFile,
out Exception error))
{
throw error;
}
break;

case ResourceFileType.UnknownFile:
throw new PSInvalidOperationException(
message: "Unkown file type. Required resource file must be either a json or psd1 data file.");
}
}
catch (Exception)
Expand Down
17 changes: 12 additions & 5 deletions src/code/PublishPSResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,12 +477,19 @@ private string CreateNuspec(
// a module will still need the module manifest to be parsed.
if (!isScript)
{
// Parse the module manifest and *replace* the passed-in metadata with the module manifest metadata.
if (!Utils.TryParsePSDataFile(
moduleFileInfo: filePath,
cmdletPassedIn: this,
parsedMetadataHashtable: out parsedMetadataHash))
// Use the parsed module manifest data as 'parsedMetadataHash' instead of the passed-in data.
if (!Utils.TryReadManifestFile(
manifestFilePath: filePath,
manifestInfo: out parsedMetadataHash,
error: out Exception manifestReadError))
{
WriteError(
new ErrorRecord(
exception: manifestReadError,
errorId: "ManifestFileReadParseForNuspecError",
errorCategory: ErrorCategory.ReadError,
this));

return string.Empty;
}
}
Expand Down
Loading