commit 6abb614f23b155c4ef00bd8d4adbabdf6cf9bd70
parent 869c3d9055fd5887273935d94c1670547b04186f
Author: Kaleb Luedtke <jluedtk@jci.com>
Date: Tue, 29 Aug 2023 20:00:51 -0500
Rename file in single portable installs (#3439)
Diffstat:
2 files changed, 13 insertions(+), 21 deletions(-)
diff --git a/src/AppInstallerCLICore/Workflows/PortableFlow.cpp b/src/AppInstallerCLICore/Workflows/PortableFlow.cpp
@@ -196,7 +196,7 @@ namespace AppInstaller::CLI::Workflow
for (const auto& nestedInstallerFile : nestedInstallerFiles)
{
const std::filesystem::path& targetPath = targetInstallDirectory / ConvertToUTF16(nestedInstallerFile.RelativeFilePath);
-
+
std::filesystem::path commandAlias;
if (nestedInstallerFile.PortableCommandAlias.empty())
{
@@ -215,31 +215,20 @@ namespace AppInstaller::CLI::Workflow
{
std::string_view renameArg = context.Args.GetArg(Execution::Args::Type::Rename);
const std::vector<string_t>& commands = context.Get<Execution::Data::Installer>()->Commands;
- std::filesystem::path fileName;
- std::filesystem::path commandAlias;
-
- if (!renameArg.empty())
+ std::filesystem::path commandAlias = installerPath.filename();
+
+ if (!commands.empty())
{
- fileName = commandAlias = ConvertToUTF16(renameArg);
+ commandAlias = ConvertToUTF16(commands[0]);
}
- else
- {
- if (!commands.empty())
- {
- commandAlias = ConvertToUTF16(commands[0]);
- }
- else
- {
- commandAlias = installerPath.filename();
- }
- fileName = installerPath.filename();
+ if (!renameArg.empty())
+ {
+ commandAlias = ConvertToUTF16(renameArg);
}
-
- AppInstaller::Filesystem::AppendExtension(fileName, ".exe");
AppInstaller::Filesystem::AppendExtension(commandAlias, ".exe");
- const std::filesystem::path& targetFullPath = targetInstallDirectory / fileName;
+ const std::filesystem::path& targetFullPath = targetInstallDirectory / commandAlias;
entries.emplace_back(std::move(PortableFileEntry::CreateFileEntry(installerPath, targetFullPath, {})));
entries.emplace_back(std::move(PortableFileEntry::CreateSymlinkEntry(symlinkDirectory / commandAlias, targetFullPath)));
}
diff --git a/src/AppInstallerCLIE2ETests/Helpers/TestCommon.cs b/src/AppInstallerCLIE2ETests/Helpers/TestCommon.cs
@@ -481,8 +481,11 @@ namespace AppInstallerCLIE2ETests.Helpers
bool shouldExist,
Scope scope = Scope.User)
{
+ // When portables are installed, if the exe path is inside a directory it will not be aliased
+ // if the exe path is at the root level, it will be aliased. Therefore, if either exist, the exe exists
string exePath = Path.Combine(installDir, filename);
- bool exeExists = File.Exists(exePath);
+ string exeAliasedPath = Path.Combine(installDir, commandAlias);
+ bool exeExists = File.Exists(exePath) || File.Exists(exeAliasedPath);
string symlinkDirectory = GetPortableSymlinkDirectory(scope);
string symlinkPath = Path.Combine(symlinkDirectory, commandAlias);