From 37b78b2918af1aaedb179db5b5e619dfc46f8166 Mon Sep 17 00:00:00 2001 From: Sridhar Periyasamy Date: Tue, 20 Oct 2015 10:46:28 -0700 Subject: [PATCH] Add the self-hosting build script for linux - build.sh will not install dotnet using apt-get from a feed. The installed dotnet is used to build teh cli repo and to produce teh dotnet deb package - Download the dnx dependency for dotnet restore - Fix dotnet-restore script file permission issues --- build.sh | 71 +++++++++++++++++-- scripts/dotnet-restore | 0 .../project.json | 8 +++ 3 files changed, 72 insertions(+), 7 deletions(-) mode change 100644 => 100755 scripts/dotnet-restore create mode 100644 src/Microsoft.DotNet.Tools.Restore/project.json diff --git a/build.sh b/build.sh index f5f7ae86e..69ec08c57 100755 --- a/build.sh +++ b/build.sh @@ -11,26 +11,85 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +UNAME=$(uname) + + +if [ "$UNAME" == "Darwin" ]; then + echo "Building Currently not supported on OSX" + exit 1 +fi + + REPO_ROOT=$DIR OUTPUT_DIR="$REPO_ROOT/bin" PACKAGE_LAYOUT_DIR="$OUTPUT_DIR/package_layout" PACKAGE_OUTPUT_DIR="$OUTPUT_DIR/package_output" -REPO_BINARIES_DIR="$REPO_ROOT/artifacts/ubuntu.14.04-x64" +REPO_BINARIES_DIR="$REPO_ROOT/bin/$UNAME" execute(){ + install_dotnet build_repo create_empty_debian_layout copy_files_to_debian_layout create_debian_package } -acquire_previous_version(){ +install_dotnet(){ + sudo sh -c 'echo "deb [arch=amd64] http://tux-devrepo.corp.microsoft.com/repos/dotnet-dev/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' + sudo apt-key adv --keyserver tux-devrepo.corp.microsoft.com --recv-keys 008C0E6C + sudo apt-get update + + # install/upgrade dotnet debian package + echo "Installing dotnet.." + + sudo apt-get install dotnet + + if [[ $? > 0 ]] + then + echo "Installing 'dotnet' failed, exiting." + exit 1 + else + echo "Installing 'dotnet' succeeded." + fi } build_repo(){ + if [ -z "$RID" ]; then + if [ "$UNAME" == "Darwin" ]; then + RID=osx.10.10-x64 + elif [ "$UNAME" == "Linux" ]; then + # Detect Distro? + RID=ubuntu.14.04-x64 + else + echo "Unknown OS: $UNAME" 1>&2 + exit 1 + fi + fi + dotnet restore "$REPO_ROOT" --runtime osx.10.10-x64 --runtime ubuntu.14.04-x64 --runtime osx.10.11-x64 + + dirs=(`find ./src -type f -iname 'project.json' | sed -r 's|/[^/]+$||' |sort |uniq`) + + for i in ${dirs[@]}; do + echo "Building directory $i"; + pushd $i + # HACK for getting dnu. Right now dotnet-restore depends on dnu. + # Restore the dnx package into tmp and copy the binaries into the output folder + if [[ $i == *"Microsoft.DotNet.Tools.Restore"* ]]; then + dotnet restore . --runtime $RID --packages /tmp + mkdir $REPO_BINARIES_DIR/dnx + cp -r /tmp/dnx-coreclr-linux-x64/1.0.0-*/bin/* "$REPO_BINARIES_DIR/dnx/" + cp "$REPO_ROOT/scripts/dotnet-restore" "$REPO_BINARIES_DIR" + elif [[ $i == *"Microsoft.Extensions.ProjectModel"* ]]; then + : + #HACK to prevent publishing of Microsoft.Extensions.ProjectModel + else + dotnet-publish --framework dnxcore50 --runtime $RID --output "$REPO_BINARIES_DIR" . + fi + popd + done } create_empty_debian_layout(){ @@ -49,12 +108,10 @@ copy_files_to_debian_layout(){ # Copy config file cp "$REPO_ROOT/debian_config.json" "$PACKAGE_LAYOUT_DIR" - - # Copy Wrapper Scripts - # TODO: This is a workaround for https://github.com/dotnet/coreclr/issues/1774 - cp "$REPO_ROOT/wrappers/." "PACKAGE_LAYOUT_DIR/package_root" } create_debian_package(){ $DIR/package_tool/package_tool $PACKAGE_LAYOUT_DIR $PACKAGE_OUTPUT_DIR -} \ No newline at end of file +} + +execute diff --git a/scripts/dotnet-restore b/scripts/dotnet-restore old mode 100644 new mode 100755 diff --git a/src/Microsoft.DotNet.Tools.Restore/project.json b/src/Microsoft.DotNet.Tools.Restore/project.json new file mode 100644 index 000000000..1bd64a4a5 --- /dev/null +++ b/src/Microsoft.DotNet.Tools.Restore/project.json @@ -0,0 +1,8 @@ +{ + "dependencies": { + "dnx-coreclr-linux-x64": "1.0.0-*", + }, + "frameworks": { + "dnxcore50": { } + } +}