-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.bat
More file actions
197 lines (163 loc) · 5.9 KB
/
Copy pathbuild.bat
File metadata and controls
197 lines (163 loc) · 5.9 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Build TerrariaDepotDownloader Via MSBuild Tools ::
:: GitHub: https://github.com/RussDev7/TerrariaDepotDownloader ::
:: Developed and maintained by RussDev7 / Discord: dannyruss ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
REM ============================================================
REM Paths
REM ============================================================
SET "RootDir=%~dp0"
SET "SolutionPath=%RootDir%src\TerrariaDepotDownloader.sln"
SET "ProjectOutput=%RootDir%src\TerrariaDepotDownloader\bin\x64\Release"
SET "ReleaseDir=%RootDir%release"
SET "ExeName=TerrariaDepotDownloader.exe"
SET "ExternalResourcesDir=%RootDir%src\TerrariaDepotDownloader\ExternalResources"
SET "DepotDownloaderDir=%RootDir%src\TerrariaDepotDownloader\DepotDownloader"
REM ============================================================
REM Find Visual Studio / Build Tools MSBuild
REM ============================================================
SET "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
IF NOT EXIST "%VSWHERE%" (
ECHO ERROR: vswhere.exe was not found.
ECHO Install Visual Studio or Visual Studio Build Tools with .NET desktop build tools.
PAUSE
EXIT /B 1
)
FOR /F "usebackq tokens=*" %%I IN (`"%VSWHERE%" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) DO (
SET "MSBUILD=%%I"
)
IF NOT DEFINED MSBUILD (
ECHO ERROR: Could not find Visual Studio MSBuild.
ECHO Install Visual Studio Build Tools and include MSBuild / .NET desktop workload.
PAUSE
EXIT /B 1
)
ECHO Using MSBuild:
ECHO "%MSBUILD%"
ECHO(
REM ============================================================
REM Build Solution
REM ============================================================
ECHO Building TerrariaDepotDownloader.sln...
"%MSBUILD%" "%SolutionPath%" ^
/m ^
/restore ^
/p:Configuration=Release ^
/p:Platform=x64
IF ERRORLEVEL 1 (
ECHO(
ECHO Build failed.
PAUSE
EXIT /B 1
)
REM ============================================================
REM Read File Version From Built EXE
REM ============================================================
IF NOT EXIST "%ProjectOutput%\%ExeName%" (
ECHO ERROR: Built EXE was not found:
ECHO "%ProjectOutput%\%ExeName%"
PAUSE
EXIT /B 1
)
FOR /F "usebackq tokens=*" %%V IN (`powershell.exe -NoLogo -NoProfile -Command "(Get-Item '%ProjectOutput%\%ExeName%').VersionInfo.FileVersion"`) DO (
SET "VersionPrefix=%%V"
)
IF NOT DEFINED VersionPrefix (
ECHO ERROR: Could not read file version from EXE.
PAUSE
EXIT /B 1
)
SET "FileName=TerrariaDepotDownloader-%VersionPrefix%"
SET "PackageDir=%ReleaseDir%\%FileName%"
ECHO(
ECHO Detected File Version: %VersionPrefix%
ECHO Release Name: %FileName%
ECHO(
REM ============================================================
REM Recreate Release Folder
REM ============================================================
IF EXIST "%ReleaseDir%" (
RMDIR /S /Q "%ReleaseDir%"
)
MKDIR "%PackageDir%"
IF ERRORLEVEL 1 (
ECHO(
ECHO Failed to create release folder.
PAUSE
EXIT /B 1
)
REM ============================================================
REM Copy Build Output
REM ============================================================
ECHO Copying build output...
XCOPY /E /Y /I "%ProjectOutput%\*" "%PackageDir%\"
IF ERRORLEVEL 1 (
ECHO(
ECHO Failed to copy build output.
PAUSE
EXIT /B 1
)
REM ============================================================
REM Copy External Resources
REM ============================================================
ECHO Copying external resources...
IF EXIST "%ExternalResourcesDir%\ManifestVersions.cfg" (
COPY /Y "%ExternalResourcesDir%\ManifestVersions.cfg" "%PackageDir%\" >NUL
) ELSE (
ECHO WARNING: ManifestVersions.cfg was not found.
)
REM ============================================================
REM Copy DepotDownloader Runtime Files
REM ============================================================
ECHO Copying DepotDownloader runtime files...
IF EXIST "%DepotDownloaderDir%" (
ROBOCOPY "%DepotDownloaderDir%" "%PackageDir%" /E /XF *.pdb >NUL
REM Robocopy returns 0-7 for success / non-fatal copy states.
IF !ERRORLEVEL! GEQ 8 (
ECHO(
ECHO Failed to copy DepotDownloader runtime files.
PAUSE
EXIT /B 1
)
) ELSE (
ECHO ERROR: DepotDownloader folder was not found:
ECHO "%DepotDownloaderDir%"
PAUSE
EXIT /B 1
)
REM ============================================================
REM Clean Release Files
REM ============================================================
ECHO Cleaning release files...
DEL /F /Q /S "%ReleaseDir%\*.xml" >NUL 2>&1
DEL /F /Q /S "%ReleaseDir%\*.pdb" >NUL 2>&1
REM NOTE:
REM Do NOT delete *.config for this project.
REM TerrariaDepotDownloader.exe.config contains .NET Framework runtime settings,
REM user setting defaults, and binding redirects for NuGet dependencies.
REM ============================================================
REM Create ZIP Release
REM ============================================================
IF EXIST "%RootDir%%FileName%.zip" (
DEL /F /Q "%RootDir%%FileName%.zip"
)
ECHO Creating ZIP package...
powershell.exe -NoLogo -NoProfile -Command ^
"Compress-Archive -Path '%PackageDir%' -DestinationPath '%RootDir%%FileName%.zip' -Force"
IF ERRORLEVEL 1 (
ECHO(
ECHO ZIP creation failed.
PAUSE
EXIT /B 1
)
REM ============================================================
REM Operation Complete
REM ============================================================
ECHO(
ECHO Build complete.
ECHO Created: "%RootDir%%FileName%.zip"
ECHO(
PAUSE
ENDLOCAL