From 7b35023d0a691dc6526be4cd9bc9846000b055be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20R=C3=B8nnestad=20Birkeland?= <6450056+o-l-a-v@users.noreply.github.com> Date: Mon, 11 Aug 2025 11:00:06 +0200 Subject: [PATCH 1/4] Use explicit type --- src/code/InstallHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/code/InstallHelper.cs b/src/code/InstallHelper.cs index 16dcda959..9f062fc23 100644 --- a/src/code/InstallHelper.cs +++ b/src/code/InstallHelper.cs @@ -926,7 +926,7 @@ private bool TryInstallToTempPath( try { var pathToFile = Path.Combine(tempInstallPath, $"{pkgName}.{normalizedPkgVersion}.zip"); - using var fs = File.Create(pathToFile); + using FileStream fs = File.Create(pathToFile); responseStream.Seek(0, System.IO.SeekOrigin.Begin); responseStream.CopyTo(fs); fs.Close(); From 46885659ee26f4c46169d90e98ace78030b138e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20R=C3=B8nnestad=20Birkeland?= <6450056+o-l-a-v@users.noreply.github.com> Date: Mon, 11 Aug 2025 11:47:49 +0200 Subject: [PATCH 2/4] Simplify type name --- src/code/Utils.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/code/Utils.cs b/src/code/Utils.cs index 308c3b2e7..5f6fdfc57 100644 --- a/src/code/Utils.cs +++ b/src/code/Utils.cs @@ -1343,8 +1343,8 @@ private static bool TryReadPSDataFile( throw new PSArgumentNullException(nameof(filePath)); } - string contents = System.IO.File.ReadAllText(filePath); - var scriptBlock = System.Management.Automation.ScriptBlock.Create(contents); + string contents = File.ReadAllText(filePath); + var scriptBlock = ScriptBlock.Create(contents); // Ensure that the content script block is safe to convert into a PSDataFile Hashtable. // This will throw for unsafe content. From d7a53fc73116d6c04219d1e992b7e63d613c7b9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20R=C3=B8nnestad=20Birkeland?= <6450056+o-l-a-v@users.noreply.github.com> Date: Mon, 11 Aug 2025 11:48:12 +0200 Subject: [PATCH 3/4] Experimenting on getting case of GitHub Packages packages --- src/code/InstallHelper.cs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/code/InstallHelper.cs b/src/code/InstallHelper.cs index 9f062fc23..ffcf4e8d6 100644 --- a/src/code/InstallHelper.cs +++ b/src/code/InstallHelper.cs @@ -943,8 +943,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); @@ -980,6 +980,15 @@ private bool TryInstallToTempPath( return false; } + // Get module actual name with correct casing + string moduleManifestActualFileName = Path.GetFileName( + Directory.GetFiles( + tempDirNameVersion, + $"{pkgName}.psd1" + )[0] + ); + _cmdletPassedIn.WriteVerbose($"pkgName: \"{pkgName}\", actual name of manifest: \"${moduleManifestActualFileName}"); + if (!Utils.TryReadManifestFile( manifestFilePath: moduleManifest, manifestInfo: out Hashtable parsedMetadataHashtable, @@ -1032,6 +1041,15 @@ 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 { @@ -1040,6 +1058,15 @@ private bool TryInstallToTempPath( _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}\""); } installPath = _savePkg ? _pathsToInstallPkg.First() : installPath; From f2b645b81ad1363ee595b93db24c5de473793410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20R=C3=B8nnestad=20Birkeland?= <6450056+o-l-a-v@users.noreply.github.com> Date: Mon, 11 Aug 2025 11:50:45 +0200 Subject: [PATCH 4/4] Don't want the extension yo --- src/code/InstallHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/code/InstallHelper.cs b/src/code/InstallHelper.cs index ffcf4e8d6..c45865b92 100644 --- a/src/code/InstallHelper.cs +++ b/src/code/InstallHelper.cs @@ -981,7 +981,7 @@ private bool TryInstallToTempPath( } // Get module actual name with correct casing - string moduleManifestActualFileName = Path.GetFileName( + string moduleManifestActualFileName = Path.GetFileNameWithoutExtension( Directory.GetFiles( tempDirNameVersion, $"{pkgName}.psd1"