Skip to content

Commit 1f98acf

Browse files
committed
Update wine-run to handle more exotic project structures
1 parent bdd7d4e commit 1f98acf

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

mtgosdk/scripts/wine-run.sh

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,31 @@ echo "--- Building $PROJECT_OR_SLN ---"
1818
dotnet build "$PROJECT_OR_SLN"
1919

2020
# Get the project name to look for the matching binary
21-
# If the input contains a path, take the filename and strip any C# project/solution extension.
22-
PROJECT_NAME=$(basename "$PROJECT_OR_SLN" | sed -E 's/\.(csproj|sln|fsproj|vbproj)$//')
21+
# Determine the project name to look for the matching binary.
22+
# If a .sln is provided, we need to find the actual .csproj it builds to get the correct binary name.
23+
if [[ "$PROJECT_OR_SLN" == *.sln ]]; then
24+
# Find the first .csproj in the directory (assuming standard single-project solution or taking the first one)
25+
# This is a heuristic; for multi-project solutions, we might want to be more specific, but this covers the flexible rename case.
26+
FOUND_CS=$(find "$(dirname "$PROJECT_OR_SLN")" -name "*.csproj" | head -n 1)
27+
if [ -n "$FOUND_CS" ]; then
28+
PROJECT_NAME=$(basename "$FOUND_CS" .csproj)
29+
PROJECT_DIR=$(dirname "$FOUND_CS")
30+
else
31+
PROJECT_NAME=$(basename "$PROJECT_OR_SLN" .sln)
32+
fi
33+
elif [[ -d "$PROJECT_OR_SLN" ]]; then
34+
# If it's a directory, look for a .csproj inside
35+
FOUND_CS=$(find "$PROJECT_OR_SLN" -maxdepth 2 -name "*.csproj" | head -n 1)
36+
if [ -n "$FOUND_CS" ]; then
37+
PROJECT_NAME=$(basename "$FOUND_CS" .csproj)
38+
PROJECT_DIR=$(dirname "$FOUND_CS")
39+
else
40+
PROJECT_NAME=$(basename "$PROJECT_OR_SLN")
41+
fi
42+
else
43+
# Fallback for direct .csproj input
44+
PROJECT_NAME=$(basename "$PROJECT_OR_SLN" | sed -E 's/\.(csproj|sln|fsproj|vbproj)$//')
45+
fi
2346

2447
# Search for the binary in common output paths
2548
find_binary() {
@@ -55,6 +78,12 @@ if [ -z "$EXE_PATH" ]; then
5578
fi
5679
fi
5780

81+
if [ -z "$EXE_PATH" ]; then
82+
if [ -n "$PROJECT_DIR" ] && [ -d "$PROJECT_DIR/bin" ]; then
83+
EXE_PATH=$(find_binary "$PROJECT_DIR/bin")
84+
fi
85+
fi
86+
5887
if [ -f "$EXE_PATH" ]; then
5988
# Ensure we use an absolute Unix path first
6089
ABS_EXE_PATH=$(realpath "$EXE_PATH")

0 commit comments

Comments
 (0)