diff --git a/src/code/InstallHelper.cs b/src/code/InstallHelper.cs index c89ef0ee9..6708d55c2 100644 --- a/src/code/InstallHelper.cs +++ b/src/code/InstallHelper.cs @@ -1028,8 +1028,8 @@ private bool TryInstallToTempPath( File.Delete(pathToFile); - var moduleManifest = Path.Combine(tempDirNameVersion, pkgName + PSDataFileExt); - var scriptPath = Path.Combine(tempDirNameVersion, pkgName + PSScriptFileExt); + string moduleManifest = Path.Combine(tempDirNameVersion, pkgName + PSDataFileExt); + string scriptPath = Path.Combine(tempDirNameVersion, pkgName + PSScriptFileExt); bool isModule = File.Exists(moduleManifest); bool isScript = File.Exists(scriptPath); @@ -1066,6 +1066,15 @@ private bool TryInstallToTempPath( return false; } + // Get module actual name with correct casing + string moduleManifestActualFileName = Path.GetFileNameWithoutExtension( + Directory.GetFiles( + tempDirNameVersion, + $"{pkgName}.psd1" + )[0] + ); + _cmdletPassedIn.WriteVerbose($"pkgName: \"{pkgName}\", actual name of manifest: \"${moduleManifestActualFileName}"); + if (!Utils.TryReadManifestFile( manifestFilePath: moduleManifest, manifestInfo: out Hashtable parsedMetadataHashtable, @@ -1118,12 +1127,32 @@ private bool TryInstallToTempPath( } return false; } + + // Get script actual name with correct casing + string scriptActualFileName = Path.GetFileNameWithoutExtension( + Directory.GetFiles( + tempDirNameVersion, + $"{pkgName}.ps1" + )[0] + ); + _cmdletPassedIn.WriteVerbose($"pkgName: \"{pkgName}\", actual name of script: \"{scriptActualFileName}\""); } else { // This package is not a PowerShell package (eg a resource from the NuGet Gallery). installPath = _pathsToInstallPkg.Find(path => path.EndsWith("Modules", StringComparison.InvariantCultureIgnoreCase)); + _cmdletPassedIn.WriteVerbose($"This resource is not a PowerShell package and will be installed to the modules path: {installPath}."); + isModule = true; + + // Get actual name from .nuspec file + string resourceNuspecFileName = Path.GetFileNameWithoutExtension( + Directory.GetFiles( + tempDirNameVersion, + $"{pkgName}.nuspec" + )[0] + ); + _cmdletPassedIn.WriteVerbose($"pkgName: \"{pkgName}\", actual name of nuspec file: \"{resourceNuspecFileName}\""); // TODO: pass in ConcurrentQueue to write out verbose message. // _cmdletPassedIn.WriteVerbose($"This resource is not a PowerShell package and will be installed to the modules path: {installPath}."); isModule = true; diff --git a/src/code/Utils.cs b/src/code/Utils.cs index 20ccc2d65..89f30037e 100644 --- a/src/code/Utils.cs +++ b/src/code/Utils.cs @@ -1394,7 +1394,7 @@ private static bool TryReadPSDataFile( { throw new PSArgumentNullException(nameof(filePath)); } - string contents = System.IO.File.ReadAllText(filePath); + string contents = File.ReadAllText(filePath); // Validate that the file content conforms to restricted language rules before execution. // This parses the content into an AST and statically validates it only contains data-file-safe constructs (hashtables, arrays, literals, etc).