Skip to content

Commit 8695ac9

Browse files
Bugfix - Test if InstalledScriptInfos folder exists and create if needed (#1542)
* Test InstalledScriptInfos folder and create if needed * Update src/code/InstallHelper.cs Co-authored-by: Aditya Patwardhan <[email protected]> * Update src/code/InstallHelper.cs Co-authored-by: Aditya Patwardhan <[email protected]> --------- Co-authored-by: Aditya Patwardhan <[email protected]>
1 parent 0fc7827 commit 8695ac9

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/code/InstallHelper.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,15 +488,26 @@ private void MoveFilesIntoInstallPath(
488488
}
489489
else
490490
{
491-
var scriptXML = pkgInfo.Name + "_InstalledScriptInfo.xml";
491+
string scriptInfoFolderPath = Path.Combine(installPath, "InstalledScriptInfos");
492+
string scriptXML = pkgInfo.Name + "_InstalledScriptInfo.xml";
493+
string scriptXmlFilePath = Path.Combine(scriptInfoFolderPath, scriptXML);
492494
if (!_savePkg)
493495
{
496+
// Need to ensure "InstalledScriptInfos directory exists
497+
if (!Directory.Exists(scriptInfoFolderPath))
498+
499+
{
500+
_cmdletPassedIn.WriteVerbose($"Created '{scriptInfoFolderPath}' path for scripts");
501+
Directory.CreateDirectory(scriptInfoFolderPath);
502+
}
503+
494504
// Need to delete old xml files because there can only be 1 per script
495-
_cmdletPassedIn.WriteVerbose(string.Format("Checking if path '{0}' exists: ", File.Exists(Path.Combine(installPath, "InstalledScriptInfos", scriptXML))));
496-
if (File.Exists(Path.Combine(installPath, "InstalledScriptInfos", scriptXML)))
505+
_cmdletPassedIn.WriteVerbose(string.Format("Checking if path '{0}' exists: '{1}'", scriptXmlFilePath, File.Exists(scriptXmlFilePath)));
506+
if (File.Exists(scriptXmlFilePath))
497507
{
498508
_cmdletPassedIn.WriteVerbose("Deleting script metadata XML");
499-
File.Delete(Path.Combine(installPath, "InstalledScriptInfos", scriptXML));
509+
File.Delete(Path.Combine(scriptInfoFolderPath, scriptXML));
510+
500511
}
501512

502513
_cmdletPassedIn.WriteVerbose(string.Format("Moving '{0}' to '{1}'", Path.Combine(dirNameVersion, scriptXML), Path.Combine(installPath, "InstalledScriptInfos", scriptXML)));

0 commit comments

Comments
 (0)