From 1ffcc232db7a56415aff33bd293fda1d0a0e55b9 Mon Sep 17 00:00:00 2001 From: Boppy Date: Thu, 28 Sep 2023 15:40:59 -0500 Subject: [PATCH] Add project path check --- crates/cli/src/tasks/csharp.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/cli/src/tasks/csharp.rs b/crates/cli/src/tasks/csharp.rs index ed2f46b002d..e69a074329c 100644 --- a/crates/cli/src/tasks/csharp.rs +++ b/crates/cli/src/tasks/csharp.rs @@ -1,4 +1,5 @@ use duct::cmd; +use std::fs; use std::path::{Path, PathBuf}; pub(crate) fn build_csharp(project_path: &Path, _build_debug: bool) -> anyhow::Result { @@ -11,6 +12,14 @@ pub(crate) fn build_csharp(project_path: &Path, _build_debug: bool) -> anyhow::R std::fs::remove_file(&output_path)?; } + // Ensure the project path exists + if fs::metadata(project_path).is_err() { + anyhow::bail!( + "The provided project path '{}' does not exist.", + project_path.to_str().unwrap() + ); + } + // run dotnet publish using cmd macro let result = cmd!("dotnet", "publish", "-c", "Release").dir(project_path).run(); match result {