2017-05-01 04:17:01 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2017-07-07 23:49:03 +03:00
|
|
|
# Usage:
|
|
|
|
# Build the project in the local environment: ./scripts/build
|
|
|
|
# Build the project inside a Docker container: ./scripts/build -s
|
|
|
|
# Build the project inside a Docker container: ./scripts/build --in-sandbox
|
|
|
|
|
2017-05-01 04:17:01 +03:00
|
|
|
# Debug|Release
|
|
|
|
CONFIGURATION=Release
|
|
|
|
|
|
|
|
set -e
|
|
|
|
APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )/"
|
|
|
|
source "$APP_HOME/scripts/.functions.sh"
|
|
|
|
|
2017-07-07 23:49:03 +03:00
|
|
|
# Folder where PCS sandboxes cache data. Reuse the same folder to speed up the
|
|
|
|
# sandbox and to save disk space.
|
|
|
|
# Use PCS_CACHE="$APP_HOME/.cache" to cache inside the project folder
|
|
|
|
PCS_CACHE="/tmp/azure/iotpcs/.cache"
|
|
|
|
|
2017-05-01 04:17:01 +03:00
|
|
|
compile() {
|
Migrate to .NET Core (#9)
Upgrade source code, project files and scripts to use .NET Core. Mono is not required anymore, and also the Docker image will now use only .NET Core.
The configuration format has changed to be in line with ASP.NET Core configuration providers.
The simulation runner is temporarily disabled, because Akka.NET is not ready for .NET Core, and I'm in the middle of removing Akka from the project as well.
Due to the move from .NET Core, some internal APIs are different, for instance you might notice changes in the web service exception filter, in the Autofac dependency injection setup, in the use of Kestrel as a HTTP server.
Since the microservice is now built and packaged with the `dotnet` command, some paths have changed, and scripts have been updated accordingly. I tested the scripts in Windows and MacOS, hopefully catching all the edge cases. The scripts are now actually simpler, which is a nice and unexpected result of the migration.
2017-06-21 04:52:50 +03:00
|
|
|
check_dependency_dotnet
|
2017-05-26 04:22:07 +03:00
|
|
|
|
|
|
|
cd $APP_HOME
|
2017-08-09 04:10:43 +03:00
|
|
|
./scripts/env-vars-check
|
|
|
|
|
2017-05-26 04:22:07 +03:00
|
|
|
header "Downloading dependencies..."
|
Migrate to .NET Core (#9)
Upgrade source code, project files and scripts to use .NET Core. Mono is not required anymore, and also the Docker image will now use only .NET Core.
The configuration format has changed to be in line with ASP.NET Core configuration providers.
The simulation runner is temporarily disabled, because Akka.NET is not ready for .NET Core, and I'm in the middle of removing Akka from the project as well.
Due to the move from .NET Core, some internal APIs are different, for instance you might notice changes in the web service exception filter, in the Autofac dependency injection setup, in the use of Kestrel as a HTTP server.
Since the microservice is now built and packaged with the `dotnet` command, some paths have changed, and scripts have been updated accordingly. I tested the scripts in Windows and MacOS, hopefully catching all the edge cases. The scripts are now actually simpler, which is a nice and unexpected result of the migration.
2017-06-21 04:52:50 +03:00
|
|
|
dotnet restore
|
2017-05-26 04:22:07 +03:00
|
|
|
|
|
|
|
header "Compiling code..."
|
Migrate to .NET Core (#9)
Upgrade source code, project files and scripts to use .NET Core. Mono is not required anymore, and also the Docker image will now use only .NET Core.
The configuration format has changed to be in line with ASP.NET Core configuration providers.
The simulation runner is temporarily disabled, because Akka.NET is not ready for .NET Core, and I'm in the middle of removing Akka from the project as well.
Due to the move from .NET Core, some internal APIs are different, for instance you might notice changes in the web service exception filter, in the Autofac dependency injection setup, in the use of Kestrel as a HTTP server.
Since the microservice is now built and packaged with the `dotnet` command, some paths have changed, and scripts have been updated accordingly. I tested the scripts in Windows and MacOS, hopefully catching all the edge cases. The scripts are now actually simpler, which is a nice and unexpected result of the migration.
2017-06-21 04:52:50 +03:00
|
|
|
dotnet build --configuration $CONFIGURATION
|
2017-05-01 04:17:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
run_tests() {
|
2017-05-26 04:22:07 +03:00
|
|
|
check_dependency_dotnet
|
|
|
|
|
|
|
|
cd $APP_HOME
|
|
|
|
header "Running tests..."
|
Migrate to .NET Core (#9)
Upgrade source code, project files and scripts to use .NET Core. Mono is not required anymore, and also the Docker image will now use only .NET Core.
The configuration format has changed to be in line with ASP.NET Core configuration providers.
The simulation runner is temporarily disabled, because Akka.NET is not ready for .NET Core, and I'm in the middle of removing Akka from the project as well.
Due to the move from .NET Core, some internal APIs are different, for instance you might notice changes in the web service exception filter, in the Autofac dependency injection setup, in the use of Kestrel as a HTTP server.
Since the microservice is now built and packaged with the `dotnet` command, some paths have changed, and scripts have been updated accordingly. I tested the scripts in Windows and MacOS, hopefully catching all the edge cases. The scripts are now actually simpler, which is a nice and unexpected result of the migration.
2017-06-21 04:52:50 +03:00
|
|
|
PROJECTS=$(dotnet sln list | grep 'csproj$' | grep '\.Test')
|
2017-05-01 04:17:01 +03:00
|
|
|
for PROJ in $PROJECTS; do
|
2017-05-26 04:22:07 +03:00
|
|
|
echo "-- $PROJ"
|
2017-07-07 23:49:03 +03:00
|
|
|
dotnet test --configuration $CONFIGURATION $PROJ
|
2017-05-01 04:17:01 +03:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2017-07-07 23:49:03 +03:00
|
|
|
setup_sandbox_cache() {
|
|
|
|
mkdir -p $PCS_CACHE/sandbox/.config
|
|
|
|
mkdir -p $PCS_CACHE/sandbox/.dotnet
|
|
|
|
mkdir -p $PCS_CACHE/sandbox/.nuget
|
2017-07-21 22:20:25 +03:00
|
|
|
echo "Note: caching build files in $PCS_CACHE"
|
2017-07-07 23:49:03 +03:00
|
|
|
}
|
|
|
|
|
2017-05-26 04:22:07 +03:00
|
|
|
build_in_sandbox() {
|
2017-07-07 23:49:03 +03:00
|
|
|
|
|
|
|
setup_sandbox_cache
|
|
|
|
|
2017-05-26 04:22:07 +03:00
|
|
|
cd $APP_HOME
|
2017-07-07 23:49:03 +03:00
|
|
|
|
2017-07-21 22:20:25 +03:00
|
|
|
# In Windows this script should use docker.exe, in which case
|
2017-07-07 23:49:03 +03:00
|
|
|
# the parameters syntax is different, e.g. volumes path
|
|
|
|
# (i.e. C:\path\path\... vs /c/path/path/...).
|
|
|
|
#
|
|
|
|
# Note that this script is also used for the git precommit hook.
|
|
|
|
set +e
|
|
|
|
IS_WINDOWS=$(which cmd.exe)
|
|
|
|
set -e
|
|
|
|
if [[ -z "$IS_WINDOWS" ]]; then
|
|
|
|
check_dependency_docker
|
2017-07-11 20:28:55 +03:00
|
|
|
docker run -it \
|
2017-08-09 04:10:43 +03:00
|
|
|
-e "PCS_IOTHUB_CONNSTRING=$PCS_IOTHUB_CONNSTRING" \
|
2017-07-07 23:49:03 +03:00
|
|
|
-v "$PCS_CACHE/sandbox/.config:/root/.config" \
|
|
|
|
-v "$PCS_CACHE/sandbox/.dotnet:/root/.dotnet" \
|
|
|
|
-v "$PCS_CACHE/sandbox/.nuget:/root/.nuget" \
|
|
|
|
-v "$APP_HOME:/opt/code" \
|
2017-07-21 22:20:25 +03:00
|
|
|
azureiotpcs/code-builder-dotnet:1.0-dotnetcore /opt/code/scripts/build
|
2017-07-07 23:49:03 +03:00
|
|
|
else
|
|
|
|
# Note 'winpty' is required to provide a TTY to Docker
|
2017-07-21 22:20:25 +03:00
|
|
|
echo "Launching cmd.exe /c winpty ..."
|
|
|
|
cmd.exe /c "winpty .\scripts\build.cmd --in-sandbox"
|
2017-07-07 23:49:03 +03:00
|
|
|
fi
|
2017-05-26 04:22:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if [[ "$1" == "--in-sandbox" || "$1" == "-s" ]]; then
|
|
|
|
build_in_sandbox
|
|
|
|
else
|
2017-07-07 23:49:03 +03:00
|
|
|
# workaround for https://github.com/dotnet/cli/issues/3995
|
|
|
|
unset home
|
|
|
|
|
2017-05-26 04:22:07 +03:00
|
|
|
compile
|
|
|
|
run_tests
|
|
|
|
fi
|
|
|
|
|
|
|
|
set +e
|