From 83947ed20b404aaed9599a27982c617c426eabc3 Mon Sep 17 00:00:00 2001 From: Rune Soerensen Date: Sat, 9 Nov 2024 19:37:16 -0500 Subject: [PATCH] Use relative launch process paths (#138) --- buildpacks/dotnet/src/launch_process.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/buildpacks/dotnet/src/launch_process.rs b/buildpacks/dotnet/src/launch_process.rs index b2a3197..7d79a53 100644 --- a/buildpacks/dotnet/src/launch_process.rs +++ b/buildpacks/dotnet/src/launch_process.rs @@ -31,7 +31,21 @@ pub(crate) fn detect_solution_processes( .join("bin") .join("publish") .join(&project.assembly_name); - let mut command = executable_path.to_string_lossy().to_string(); + + let relative_executable_path = executable_path + .strip_prefix( + solution + .path + .parent() + .expect("Solution path to have a parent"), + ) + .expect("Project to be nested in solution parent directory"); + + let mut command = relative_executable_path + .file_name() + .expect("Executable path to never terminate in `..`") + .to_string_lossy() + .to_string(); if project.project_type == ProjectType::WebApplication { command.push_str(" --urls http://0.0.0.0:$PORT"); @@ -42,11 +56,11 @@ pub(crate) fn detect_solution_processes( .parse::() .map_err(LaunchProcessDetectionError::ProcessType) .map(|process_type| { - ProcessBuilder::new(process_type, ["bash", "-c", &command]) + ProcessBuilder::new(process_type, ["bash", "-c", &format!("./{}", &command)]) .working_directory(WorkingDirectory::Directory( - executable_path + relative_executable_path .parent() - .expect("Executable should always have a parent directory") + .expect("Executable path to always have a parent directory") .to_path_buf(), )) .build()