Merge pull request #5773 from Maoni0/grow_card_2
[platform/upstream/coreclr.git] / sync.cmd
1 @if "%_echo%" neq "on" echo off
2 setlocal EnableDelayedExpansion
3
4 set synclog=sync.log
5 echo Running Sync.cmd %* > %synclog%
6
7 set options=/nologo /v:minimal /clp:Summary /flp:v=detailed;Append;LogFile=%synclog%
8
9 set "__args= %*"
10 set processedArgs=
11 set unprocessedBuildArgs=
12
13 set src=false
14 set packages=false
15 set azureBlobs=false
16
17 if [%1]==[] (
18   set src=true
19   set packages=true
20   goto Begin
21 )
22
23 :Loop
24 if [%1]==[] goto Begin
25
26 if /I [%1] == [/?] goto Usage
27 if /I [%1] == [/help] goto Usage
28
29 if /I [%1] == [/p] (
30     set packages=true
31     set processedArgs=!processedArgs! %1
32     goto Next
33 )
34
35 if /I [%1] == [/s] (
36     set src=true
37     set processedArgs=!processedArgs! %1
38     goto Next
39 )
40
41 if /I [%1] == [/ab] (
42     set azureBlobs=true
43     set processedArgs=!processedArgs! %1
44     goto Next
45 )
46
47 if [!processedArgs!]==[] (
48   call set unprocessedBuildArgs=!__args!
49 ) else (
50   call set unprocessedBuildArgs=%%__args:*!processedArgs!=%%
51 )
52
53 :Next
54 shift /1
55 goto Loop
56
57 :Begin
58 echo Running init-tools.cmd
59 call %~dp0init-tools.cmd
60
61 if [%src%] == [true] (
62   echo Fetching git database from remote repos ...
63   call git fetch --all -p -v >> %synclog% 2>&1
64   if NOT [!ERRORLEVEL!]==[0] (
65     echo ERROR: An error occurred while fetching remote source code, see %synclog% for more details.
66     exit /b 1
67   )
68 )
69
70 if [%azureBlobs%] == [true] (
71   echo Connecting and downloading packages from Azure BLOB ...
72   echo msbuild.exe %~dp0src\syncAzure.proj !options! !unprocessedBuildArgs! >> %synclog%
73   call msbuild.exe %~dp0src\syncAzure.proj !options! !unprocessedBuildArgs!
74   if NOT [!ERRORLEVEL!]==[0] (
75     echo ERROR: An error occurred while downloading packages from Azure BLOB, see %synclog% for more details. There may have been networking problems so please try again in a few minutes.
76     exit /b 1
77   )
78 )
79
80 set targets=RestoreNETCorePlatforms
81
82 if [%packages%] == [true] (
83   set options=!options! /t:!targets! /p:RestoreDuringBuild=true
84   echo msbuild.exe %~dp0build.proj !options! !unprocessedBuildArgs! >> %synclog%
85   call msbuild.exe %~dp0build.proj !options! !unprocessedBuildArgs!
86   if NOT [!ERRORLEVEL!]==[0] (
87     echo ERROR: An error occurred while syncing packages, see %synclog% for more details. There may have been networking problems so please try again in a few minutes.
88     exit /b 1
89   )
90 )
91
92 echo Done Syncing.
93 exit /b 0
94
95 goto :EOF
96
97 :Usage
98 echo.
99 echo Repository syncing script.
100 echo.
101 echo Options:
102 echo     /s     - Fetches source history from all configured remotes
103 echo              (git fetch --all -p -v)
104 echo     /p     - Restores all nuget packages for repository
105 echo     /ab    - Downloads the latests product packages from Azure.
106 echo              The following properties are required:
107 echo                 /p:CloudDropAccountName="Account name"
108 echo                 /p:CloudDropAccessToken="Access token"
109 echo              To download a specific group of product packages, specify:
110 echo                 /p:BuildNumberMajor
111 echo                 /p:BuildNumberMinor
112 echo.
113 echo.
114 echo If no option is specified then sync.cmd /s /p is implied.