forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestoreglobal.sh
37 lines (31 loc) · 1.04 KB
/
restoreglobal.sh
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
#!/bin/bash
# =================================
# Script used to restore packages
# for projects that have a global
# project file (global.json).
#
# Last Update: 08/04/2016
# Author: Den Delimarsky
# =================================
# For reference purposes, get the local home path that will be used
# as the root for file-related operations.
HPATH=$PWD
echo $HPATH
# Variable used to track the success of the overall script execution.
SCRIPT_OUTPUT=0
# Read the file that contains the list of global project files
# line-by-line and trigger a dotnet restore.
# SCRIPT_OUTPUT will be incremented for any non-zero results.
while IFS='' read -r line || [[ -n "$line" ]]; do
DIR=$(dirname "${line}")
cd $DIR
dotnet restore |& tee --append $HPATH/$BUILD_TAG/buildlog.txt
SCRIPT_OUTPUT=$((${PIPESTATUS[0]} + $SCRIPT_OUTPUT))
done < $HPATH/global.projects
# Only if SCRIPT_OUTPUT is still zero means that the script
# execution completed successfully. Otherwise, force a failure.
if [ $SCRIPT_OUTPUT -eq 0 ]; then
exit 0
else
exit 1
fi