forked from theraot/Theraot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_final.bat
More file actions
137 lines (114 loc) · 2.88 KB
/
Copy pathbuild_final.bat
File metadata and controls
137 lines (114 loc) · 2.88 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
@echo off
setlocal enabledelayedexpansion
SET solution_name=Theraot.sln
SET build_configuration=NET35 NET40 NET45
SET assemblies=Theraot.Core.dll
SET recovery_path=Core\bin
SET spec_file=Theraot.nuspec
REM USE QUOTES ALWAYS <----
SET msbuild_fallback="C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe"
echo.
echo Starting.
echo.
SET mypath=%~dp0
echo Running build.bat from %mypath:~0,-1%
echo Looking for MSBuild in PATH
for %%X in (MSBuild.exe) do (SET FOUND_A=%%~$PATH:X)
if defined FOUND_A (
echo MSBuild.exe is in PATH
SET msbuild="%FOUND_A%"
) ELSE (
echo MSBuild.exe is in not in PATH
echo Fallback to default MSBuild.exe location
SET msbuild=%msbuild_fallback%
echo Looking for MSBuild in: %msbuild_fallback%
)
if EXIST %msbuild:~1,-1% (
echo MSBuild found.
SET solution=%mypath:~0,-1%\%solution_name%
echo Looking Solution file: %solution%
IF EXIST %solution% (
echo Solution file found.
echo.
echo Building.
echo.
@echo on
@for %%A in (%build_configuration%) do (
%msbuild% %solution% /m /p:Configuration=%%A
)
@echo off
if not EXIST %mypath:~0,-1%\%spec_file% (
popd
exit
)
echo.
echo Recovering assemblies.
echo.
@echo on
pushd %~dp0
cd /D %mypath:~0,3%
cd %mypath%
rmdir /S /Q package
mkdir package
mkdir package\lib\
copy %spec_file% package\%spec_file%
@for %%A in (%build_configuration%) do (
mkdir package\lib\%%A\
@for %%B in (%assemblies%) do (
copy %recovery_path%\%%A\%%B package\lib\%%A\%%B
)
)
@echo off
echo Looking for NuGet in PATH
for %%X in (NuGet.exe) do (SET FOUND_B=%%~$PATH:X)
if defined FOUND_B (
echo NuGet.exe is in PATH
SET nuget="%FOUND_B%"
) ELSE (
echo NuGet.exe is in not in PATH
echo Fallback to NuGet.CommandLine
pushd %~dp0
cd /D %mypath:~0,3%
cd %mypath:~0,-1%\packages\
for /D %%s in (.\*) do (
SET folder=%%s
SET folder=!folder:~2,17!
if "!folder!" == "NuGet.CommandLine" (
SET folder=%%s
SET nuget="%mypath:~0,-1%\packages\!folder:~2!\tools\NuGet.exe"
SET dst_folder=%mypath:~0,-1%\packages\!folder:~2!\tools\
)
)
popd
echo Looking for NuGet.exe in: !nuget!
)
if EXIST version.txt (
SET /P version=<version.txt
for /f "skip=1" %%x in ('wmic os get localdatetime') do if not defined MyDate set MyDate=%%x
set today=!MyDate:~0,4!!MyDate:~4,2!!MyDate:~6,2!
SET version=!version!
SET version=-Version !version!
)
popd
if EXIST !nuget:~1,-1! (
pushd %~dp0
if defined dst_folder (
cd !dst_folder!
.\NuGet.exe pack %mypath:~0,-1%\package\%spec_file% -OutputDirectory %mypath:~0,-1%\package\ !version!
) ELSE (
NuGet.exe pack %mypath:~0,-1%\package\%spec_file% -OutputDirectory %mypath:~0,-1%\package\ !version!
)
popd
exit
) ELSE (
echo NuGet.exe not found.
exit
)
) ELSE (
echo Solution file not found.
exit
)
) ELSE (
echo MSBuild.exe not found.
exit
)