ci-source-build.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env bash
  2. #
  3. # This script is meant for testing source build by imitating some of the input parameters and conditions.
  4. #
  5. set -euo pipefail
  6. scriptroot="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  7. reporoot="$(dirname "$(dirname "$scriptroot")")"
  8. # For local development, make a backup copy of this file first
  9. if [ ! -f "$reporoot/global.bak.json" ]; then
  10. mv "$reporoot/global.json" "$reporoot/global.bak.json"
  11. fi
  12. # Detect the current version of .NET Core installed
  13. export SDK_VERSION=$(dotnet --version)
  14. echo "The ambient version of .NET Core SDK version = $SDK_VERSION"
  15. # Update the global.json file to match the current .NET environment
  16. cat "$reporoot/global.bak.json" | \
  17. jq '.sdk.version=env.SDK_VERSION' | \
  18. jq '.tools.dotnet=env.SDK_VERSION' | \
  19. jq 'del(.tools.runtimes)' \
  20. > "$reporoot/global.json"
  21. # Restore the original global.json file
  22. trap "{
  23. mv "$reporoot/global.bak.json" "$reporoot/global.json"
  24. }" EXIT
  25. export DotNetBuildFromSource='true'
  26. # Build repo tasks
  27. "$reporoot/eng/common/build.sh" --restore --build --ci --configuration Release /p:ProjectToBuild=$reporoot/eng/tools/RepoTasks/RepoTasks.csproj
  28. # Build projects
  29. "$reporoot/eng/common/build.sh" --restore --build --pack "$@"