diff --git a/src/code/InstallHelper.cs b/src/code/InstallHelper.cs index 927ebca19..24105381a 100644 --- a/src/code/InstallHelper.cs +++ b/src/code/InstallHelper.cs @@ -737,8 +737,6 @@ private Hashtable BeginPackageInstall( FindResults responses = null; errRecord = null; - //_cmdletPassedIn.WriteWarning($"~~~~~~~~~~~~~~~~~~ pkgNameToInstall is: '{pkgNameToInstall}'."); - switch (searchVersionType) { case VersionType.VersionRange: @@ -816,9 +814,6 @@ private Hashtable BeginPackageInstall( return packagesHash; } - // THIS SHOULD BE THE CORRECT PKG NAME - // _cmdletPassedIn.WriteWarning($"~~~~~~~~~~~~~~~~~~ pkgToInstall.Name is: '{pkgToInstall.Name}'."); - pkgToInstall.RepositorySourceLocation = repository.Uri.ToString(); pkgToInstall.AdditionalMetadata.TryGetValue("NormalizedVersion", out string pkgVersion); if (pkgVersion == null) { @@ -976,14 +971,6 @@ private bool TryInstallToTempPath( updatedPackagesHash = packagesHash; try { - if (responseStream == null) - { - _cmdletPassedIn.WriteVerbose($"response stream is null"); - } - else { - _cmdletPassedIn.WriteVerbose($"response stream is NOT null"); - } - var pathToFile = Path.Combine(tempInstallPath, $"{pkgName}.{normalizedPkgVersion}.zip"); _cmdletPassedIn.WriteVerbose($"pathToFile IS: {pathToFile}."); @@ -1003,41 +990,11 @@ private bool TryInstallToTempPath( return false; } - - _cmdletPassedIn.WriteVerbose($"tempDirNameVersionIS: {tempDirNameVersion}."); - - // Check if the directory exists - if (Directory.Exists(tempDirNameVersion)) - { - Console.WriteLine($"Contents of {tempDirNameVersion}:"); - - // Display all files in the directory - string[] files = Directory.GetFiles(tempDirNameVersion, "*.*", SearchOption.AllDirectories); - foreach (string file in files) - { - Console.WriteLine($"File: {file}"); - } - - // Display all subdirectories in the directory - string[] directories = Directory.GetDirectories(tempDirNameVersion, "*", SearchOption.AllDirectories); - foreach (string directory in directories) - { - Console.WriteLine($"Directory: {directory}"); - } - } - else - { - Console.WriteLine($"The directory {tempDirNameVersion} does not exist."); - } - - - File.Delete(pathToFile); var moduleManifest = Path.Combine(tempDirNameVersion, pkgName + PSDataFileExt); var scriptPath = Path.Combine(tempDirNameVersion, pkgName + PSScriptFileExt); - _cmdletPassedIn.WriteVerbose($"MODULE MANIFEST PATH IS: {moduleManifest}."); bool isModule = File.Exists(moduleManifest); bool isScript = File.Exists(scriptPath); diff --git a/src/code/LocalServerApiCalls.cs b/src/code/LocalServerApiCalls.cs index 4473e5392..1dca86200 100644 --- a/src/code/LocalServerApiCalls.cs +++ b/src/code/LocalServerApiCalls.cs @@ -730,7 +730,7 @@ private Hashtable GetMetadataFromNupkg(string packageName, string packagePath, s } pkgMetadata = parsedScript.ToHashtable(); - pkgMetadata.Add("Id", packageName); + pkgMetadata.Add("Id", properCasingPkgName); pkgMetadata.Add(_fileTypeKey, Utils.MetadataFileType.ScriptFile); pkgTags.AddRange(pkgMetadata["Tags"] as string[]); diff --git a/src/code/Utils.cs b/src/code/Utils.cs index 1d5462d94..da80d3f42 100644 --- a/src/code/Utils.cs +++ b/src/code/Utils.cs @@ -1186,27 +1186,28 @@ internal static void GetMetadataFilesFromPath(string dirPath, string packageName { if (rgx.IsMatch(file)) { - if (file.EndsWith("psd1")) + string fileName = Path.GetFileName(file); + if (fileName.EndsWith("psd1")) { - if (string.Compare($"{packageName}.psd1", file, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Compare($"{packageName}.psd1", fileName, StringComparison.OrdinalIgnoreCase) == 0) { - properCasingPkgName = file.Split(new string[] { ".psd1" }, StringSplitOptions.None).First(); + properCasingPkgName = Path.GetFileNameWithoutExtension(file); } psd1FilePath = file; } else if (file.EndsWith("nuspec")) { - if (string.Compare($"{packageName}.nuspec", file, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Compare($"{packageName}.nuspec", fileName, StringComparison.OrdinalIgnoreCase) == 0) { - properCasingPkgName = file.Split(new string[] { ".nuspec" }, StringSplitOptions.None).First(); + properCasingPkgName = Path.GetFileNameWithoutExtension(file); } nuspecFilePath = file; } else if (file.EndsWith("ps1")) { - if (string.Compare($"{packageName}.ps1", file, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Compare($"{packageName}.ps1", fileName, StringComparison.OrdinalIgnoreCase) == 0) { - properCasingPkgName = file.Split(new string[] { ".ps1" }, StringSplitOptions.None).First(); + properCasingPkgName = Path.GetFileNameWithoutExtension(file); } ps1FilePath = file; }