Skip to content

Commit

Permalink
Use relative launch process paths (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
runesoerensen authored Nov 10, 2024
1 parent 778efa9 commit 83947ed
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions buildpacks/dotnet/src/launch_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -42,11 +56,11 @@ pub(crate) fn detect_solution_processes(
.parse::<ProcessType>()
.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()
Expand Down

0 comments on commit 83947ed

Please sign in to comment.