-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild.bat
More file actions
150 lines (126 loc) · 4.4 KB
/
build.bat
File metadata and controls
150 lines (126 loc) · 4.4 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
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Build The CoreKeepersWorkshop Project Via Batch ::
:: GitHub: https://github.com/RussDev7/CoreKeepersWorkshop ::
:: Developed and maintained by RussDev7 / Discord: dannyruss ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
REM ============================================================
REM Paths
REM ============================================================
SET "RootDir=%~dp0"
SET "SolutionPath=%RootDir%src\CoreKeeperInventoryEditor.sln"
SET "ProjectOutput=%RootDir%src\CoreKeeperInventoryEditor\bin\x64\Release"
SET "ReleaseDir=%RootDir%release"
SET "ExeName=CoreKeepersWorkshop.exe"
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 CoreKeeperInventoryEditor.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=CoreKeeperInventoryEditor-%VersionPrefix%"
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 "%ReleaseDir%\%FileName%"
IF ERRORLEVEL 1 (
ECHO(
ECHO Failed to create release folder.
PAUSE
EXIT /B 1
)
REM ============================================================
REM Copy Build Output
REM ============================================================
XCOPY /E /Y /I "%ProjectOutput%\*" "%ReleaseDir%\%FileName%\"
IF ERRORLEVEL 1 (
ECHO(
ECHO Copy failed.
PAUSE
EXIT /B 1
)
REM ============================================================
REM Clean Release Files
REM ============================================================
DEL /F /Q /S "%ReleaseDir%\*.xml" >NUL 2>&1
DEL /F /Q /S "%ReleaseDir%\*.pdb" >NUL 2>&1
DEL /F /Q /S "%ReleaseDir%\*.config" >NUL 2>&1
REM ============================================================
REM Create ZIP Release
REM ============================================================
IF EXIST "%RootDir%%FileName%.zip" (
DEL /F /Q "%RootDir%%FileName%.zip"
)
powershell.exe -NoLogo -NoProfile -Command ^
"Compress-Archive -Path '%ReleaseDir%\%FileName%' -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