@@ -13,27 +13,50 @@ if [ -z "$PROJECT_OR_SLN" ]; then
1313 PROJECT_OR_SLN=" ."
1414fi
1515
16- echo " --- Building $PROJECT_OR_SLN (win-x64, Framework-Dependent) ---"
16+ echo " --- Building $PROJECT_OR_SLN (Framework-Dependent) ---"
1717dotnet 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
2024if [ -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
2231fi
2332
2433if [ -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
3149fi
3250
3351if [ -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
3659else
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
3962fi
0 commit comments