-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathappcenter-pre-build.sh
executable file
·38 lines (33 loc) · 1.19 KB
/
appcenter-pre-build.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
#!/usr/bin/env bash
#
# For Xamarin, change some constants located in some class of the app.
# In this sample, suppose we have an AppConstant.cs class in shared folder with follow content:
#
# namespace Core
# {
# public class AppConstant
# {
# public const string ApiUrl = "https://CMS_MyApp-Eur01.com/api";
# }
# }
#
# Suppose in our project exists two branches: master and develop.
# We can release app for production API in master branch and app for test API in develop branch.
# We just need configure this behaviour with environment variable in each branch :)
#
# The same thing can be perform with any class of the app.
#
# AN IMPORTANT THING: FOR THIS SAMPLE YOU NEED DECLARE API_URL ENVIRONMENT VARIABLE IN APP CENTER BUILD CONFIGURATION.
if [ -z "$appcenterID" ]
then
echo "You need define the appcenterID variable in App Center"
exit
fi
APP_CONSTANT_FILE=$APPCENTER_SOURCE_DIRECTORY/PiholeDashboard/AppConstant.cs
if [ -e "$APP_CONSTANT_FILE" ]
then
echo "Updating ApiUrl to $appcenterID in AppConstant.cs"
sed -i '' 's#appcenterID = "[-A-Za-z0-9:_./]*"#appcenterID = "'$appcenterID'"#' $APP_CONSTANT_FILE
echo "File content:"
cat $APP_CONSTANT_FILE
fi