forked from alexAgyapong/build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cmd
88 lines (71 loc) · 2.37 KB
/
build.cmd
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
@echo off
@if defined _echo echo on
:main
setlocal EnableDelayedExpansion
set errorlevel=
set BuildConfiguration=Release
set /p BuildVersion=<"%~dp0\.config\BuildVersion.txt"
REM Check that git is on path.
where.exe /Q git.exe || (
echo ERROR: git.exe is not in the path.
exit /b 1
)
call taskkill /IM dotnet.exe /F > nul
set /a count = 0
for /f %%l in ('git clean -xdn') do set /a count += 1
for /f %%l in ('git status --porcelain') do set /a count += 1
if %count% neq 0 (
git clean -xdf
)
set /a count = 0
for /f %%l in ('git clean -xdn') do set /a count += 1
for /f %%l in ('git status --porcelain') do set /a count += 1
if %count% neq 0 (
choice.exe /T 10 /D N /C YN /M "WARNING: The repo contains uncommitted changes and you are building for publication. Press Y to continue or N to stop. "
if !errorlevel! neq 1 exit /b 1
)
set LV_GIT_HEAD_SHA=
for /f %%c in ('git rev-parse HEAD') do set "LV_GIT_HEAD_SHA=%%c"
set LocalDotNet_PackagesDir=%~dp0packages
if exist "%LocalDotNet_PackagesDir%" rmdir /s /q "%LocalDotNet_PackagesDir%"
if exist "%LocalDotNet_PackagesDir%" (
echo ERROR: Failed to remove "%LocalDotNet_PackagesDir%" folder.
exit /b 1
)
echo/==================
echo/ %LV_GIT_HEAD_SHA%
echo/==================
echo/==================
echo/ Building %BuildVersion% %BuildConfiguration% version of NuGet packages.
echo/==================
call .nuget\_NuGet.cmd %BuildConfiguration% %BuildVersion%
set OutputDirectory=%~dp0.nuget\nuget
call :remove_directory "%OutputDirectory%" || exit /b 1
call taskkill /IM dotnet.exe /F > nul
echo/==================
echo/ %LV_GIT_HEAD_SHA%
echo/==================
echo/==================
echo/ Building %BuildVersion% %BuildConfiguration% version of MyGet packages.
echo/==================
call .myget\_MyGet.cmd %BuildConfiguration% %BuildVersion%
set OutputDirectory=%~dp0.myget\myget
call :remove_directory "%OutputDirectory%" || exit /b 1
call taskkill /IM dotnet
endlocal& exit /b %errorlevel%
:print_error_message
echo/
echo/ [ERROR] %*
echo/
exit /b %errorlevel%
:remove_directory
if "%~1" == "" (
call :print_error_message Directory name was not specified.
exit /b 1
)
if exist "%~1" rmdir /s /q "%~1"
if exist "%~1" (
call :print_error_message Failed to remove directory "%~1".
exit /b 1
)
exit /b 0