Skip to content

Commit 30a5389

Browse files
committed
Fix binary detection if no RID is specified
1 parent 37d4688 commit 30a5389

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

mtgosdk/scripts/wine-run.sh

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,50 @@ if [ -z "$PROJECT_OR_SLN" ]; then
1313
PROJECT_OR_SLN="."
1414
fi
1515

16-
echo "--- Building $PROJECT_OR_SLN (win-x64, Framework-Dependent) ---"
16+
echo "--- Building $PROJECT_OR_SLN (Framework-Dependent) ---"
1717
dotnet build "$PROJECT_OR_SLN"
1818

19+
# Get the project name to look for the matching executable
20+
# If the input contains a path, take the filename. Then strip any C# project/solution extension.
21+
PROJECT_NAME=$(basename "$PROJECT_OR_SLN" | sed -E 's/\.(csproj|sln|fsproj|vbproj)$//')
22+
1923
# Search for the executable in the most common output paths
2024
if [ -d "bin" ]; then
21-
EXE_PATH=$(find bin -name "*.exe" | grep "win-x64" | head -n 1)
25+
# Prioritize exact matches for .exe or .dll (for tests)
26+
EXE_PATH=$(find bin -name "${PROJECT_NAME}.exe" -o -name "${PROJECT_NAME}.dll" | head -n 1)
27+
# Fallback to any executable if the exact match wasn't found
28+
if [ -z "$EXE_PATH" ]; then
29+
EXE_PATH=$(find bin -name "*.exe" | head -n 1)
30+
fi
2231
fi
2332

2433
if [ -z "$EXE_PATH" ]; then
25-
if [ -f "$PROJECT_OR_SLN" ]; then
34+
BASE_DIR=""
35+
if [ -d "$PROJECT_OR_SLN" ]; then
36+
BASE_DIR="$PROJECT_OR_SLN"
37+
elif [ -f "$PROJECT_OR_SLN" ]; then
2638
BASE_DIR=$(dirname "$PROJECT_OR_SLN")
27-
if [ -d "$BASE_DIR/bin" ]; then
28-
EXE_PATH=$(find "$BASE_DIR/bin" -name "*.exe" | grep "win-x64" | head -n 1)
39+
fi
40+
41+
if [ -n "$BASE_DIR" ] && [ -d "$BASE_DIR/bin" ]; then
42+
# Prioritize exact matches for .exe or .dll (for tests)
43+
EXE_PATH=$(find "$BASE_DIR/bin" -name "${PROJECT_NAME}.exe" -o -name "${PROJECT_NAME}.dll" | head -n 1)
44+
# Fallback to any executable if the exact match wasn't found
45+
if [ -z "$EXE_PATH" ]; then
46+
EXE_PATH=$(find "$BASE_DIR/bin" -name "*.exe" | head -n 1)
2947
fi
3048
fi
3149
fi
3250

3351
if [ -f "$EXE_PATH" ]; then
3452
echo "--- Running $EXE_PATH via Wine ---"
35-
wine "$EXE_PATH" "$@"
53+
# If it's a DLL, we run it via the windows dotnet host
54+
if [[ "$EXE_PATH" == *.dll ]]; then
55+
wine "C:\\dotnet\\dotnet.exe" "$EXE_PATH" "$@"
56+
else
57+
wine "$EXE_PATH" "$@"
58+
fi
3659
else
37-
echo "Error: Could not find win-x64 executable for $PROJECT_OR_SLN"
60+
echo "Error: Could not find executable for $PROJECT_OR_SLN"
3861
exit 1
3962
fi

mtgosdk/scripts/wine-shell.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ alias run='wine-run'
1111
alias wine-dotnet='wine C:\\dotnet\\dotnet.exe'
1212
echo "----------------------------------------------------"
1313
echo " Wine Shell Initialized"
14-
echo " 'dotnet build' -> Produces win-x64 binaries (Framework-Dependent)"
14+
echo " 'dotnet build' -> Produces framework-dependent binaries"
1515
echo " 'run' -> Runs 'wine-run' (Build + Wine Run)"
1616
echo " 'wine-dotnet' -> Runs the native Windows .NET SDK in Wine"
1717
echo "----------------------------------------------------"

0 commit comments

Comments
 (0)