Skip to content

Commit

Permalink
Add project path check
Browse files Browse the repository at this point in the history
  • Loading branch information
Boppy authored and Centril committed Oct 6, 2023
1 parent d9b6e76 commit 1ffcc23
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/cli/src/tasks/csharp.rs
Original file line number Diff line number Diff line change
@@ -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<PathBuf> {
Expand All @@ -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 {
Expand Down

0 comments on commit 1ffcc23

Please sign in to comment.