forked from theraot/Theraot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage_final.bat
84 lines (69 loc) · 1.92 KB
/
package_final.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
@echo off
setlocal enabledelayedexpansion
REM nuspec file name
SET spec_file=Theraot.nuspec
echo.
echo Starting.
echo.
REM Store path of the bat
SET mypath=%~dp0
echo ____________________________
echo Running from %mypath:~0,-1%\package_final.bat
echo ____________________________
if not EXIST %mypath:~0,-1%\%spec_file% (
popd
exit
)
REM enter the path of the bat
pushd %~dp0
cd /D %mypath:~0,3%
cd %mypath%
REM copy the nuspec file to the package folder
copy %spec_file% package\%spec_file%
echo Looking for NuGet in PATH
REM look for nuget.exe in the PATH environment variable
for %%X in (NuGet.exe) do (SET FOUND_B=%%~$PATH:X)
REM if found
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
REM get nuget from .\packages\NuGet.CommandLine.*\tools\NuGet.exe
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!
)
REM get the version number form version.txt if it exists
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 !version!
)
REM leave the path
popd
REM if NuGet exists use it to create the package
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 /b