forked from rscustom/rocksmith-custom-song-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPatchAssemblyInfo.bat
99 lines (79 loc) · 2.29 KB
/
PatchAssemblyInfo.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
96
97
98
99
@echo off
setlocal enabledelayedexpansion
if errorlevel 1 goto BuildEventFailed
set batchpath=%~dp0
echo Current batch path: %batchpath%
cd %batchpath%
set solution=%~1
set toolkitver=%~2
echo Solution Path from Command Line: %solution%
echo Toolkit Version Path from Command Line: %toolkitver%
REM args for testing
if "%solution%"=="" (
set solution=.\
)
REM args for testing
if "%toolkitver%"=="" (
rem set toolkitver=.\RocksmithToolkitLib\ToolkitVersion.cs
rem set toolkitver=.\RocksmithToolkitLib\Properties\AssemblyInfo.cs
rem set toolkitver=.\RocksmithToolkitUpdater\Properties\AssemblyInfo.cs
set toolkitver=.\RocksmithTookitGUI\Properties\AssemblyInfo.cs
)
set toolkitverdist=%toolkitver%_dist
echo solution %solution%
echo toolkitver %toolkitver%
echo toolkitverdist %toolkitverdist%
echo Copying %toolkitverdist%
echo To %toolkitver%
copy %toolkitverdist% %toolkitver%
echo Checking .git\HEAD exists ...
:: get git commit version from .git\refs\heads\master file
:: github commit version script
if exist %solution%\.git\HEAD (
echo Reading .git\HEAD ...
set /p head=<"%solution%\.git\HEAD"
if "!head:~0,4!" == "ref:" (
set master=.git\!head:~5!
if exist "%solution%\.git\!head:~5!" set /p commit=<"%solution%\.git\!head:~5!"
) else (
set commit=!head!
)
if not "!commit!" == "" (
echo Found commit: !commit!
set newrev=!commit:~0,8!
echo newrev !newrev!
for %%a in (%solution%!master!) do set newrevdate=%%~ta
echo newrevdate !newrevdate!
) else echo Unable to find commit ...
)
set oldrev=00000000
::pause
REM this has been depricated does not seem to be needed with revised scripts
::*.cs files in Unicode, required for VS2010 Pre-Build Event to work with WinXP
::chcp 65001>nul not reliable on WinXP SP3
::alt work around
::(
::chcp 65001
::cmd /c type myfile.txt
::chcp 850
::)
echo Replacing %oldrev% in tempfile.txt with %newrev% ...
::pause
::git version replacement script
for /f "tokens=* delims==" %%i in (%toolkitverdist%) do (
set str=%%i
set newstr=!str:%oldrev%=%newrev%!
echo !newstr!>>tempfile.txt
)
::pause
echo Moving tempfile.txt to new %toolkitver% ...
move /y tempfile.txt "%toolkitver%"
echo Creating VersionInfo.txt ...
echo %newrev% > VersionInfo.txt
echo Done
::pause
endlocal
exit /b 0
:BuildEventFailed
echo Pre-Build Event Failed in prebuild.bat file
pause