forked from CoplayDev/unity-mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-dev.bat
More file actions
151 lines (131 loc) · 4.26 KB
/
deploy-dev.bat
File metadata and controls
151 lines (131 loc) · 4.26 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
@echo off
setlocal enabledelayedexpansion
echo ===============================================
echo MCP for Unity Development Deployment Script
echo ===============================================
echo.
:: Configuration
set "SCRIPT_DIR=%~dp0"
set "BRIDGE_SOURCE=%SCRIPT_DIR%MCPForUnity"
set "SERVER_SOURCE=%SCRIPT_DIR%Server"
set "DEFAULT_BACKUP_DIR=%USERPROFILE%\Desktop\unity-mcp-backup"
set "DEFAULT_SERVER_PATH=%LOCALAPPDATA%\UnityMCP\UnityMcpServer\src"
:: Get user inputs
echo Please provide the following paths:
echo.
:: Package cache location
echo Unity Package Cache Location:
echo Example: X:\Unity\Projects\UnityMCPTestbed2\Library\PackageCache\com.coplaydev.unity-mcp@4c106125b342
set /p "PACKAGE_CACHE_PATH=Enter Unity package cache path: "
if "%PACKAGE_CACHE_PATH%"=="" (
echo Error: Package cache path cannot be empty!
pause
exit /b 1
)
rem Server installation path prompt disabled (server deploy skipped)
set "SERVER_PATH="
:: Backup location (with default)
echo.
echo Backup Location:
echo Default: %DEFAULT_BACKUP_DIR%
set /p "BACKUP_DIR=Enter backup directory (or press Enter for default): "
if "%BACKUP_DIR%"=="" set "BACKUP_DIR=%DEFAULT_BACKUP_DIR%"
:: Validation
echo.
echo ===============================================
echo Validating paths...
echo ===============================================
if not exist "%BRIDGE_SOURCE%" (
echo Error: Bridge source not found: %BRIDGE_SOURCE%
pause
exit /b 1
)
if not exist "%PACKAGE_CACHE_PATH%" (
echo Error: Package cache path not found: %PACKAGE_CACHE_PATH%
pause
exit /b 1
)
:: Create backup directory
if not exist "%BACKUP_DIR%" (
echo Creating backup directory: %BACKUP_DIR%
mkdir "%BACKUP_DIR%"
)
:: Create timestamped backup subdirectory
set "TIMESTAMP=%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%"
set "TIMESTAMP=%TIMESTAMP: =0%"
set "TIMESTAMP=%TIMESTAMP::=-%"
set "TIMESTAMP=%TIMESTAMP:/=-%"
set "BACKUP_SUBDIR=%BACKUP_DIR%\backup_%TIMESTAMP%"
mkdir "%BACKUP_SUBDIR%"
echo.
echo ===============================================
echo Starting deployment...
echo ===============================================
:: Backup original files
echo Creating backup of original files...
if exist "%PACKAGE_CACHE_PATH%\Editor" (
echo Backing up Unity Bridge files...
xcopy "%PACKAGE_CACHE_PATH%\Editor" "%BACKUP_SUBDIR%\UnityBridge\Editor\" /E /I /Y > nul
if !errorlevel! neq 0 (
echo Error: Failed to backup Unity Bridge files
pause
exit /b 1
)
)
if exist "%PACKAGE_CACHE_PATH%\Runtime" (
echo Backing up Unity Runtime files...
xcopy "%PACKAGE_CACHE_PATH%\Runtime" "%BACKUP_SUBDIR%\UnityBridge\Runtime\" /E /I /Y > nul
if !errorlevel! neq 0 (
echo Error: Failed to backup Unity Runtime files
pause
exit /b 1
)
)
rem Server backup skipped (deprecated legacy deploy)
rem if exist "%SERVER_PATH%" (
rem echo Backing up Python Server files...
rem xcopy "%SERVER_PATH%\*" "%BACKUP_SUBDIR%\PythonServer\" /E /I /Y > nul
rem if !errorlevel! neq 0 (
rem echo Error: Failed to backup Python Server files
rem pause
rem exit /b 1
rem )
rem )
:: Deploy Unity Bridge
echo.
echo Deploying Unity Bridge code...
xcopy "%BRIDGE_SOURCE%\Editor\*" "%PACKAGE_CACHE_PATH%\Editor\" /E /Y > nul
if !errorlevel! neq 0 (
echo Error: Failed to deploy Unity Bridge code
pause
exit /b 1
)
echo Deploying Unity Runtime code...
xcopy "%BRIDGE_SOURCE%\Runtime\*" "%PACKAGE_CACHE_PATH%\Runtime\" /E /Y > nul
if !errorlevel! neq 0 (
echo Error: Failed to deploy Unity Runtime code
pause
exit /b 1
)
rem Deploy Python Server (disabled; server no longer deployed this way)
rem echo Deploying Python Server code...
rem xcopy "%SERVER_SOURCE%\*" "%SERVER_PATH%\" /E /Y > nul
rem if !errorlevel! neq 0 (
rem echo Error: Failed to deploy Python Server code
rem pause
rem exit /b 1
rem )
:: Success
echo.
echo ===============================================
echo Deployment completed successfully!
echo ===============================================
echo.
echo Backup created at: %BACKUP_SUBDIR%
echo.
echo Next steps:
echo 1. Restart Unity Editor to load new Bridge code
echo 2. Restart any MCP clients to use new Server code
echo 3. Use restore-dev.bat to rollback if needed
echo.
pause