-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bat
95 lines (85 loc) · 3.16 KB
/
build.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
@echo off
setlocal enabledelayedexpansion
:: Store the script's directory
set "SCRIPT_DIR=%~dp0"
:: Define paths relative to script directory
set "SOURCE_DLL=%SCRIPT_DIR%bin\Debug\netstandard2.1\BinderSearch.dll"
set "BEPINEX_PLUGINS=%SCRIPT_DIR%BepInEx\plugins\BinderSearch\BinderSearch.dll"
set "STEAM_PLUGINS=C:\Program Files (x86)\Steam\steamapps\common\TCG Card Shop Simulator\BepInEx\plugins\BinderSearch.dll"
set "ZIP_NAME=BinderSearch.zip"
set "MOD_FOLDER=%SCRIPT_DIR%BepInEx"
set "DESTINATION_PATH=%SCRIPT_DIR%BinderSearch.zip"
:: Echo paths for verification
echo [INFO] Current directory: %CD%
echo [INFO] Script directory: %SCRIPT_DIR%
echo [INFO] Source DLL path: %SOURCE_DLL%
echo [INFO] BepInEx plugins path: %BEPINEX_PLUGINS%
echo [INFO] Steam plugins path: %STEAM_PLUGINS%
:: Build the project
echo [BUILD] Building project...
dotnet build
if errorlevel 1 (
echo [ERROR] Build failed!
exit /b %errorlevel%
)
:: Verify source file exists
if not exist "%SOURCE_DLL%" (
echo [ERROR] Source DLL not found at: %SOURCE_DLL%
exit /b 1
)
:: Create directories if they don't exist
echo [INFO] Creating directories...
for %%G in ("%BEPINEX_PLUGINS%" "%STEAM_PLUGINS%") do (
if not exist "%%~dpG" (
mkdir "%%~dpG"
if errorlevel 1 (
echo [ERROR] Failed to create directory: %%~dpG
exit /b 1
)
)
)
:: Copy DLL to development folder
echo [INFO] Copying to development folder...
copy /Y "%SOURCE_DLL%" "%BEPINEX_PLUGINS%" > nul
if errorlevel 1 (
echo [ERROR] Development folder copy failed!
echo [DEBUG] Source: %SOURCE_DLL%
echo [DEBUG] Destination: %BEPINEX_PLUGINS%
exit /b %errorlevel%
)
:: Check Steam directory exists and is accessible
echo [INFO] Checking Steam directory...
if not exist "C:\Program Files (x86)\Steam\steamapps\common\TCG Card Shop Simulator" (
echo [WARNING] Steam game directory not found. Is the game installed?
choice /M "Do you want to continue without copying to Steam directory"
if errorlevel 2 exit /b 1
) else (
:: Copy DLL to Steam folder with enhanced error checking
echo [INFO] Copying to Steam folder...
copy /Y "%SOURCE_DLL%" "%STEAM_PLUGINS%" > nul
if errorlevel 1 (
echo [ERROR] Steam folder copy failed! Checking permissions...
:: Test write permissions
echo. 2> "%STEAM_PLUGINS%\.test" > nul
if errorlevel 1 (
echo [ERROR] No write permission to Steam directory. Try running as administrator.
choice /M "Do you want to continue without copying to Steam directory"
if errorlevel 2 exit /b 1
) else (
del "%STEAM_PLUGINS%\.test"
echo [ERROR] Unknown error during copy to Steam directory.
exit /b 1
)
)
)
:: Create zip (requires PowerShell)
echo [INFO] Creating zip file...
if exist "%DESTINATION_PATH%" del "%DESTINATION_PATH%"
powershell -NoProfile -Command "Compress-Archive -Force -Path '%MOD_FOLDER%' -DestinationPath '%DESTINATION_PATH%'"
if errorlevel 1 (
echo [ERROR] Zip creation failed!
echo [DEBUG] Source: %MOD_FOLDER%
echo [DEBUG] Destination: %DESTINATION_PATH%
exit /b %errorlevel%
)
echo [SUCCESS] Build complete!