├── .editorconfig ├── .gitattributes ├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── appveyor.yml ├── build ├── KoreBuild.proj ├── KoreBuild.ps1 ├── KoreBuild.sh ├── NuGet.config ├── cli.version ├── dotnet │ ├── dotnet-install.ps1 │ └── dotnet-install.sh ├── msbuild │ └── KoreBuild.RepoTasks.Sdk │ │ └── Sdk │ │ ├── Sdk.props │ │ └── Sdk.targets ├── shared-runtime.version ├── shared │ └── sharedsources.csproj └── targets │ ├── KoreBuild.Common.props │ ├── KoreBuild.Common.targets │ ├── KoreBuild.DefaultBuildSettings.props │ ├── KoreBuild.SolutionBuild.targets │ ├── KoreBuild.SolutionItems.targets │ └── Project.CSharp.Resx.targets └── test ├── build-canary-repo.ps1 └── build-canary-repo.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | ; EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | # Xml files 12 | [*.{csproj,config,props,targets,ruleset,config,resx,xml}] 13 | indent_size = 2 14 | 15 | [*.{json, yml}] 16 | indent_size = 2 17 | 18 | [*.{ps1,sh}] 19 | indent_size = 4 20 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.sh eol=lf 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | This repository contains scripts used to build ASP.NET Core and Entity Framework Core. 2 | 3 | These scripts are not supported products of Microsoft and are intended for Microsoft use only. 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build2/Tools 2 | project.lock.json 3 | 4 | [Oo]bj/ 5 | [Bb]in/ 6 | TestResults/ 7 | .nuget/ 8 | _ReSharper.*/ 9 | packages/ 10 | artifacts/ 11 | PublishProfiles/ 12 | *.user 13 | *.suo 14 | *.cache 15 | *.docstates 16 | _ReSharper.* 17 | *.exe 18 | *.dll 19 | *net45.csproj 20 | *net451.csproj 21 | *k10.csproj 22 | *.psess 23 | *.vsp 24 | *.pidb 25 | *.userprefs 26 | *DS_Store 27 | *.ncrunchsolution 28 | *.*sdf 29 | *.ipch 30 | *.sln.ide 31 | project.lock.json 32 | .vs 33 | .build/ 34 | .testPublish/ 35 | 36 | # Korebuild logs 37 | korebuild.msbuild.log 38 | korebuild.log 39 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: csharp 2 | sudo: false 3 | dist: trusty 4 | env: 5 | global: 6 | - DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true 7 | - DOTNET_CLI_TELEMETRY_OPTOUT=1 8 | mono: none 9 | os: 10 | - linux 11 | - osx 12 | osx_image: xcode8.2 13 | addons: 14 | apt: 15 | packages: 16 | - libunwind8 17 | branches: 18 | only: 19 | - master 20 | - release 21 | - dev 22 | - /^(.*\/)?ci-.*$/ 23 | - /^rel\/.*/ 24 | before_install: 25 | - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi 26 | script: 27 | - ./test/build-canary-repo.sh 28 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ====== 3 | 4 | Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) in the Home repo. 5 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | KoreBuild - OBSOLETE 2 | ========= 3 | 4 | ## Obsolete notice 5 | 6 | These build scripts are obsolete. 7 | The recommended replacements are available at https://github.com/aspnet/BuildTools. 8 | 9 | ## About this repo 10 | 11 | [![Travis build status](https://img.shields.io/travis/aspnet/KoreBuild.svg?label=travis-ci&branch=dev&style=flat-square)](https://travis-ci.org/aspnet/KoreBuild/branches) 12 | [![AppVeyor build status](https://img.shields.io/appveyor/ci/aspnetci/KoreBuild/dev.svg?label=appveyor&style=flat-square)](https://ci.appveyor.com/project/aspnetci/KoreBuild/branch/dev) 13 | 14 | Build scripts for repos on https://github.com/aspnet. 15 | 16 | This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [Home](https://github.com/aspnet/home) repo. 17 | 18 | ## Testing 19 | 20 | This repository contains test scripts in the test/ folder. 21 | 22 | ### build-canary-repo.{sh, ps1} 23 | 24 | This script will download a repository and use the local version of KoreBuild to build it. 25 | This serves as a canary test for the scripts but may not exercise all areas of KoreBuild. 26 | 27 | This defaults to using as the canary. 28 | 29 | ## Replaying MSBuild binary log file to a text file 30 | dotnet msbuild .\msbuild.binlog /noconlog /flp:verbosity=diag`;logfile=diagnostic.log /noautoresponse 31 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | init: 2 | - git config --global core.autocrlf true 3 | branches: 4 | only: 5 | - master 6 | - release 7 | - dev 8 | - /^(.*\/)?ci-.*$/ 9 | - /^rel\/.*/ 10 | environment: 11 | global: 12 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true 13 | DOTNET_CLI_TELEMETRY_OPTOUT: 1 14 | build_script: 15 | - ps: .\test\build-canary-repo.ps1 16 | clone_depth: 1 17 | test: off 18 | deploy: off 19 | os: Visual Studio 2017 20 | -------------------------------------------------------------------------------- /build/KoreBuild.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | netcoreapp2.0 8 | 9 | 15 | <_BuildPropertiesToRemove>$(_BuildPropertiesToRemove);RestoreGraphProjectInput;_InvalidConfigurationWarn;_InvalidConfigurationError 16 | 17 | 21 | $(MSBuildProjectFullPath);$(MSBuildThisFileDirectory)shared\sharedsources.csproj 22 | 23 | 24 | 30 | 31 | 32 | 33 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | <_InvalidConfigurationWarn>false 48 | <_InvalidConfigurationError>false 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /build/KoreBuild.ps1: -------------------------------------------------------------------------------- 1 | #requires -version 4 2 | 3 | param([parameter(ValueFromRemainingArguments=$true)][string[]] $allparams) 4 | 5 | Write-Warning @" 6 | 7 | These build scripts are obsolete. 8 | The recommended replacements are available at https://github.com/aspnet/BuildTools. 9 | 10 | "@ 11 | 12 | function __exec($cmd) { 13 | $cmdName = [IO.Path]::GetFileName($cmd) 14 | Write-Host -ForegroundColor Cyan "> $cmdName $args" 15 | $originalErrorPref = $ErrorActionPreference 16 | $ErrorActionPreference = 'Continue' 17 | & $cmd @args 18 | $exitCode = $LASTEXITCODE 19 | $ErrorActionPreference = $originalErrorPref 20 | if($exitCode -ne 0) { 21 | throw "'$cmdName $args' failed with exit code: $exitCode" 22 | } 23 | } 24 | 25 | $repoFolder = $env:REPO_FOLDER 26 | if (!$repoFolder) { 27 | throw "REPO_FOLDER is not set" 28 | } 29 | 30 | Write-Host "Building $repoFolder" 31 | cd $repoFolder 32 | 33 | $dotnetArch = 'x64' 34 | $dotnetVersionFile = $PSScriptRoot + "\cli.version" 35 | $dotnetChannel = "preview" 36 | $dotnetVersion = Get-Content $dotnetVersionFile 37 | $sharedRuntimeVersionFile = $PSScriptRoot + "\shared-runtime.version" 38 | $sharedRuntimeChannel = "master" 39 | $sharedRuntimeVersion = Get-Content $sharedRuntimeVersionFile 40 | 41 | if ($env:KOREBUILD_DOTNET_CHANNEL) 42 | { 43 | $dotnetChannel = $env:KOREBUILD_DOTNET_CHANNEL 44 | } 45 | if ($env:KOREBUILD_DOTNET_VERSION) 46 | { 47 | $dotnetVersion = $env:KOREBUILD_DOTNET_VERSION 48 | } 49 | if ($env:KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL) 50 | { 51 | $sharedRuntimeChannel = $env:KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL 52 | } 53 | if ($env:KOREBUILD_DOTNET_SHARED_RUNTIME_VERSION) 54 | { 55 | $sharedRuntimeVersion = $env:KOREBUILD_DOTNET_SHARED_RUNTIME_VERSION 56 | } 57 | 58 | $dotnetLocalInstallFolder = $env:DOTNET_INSTALL_DIR 59 | if (!$dotnetLocalInstallFolder) 60 | { 61 | $dotnetLocalInstallFolder = "$env:USERPROFILE\.dotnet\$dotnetArch\" 62 | } 63 | 64 | function InstallSharedRuntime([string] $version, [string] $channel) 65 | { 66 | $sharedRuntimePath = [IO.Path]::Combine($dotnetLocalInstallFolder, 'shared', 'Microsoft.NETCore.App', $version) 67 | # Avoid redownloading the CLI if it's already installed. 68 | if (!(Test-Path $sharedRuntimePath)) 69 | { 70 | & "$PSScriptRoot\dotnet\dotnet-install.ps1" -Channel $channel ` 71 | -SharedRuntime ` 72 | -Version $version ` 73 | -Architecture $dotnetArch ` 74 | -InstallDir $dotnetLocalInstallFolder 75 | } 76 | } 77 | 78 | function BuildTaskProject { 79 | $taskProj = "$repoFolder/build/tasks/RepoTasks.csproj" 80 | $publishFolder = "$repoFolder/build/tasks/bin/publish/" 81 | 82 | if (!(Test-Path $taskProj)) { 83 | return 84 | } 85 | 86 | if (Test-Path $publishFolder) { 87 | Remove-Item $publishFolder -Recurse -Force 88 | } 89 | 90 | $sdkPath = "/p:RepoTasksSdkPath=$PSScriptRoot/msbuild/KoreBuild.RepoTasks.Sdk/Sdk/" 91 | __exec dotnet restore $taskProj $sdkPath 92 | __exec dotnet publish $taskProj --configuration Release --output $publishFolder $sdkPath 93 | } 94 | 95 | $newPath = "$dotnetLocalInstallFolder;$env:PATH" 96 | if ($env:KOREBUILD_SKIP_RUNTIME_INSTALL -eq "1") 97 | { 98 | Write-Host "Skipping runtime installation because KOREBUILD_SKIP_RUNTIME_INSTALL = 1" 99 | # Add to the _end_ of the path in case preferred .NET CLI is not in the default location. 100 | $newPath = "$env:PATH;$dotnetLocalInstallFolder" 101 | } 102 | else 103 | { 104 | # Temporarily install these runtimes to prevent build breaks for repos not yet converted 105 | # 1.0.5 - for tools 106 | InstallSharedRuntime -version "1.0.5" -channel "preview" 107 | # 1.1.2 - for test projects which haven't yet been converted to netcoreapp2.0 108 | InstallSharedRuntime -version "1.1.2" -channel "release/1.1.0" 109 | 110 | if ($sharedRuntimeVersion) 111 | { 112 | InstallSharedRuntime -version $sharedRuntimeVersion -channel $sharedRuntimeChannel 113 | } 114 | 115 | # Install the version of dotnet-cli used to compile 116 | & "$PSScriptRoot\dotnet\dotnet-install.ps1" -Channel $dotnetChannel ` 117 | -Version $dotnetVersion ` 118 | -Architecture $dotnetArch ` 119 | -InstallDir $dotnetLocalInstallFolder 120 | } 121 | 122 | if (!($env:Path.Split(';') -icontains $dotnetLocalInstallFolder)) 123 | { 124 | Write-Host "Adding $dotnetLocalInstallFolder to PATH" 125 | $env:Path = "$newPath" 126 | } 127 | 128 | $makeFileProj = "$PSScriptRoot/KoreBuild.proj" 129 | $msbuildArtifactsDir = "$repoFolder/artifacts/msbuild" 130 | $msBuildResponseFile = "$msbuildArtifactsDir/msbuild.rsp" 131 | 132 | $msBuildLogArgument = "" 133 | 134 | if ($env:KOREBUILD_ENABLE_BINARY_LOG -eq "1") 135 | { 136 | Write-Host "Enabling binary logging because KOREBUILD_ENABLE_BINARY_LOG = 1" 137 | $msbuildLogFilePath = "$msbuildArtifactsDir/msbuild.binlog" 138 | $msBuildLogArgument = "/bl:$msbuildLogFilePath" 139 | } 140 | 141 | $msBuildArguments = @" 142 | /nologo 143 | /m 144 | /p:RepositoryRoot="$repoFolder/" 145 | "$msBuildLogArgument" 146 | /clp:Summary 147 | "$makeFileProj" 148 | "@ 149 | 150 | $allparams | ForEach-Object { $msBuildArguments += "`n`"$_`"" } 151 | 152 | if (!(Test-Path $msbuildArtifactsDir)) 153 | { 154 | mkdir $msbuildArtifactsDir | Out-Null 155 | } 156 | 157 | $msBuildArguments | Out-File -Encoding ASCII -FilePath $msBuildResponseFile 158 | 159 | BuildTaskProject 160 | __exec dotnet restore /p:PreflightRestore=true "$makeFileProj" 161 | __exec dotnet msbuild `@"$msBuildResponseFile" 162 | -------------------------------------------------------------------------------- /build/KoreBuild.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -o pipefail 3 | 4 | # Colors 5 | GREEN="\033[1;32m" 6 | CYAN="\033[0;36m" 7 | YELLOW="\033[0;33m" 8 | RESET="\033[0m" 9 | RED="\033[0;31m" 10 | 11 | echo -e "${YELLOW}" 12 | echo -e "WARNING:" 13 | echo -e "These build scripts are obsolete." 14 | echo -e "The recommended replacements are available at https://github.com/aspnet/BuildTools." 15 | echo -e "${RESET}" 16 | 17 | # functions 18 | 19 | __exec() { 20 | local cmd=$1 21 | shift 22 | 23 | local cmdname=$(basename $cmd) 24 | echo -e "${CYAN}> $cmdname $@${RESET}" 25 | $cmd "$@" 26 | local exitCode=$? 27 | if [ $exitCode -ne 0 ]; then 28 | echo -e "${RED}'$cmdname $@' failed with exit code $exitCode${RESET}" 1>&2 29 | exit $exitCode 30 | fi 31 | } 32 | 33 | msbuild_args="" 34 | repoFolder="" 35 | while [[ $# > 0 ]]; do 36 | case $1 in 37 | -r) 38 | shift 39 | repoFolder=$1 40 | ;; 41 | *) 42 | msbuild_args+="\"$1\"\n" 43 | ;; 44 | esac 45 | shift 46 | done 47 | if [ ! -e "$repoFolder" ]; then 48 | printf "Usage: $filename -r [repoFolder] [ [msbuild-args] ]\n\n" 49 | echo " -r [repo] The repository to build" 50 | echo " [msbuild-args] A space separated list of arguments to pass to MSBuild" 51 | exit 1 52 | fi 53 | 54 | echo "Building $repoFolder" 55 | cd $repoFolder 56 | 57 | scriptRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 58 | 59 | if [ "$(uname)" == "Darwin" ]; then 60 | ulimit -n 2048 61 | 62 | # Check that OS is 10.12 or newer 63 | osx_version="$(sw_vers | grep ProductVersion | awk '{print $2}')" 64 | minor_version="$(echo $osx_version | awk -F '.' '{print $2}')" 65 | if [ $minor_version -lt 12 ]; then 66 | echo -e "${RED}.NET Core 2.0 requires OSX 10.12 or newer. Current version is $osx_version.${RESET}" 67 | exit 1 68 | fi 69 | fi 70 | 71 | versionFile="$scriptRoot/cli.version" 72 | version=$(<$versionFile) 73 | sharedRuntimeVersionFile="$scriptRoot/shared-runtime.version" 74 | sharedRuntimeVersion=$(<$sharedRuntimeVersionFile) 75 | 76 | [ -z "$KOREBUILD_DOTNET_CHANNEL" ] && KOREBUILD_DOTNET_CHANNEL="preview" 77 | [ -z "$KOREBUILD_DOTNET_VERSION" ] && KOREBUILD_DOTNET_VERSION=$version 78 | [ -z "$KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL" ] && KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL="master" 79 | [ -z "$KOREBUILD_DOTNET_SHARED_RUNTIME_VERSION" ] && KOREBUILD_DOTNET_SHARED_RUNTIME_VERSION=$sharedRuntimeVersion 80 | 81 | install_shared_runtime() { 82 | eval $invocation 83 | 84 | local version=$1 85 | local channel=$2 86 | 87 | local sharedRuntimePath="$DOTNET_INSTALL_DIR/shared/Microsoft.NETCore.App/$version" 88 | if [ ! -d "$sharedRuntimePath" ]; then 89 | $scriptRoot/dotnet/dotnet-install.sh \ 90 | --shared-runtime \ 91 | --channel $channel \ 92 | --version $version 93 | 94 | if [ $? -ne 0 ]; then 95 | exit 1 96 | fi 97 | fi 98 | } 99 | 100 | build_taskproject() { 101 | local taskProj="$repoFolder/build/tasks/RepoTasks.csproj" 102 | local publishFolder="$repoFolder/build/tasks/bin/publish/" 103 | 104 | if [[ ! -f $taskProj ]]; then 105 | # skipping 106 | return 107 | fi 108 | 109 | if [[ -d $publishFolder ]]; then 110 | rm -rf $publishFolder 111 | fi 112 | 113 | local sdkPath="/p:RepoTasksSdkPath=$scriptRoot/msbuild/KoreBuild.RepoTasks.Sdk/Sdk/" 114 | __exec dotnet restore $taskProj $sdkPath 115 | __exec dotnet publish $taskProj --configuration Release --output $publishFolder $sdkPath 116 | } 117 | 118 | if [ ! -z "$KOREBUILD_SKIP_RUNTIME_INSTALL" ]; then 119 | echo "Skipping runtime installation because KOREBUILD_SKIP_RUNTIME_INSTALL is set" 120 | 121 | # Add .NET installation directory to the path if it isn't yet included. 122 | # Add to the _end_ in case preferred .NET CLI is not in the default location. 123 | [[ ":$PATH:" != *":$DOTNET_INSTALL_DIR:"* ]] && export PATH="$PATH:$DOTNET_INSTALL_DIR" 124 | else 125 | # Need to set this variable because by default the install script 126 | # requires sudo 127 | [ -z "$DOTNET_INSTALL_DIR" ] && DOTNET_INSTALL_DIR=~/.dotnet 128 | export DOTNET_INSTALL_DIR=$DOTNET_INSTALL_DIR 129 | chmod +x $scriptRoot/dotnet/dotnet-install.sh 130 | 131 | # Temporarily install these runtimes to prevent build breaks for repos not yet converted 132 | # 1.0.5 - for tools 133 | install_shared_runtime "1.0.5" "preview" 134 | # 1.1.2 - for test projects which haven't yet been converted to netcoreapp2.0 135 | install_shared_runtime "1.1.2" "release/1.1.0" 136 | 137 | if [ "$sharedRuntimeVersion" != "" ]; then 138 | install_shared_runtime $KOREBUILD_DOTNET_SHARED_RUNTIME_VERSION $KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL 139 | fi 140 | 141 | $scriptRoot/dotnet/dotnet-install.sh \ 142 | --channel $KOREBUILD_DOTNET_CHANNEL \ 143 | --version $KOREBUILD_DOTNET_VERSION 144 | 145 | if [ $? -ne 0 ]; then 146 | exit 1 147 | fi 148 | 149 | # Add .NET installation directory to the path if it isn't yet included. 150 | [[ ":$PATH:" != *":$DOTNET_INSTALL_DIR:"* ]] && export PATH="$DOTNET_INSTALL_DIR:$PATH" 151 | fi 152 | 153 | netfxversion='4.6.1' 154 | if [ "$NUGET_PACKAGES" == "" ]; then 155 | NUGET_PACKAGES="$HOME/.nuget/packages" 156 | fi 157 | export ReferenceAssemblyRoot=$NUGET_PACKAGES/netframeworkreferenceassemblies/$netfxversion/content 158 | 159 | makeFileProj="$scriptRoot/KoreBuild.proj" 160 | msbuildArtifactsDir="$repoFolder/artifacts/msbuild" 161 | msbuildResponseFile="$msbuildArtifactsDir/msbuild.rsp" 162 | msBuildLogArgument="" 163 | 164 | if [ ! -z "$KOREBUILD_ENABLE_BINARY_LOG" ]; then 165 | echo "Enabling binary logging because KOREBUILD_ENABLE_BINARY_LOG is set" 166 | msBuildLogFile="$msbuildArtifactsDir/msbuild.binlog" 167 | msBuildLogArgument="/bl:$msBuildLogFile" 168 | fi 169 | 170 | if [ ! -f $msbuildArtifactsDir ]; then 171 | mkdir -p $msbuildArtifactsDir 172 | fi 173 | 174 | cat > $msbuildResponseFile <> $msbuildResponseFile 183 | 184 | build_taskproject 185 | __exec dotnet restore /p:PreflightRestore=true /p:NetFxVersion=$netfxversion "$makeFileProj" 186 | __exec dotnet msbuild @"$msbuildResponseFile" 187 | -------------------------------------------------------------------------------- /build/NuGet.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /build/cli.version: -------------------------------------------------------------------------------- 1 | 2.0.0-preview3-006845 2 | -------------------------------------------------------------------------------- /build/dotnet/dotnet-install.ps1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) .NET Foundation and contributors. All rights reserved. 3 | # Licensed under the MIT license. See LICENSE file in the project root for full license information. 4 | # 5 | 6 | <# 7 | .SYNOPSIS 8 | Installs dotnet cli 9 | .DESCRIPTION 10 | Installs dotnet cli. If dotnet installation already exists in the given directory 11 | it will update it only if the requested version differs from the one already installed. 12 | .PARAMETER Channel 13 | Default: release/1.0.0 14 | Download from the Channel specified 15 | .PARAMETER Version 16 | Default: latest 17 | Represents a build version on specific channel. Possible values: 18 | - latest - most latest build on specific channel 19 | - 3-part version in a format A.B.C - represents specific version of build 20 | examples: 2.0.0-preview2-006120; 1.1.0 21 | .PARAMETER InstallDir 22 | Default: %LocalAppData%\Microsoft\dotnet 23 | Path to where to install dotnet. Note that binaries will be placed directly in a given directory. 24 | .PARAMETER Architecture 25 | Default: - this value represents currently running OS architecture 26 | Architecture of dotnet binaries to be installed. 27 | Possible values are: , x64 and x86 28 | .PARAMETER SharedRuntime 29 | Default: false 30 | Installs just the shared runtime bits, not the entire SDK 31 | .PARAMETER DebugSymbols 32 | If set the installer will include symbols in the installation. 33 | .PARAMETER DryRun 34 | If set it will not perform installation but instead display what command line to use to consistently install 35 | currently requested version of dotnet cli. In example if you specify version 'latest' it will display a link 36 | with specific version so that this command can be used deterministicly in a build script. 37 | It also displays binaries location if you prefer to install or download it yourself. 38 | .PARAMETER NoPath 39 | By default this script will set environment variable PATH for the current process to the binaries folder inside installation folder. 40 | If set it will display binaries location but not set any environment variable. 41 | .PARAMETER Verbose 42 | Displays diagnostics information. 43 | .PARAMETER AzureFeed 44 | Default: https://dotnetcli.azureedge.net/dotnet 45 | This parameter typically is not changed by the user. 46 | It allows to change URL for the Azure feed used by this installer. 47 | .PARAMETER UncachedFeed 48 | This parameter typically is not changed by the user. 49 | It allows to change URL for the Uncached feed used by this installer. 50 | .PARAMETER ProxyAddress 51 | If set, the installer will use the proxy when making web requests 52 | .PARAMETER ProxyUseDefaultCredentials 53 | Default: false 54 | Use default credentials, when using proxy address. 55 | #> 56 | [cmdletbinding()] 57 | param( 58 | [string]$Channel="release/1.0.0", 59 | [string]$Version="Latest", 60 | [string]$InstallDir="", 61 | [string]$Architecture="", 62 | [switch]$SharedRuntime, 63 | [switch]$DebugSymbols, # TODO: Switch does not work yet. Symbols zip is not being uploaded yet. 64 | [switch]$DryRun, 65 | [switch]$NoPath, 66 | [string]$AzureFeed="https://dotnetcli.azureedge.net/dotnet", 67 | [string]$UncachedFeed="https://dotnetcli.blob.core.windows.net/dotnet", 68 | [string]$ProxyAddress, 69 | [switch]$ProxyUseDefaultCredentials 70 | ) 71 | 72 | Set-StrictMode -Version Latest 73 | $ErrorActionPreference="Stop" 74 | $ProgressPreference="SilentlyContinue" 75 | 76 | $BinFolderRelativePath="" 77 | 78 | # example path with regex: shared/1.0.0-beta-12345/somepath 79 | $VersionRegEx="/\d+\.\d+[^/]+/" 80 | $OverrideNonVersionedFiles=$true 81 | 82 | function Say($str) { 83 | Write-Output "dotnet-install: $str" 84 | } 85 | 86 | function Say-Verbose($str) { 87 | Write-Verbose "dotnet-install: $str" 88 | } 89 | 90 | function Say-Invocation($Invocation) { 91 | $command = $Invocation.MyCommand; 92 | $args = (($Invocation.BoundParameters.Keys | foreach { "-$_ `"$($Invocation.BoundParameters[$_])`"" }) -join " ") 93 | Say-Verbose "$command $args" 94 | } 95 | 96 | function Invoke-With-Retry([ScriptBlock]$ScriptBlock, [int]$MaxAttempts = 3, [int]$SecondsBetweenAttempts = 1) { 97 | $Attempts = 0 98 | 99 | while ($true) { 100 | try { 101 | return $ScriptBlock.Invoke() 102 | } 103 | catch { 104 | $Attempts++ 105 | if ($Attempts -lt $MaxAttempts) { 106 | Start-Sleep $SecondsBetweenAttempts 107 | } 108 | else { 109 | throw 110 | } 111 | } 112 | } 113 | } 114 | 115 | function Get-Machine-Architecture() { 116 | Say-Invocation $MyInvocation 117 | 118 | # possible values: AMD64, IA64, x86 119 | return $ENV:PROCESSOR_ARCHITECTURE 120 | } 121 | 122 | # TODO: Architecture and CLIArchitecture should be unified 123 | function Get-CLIArchitecture-From-Architecture([string]$Architecture) { 124 | Say-Invocation $MyInvocation 125 | 126 | switch ($Architecture.ToLower()) { 127 | { $_ -eq "" } { return Get-CLIArchitecture-From-Architecture $(Get-Machine-Architecture) } 128 | { ($_ -eq "amd64") -or ($_ -eq "x64") } { return "x64" } 129 | { $_ -eq "x86" } { return "x86" } 130 | default { throw "Architecture not supported. If you think this is a bug, please report it at https://github.com/dotnet/cli/issues" } 131 | } 132 | } 133 | 134 | function Get-Version-Info-From-Version-Text([string]$VersionText) { 135 | Say-Invocation $MyInvocation 136 | 137 | $Data = @($VersionText.Split([char[]]@(), [StringSplitOptions]::RemoveEmptyEntries)); 138 | 139 | $VersionInfo = @{} 140 | $VersionInfo.CommitHash = $Data[0].Trim() 141 | $VersionInfo.Version = $Data[1].Trim() 142 | return $VersionInfo 143 | } 144 | 145 | function Load-Assembly([string] $Assembly) { 146 | try { 147 | Add-Type -Assembly $Assembly | Out-Null 148 | } 149 | catch { 150 | # On Nano Server, Powershell Core Edition is used. Add-Type is unable to resolve base class assemblies because they are not GAC'd. 151 | # Loading the base class assemblies is not unnecessary as the types will automatically get resolved. 152 | } 153 | } 154 | 155 | function GetHTTPResponse([Uri] $Uri) 156 | { 157 | Invoke-With-Retry( 158 | { 159 | 160 | $HttpClient = $null 161 | 162 | try { 163 | # HttpClient is used vs Invoke-WebRequest in order to support Nano Server which doesn't support the Invoke-WebRequest cmdlet. 164 | Load-Assembly -Assembly System.Net.Http 165 | 166 | if(-not $ProxyAddress) 167 | { 168 | # Despite no proxy being explicitly specified, we may still be behind a default proxy 169 | $DefaultProxy = [System.Net.WebRequest]::DefaultWebProxy; 170 | if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))){ 171 | $ProxyAddress = $DefaultProxy.GetProxy($Uri).OriginalString 172 | $ProxyUseDefaultCredentials = $true 173 | } 174 | } 175 | 176 | if($ProxyAddress){ 177 | $HttpClientHandler = New-Object System.Net.Http.HttpClientHandler 178 | $HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{Address=$ProxyAddress;UseDefaultCredentials=$ProxyUseDefaultCredentials} 179 | $HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler 180 | } 181 | else { 182 | $HttpClient = New-Object System.Net.Http.HttpClient 183 | } 184 | # Default timeout for HttpClient is 100s. For a 50 MB download this assumes 500 KB/s average, any less will time out 185 | # 10 minutes allows it to work over much slower connections. 186 | $HttpClient.Timeout = New-TimeSpan -Minutes 10 187 | $Response = $HttpClient.GetAsync($Uri).Result 188 | if (($Response -eq $null) -or (-not ($Response.IsSuccessStatusCode))) 189 | { 190 | $ErrorMsg = "Failed to download $Uri." 191 | if ($Response -ne $null) 192 | { 193 | $ErrorMsg += " $Response" 194 | } 195 | 196 | throw $ErrorMsg 197 | } 198 | 199 | return $Response 200 | } 201 | finally { 202 | if ($HttpClient -ne $null) { 203 | $HttpClient.Dispose() 204 | } 205 | } 206 | }) 207 | } 208 | 209 | 210 | function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel) { 211 | Say-Invocation $MyInvocation 212 | 213 | $VersionFileUrl = $null 214 | if ($SharedRuntime) { 215 | $VersionFileUrl = "$UncachedFeed/Runtime/$Channel/latest.version" 216 | } 217 | else { 218 | $VersionFileUrl = "$UncachedFeed/Sdk/$Channel/latest.version" 219 | } 220 | 221 | $Response = GetHTTPResponse -Uri $VersionFileUrl 222 | $StringContent = $Response.Content.ReadAsStringAsync().Result 223 | 224 | switch ($Response.Content.Headers.ContentType) { 225 | { ($_ -eq "application/octet-stream") } { $VersionText = [Text.Encoding]::UTF8.GetString($StringContent) } 226 | { ($_ -eq "text/plain") } { $VersionText = $StringContent } 227 | { ($_ -eq "text/plain; charset=UTF-8") } { $VersionText = $StringContent } 228 | default { throw "``$Response.Content.Headers.ContentType`` is an unknown .version file content type." } 229 | } 230 | 231 | $VersionInfo = Get-Version-Info-From-Version-Text $VersionText 232 | 233 | return $VersionInfo 234 | } 235 | 236 | 237 | function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$Channel, [string]$Version) { 238 | Say-Invocation $MyInvocation 239 | 240 | switch ($Version.ToLower()) { 241 | { $_ -eq "latest" } { 242 | $LatestVersionInfo = Get-Latest-Version-Info -AzureFeed $AzureFeed -Channel $Channel 243 | return $LatestVersionInfo.Version 244 | } 245 | default { return $Version } 246 | } 247 | } 248 | 249 | function Get-Download-Link([string]$AzureFeed, [string]$Channel, [string]$SpecificVersion, [string]$CLIArchitecture) { 250 | Say-Invocation $MyInvocation 251 | 252 | if ($SharedRuntime) { 253 | $PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-runtime-$SpecificVersion-win-$CLIArchitecture.zip" 254 | } 255 | else { 256 | $PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-sdk-$SpecificVersion-win-$CLIArchitecture.zip" 257 | } 258 | 259 | Say-Verbose "Constructed primary payload URL: $PayloadURL" 260 | 261 | return $PayloadURL 262 | } 263 | 264 | function Get-AltDownload-Link([string]$AzureFeed, [string]$Channel, [string]$SpecificVersion, [string]$CLIArchitecture) { 265 | Say-Invocation $MyInvocation 266 | 267 | if ($SharedRuntime) { 268 | $PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-win-$CLIArchitecture.$SpecificVersion.zip" 269 | } 270 | else { 271 | $PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-dev-win-$CLIArchitecture.$SpecificVersion.zip" 272 | } 273 | 274 | Say-Verbose "Constructed alternate payload URL: $PayloadURL" 275 | 276 | return $PayloadURL 277 | } 278 | 279 | function Get-User-Share-Path() { 280 | Say-Invocation $MyInvocation 281 | 282 | $InstallRoot = $env:DOTNET_INSTALL_DIR 283 | if (!$InstallRoot) { 284 | $InstallRoot = "$env:LocalAppData\Microsoft\dotnet" 285 | } 286 | return $InstallRoot 287 | } 288 | 289 | function Resolve-Installation-Path([string]$InstallDir) { 290 | Say-Invocation $MyInvocation 291 | 292 | if ($InstallDir -eq "") { 293 | return Get-User-Share-Path 294 | } 295 | return $InstallDir 296 | } 297 | 298 | function Get-Version-Info-From-Version-File([string]$InstallRoot, [string]$RelativePathToVersionFile) { 299 | Say-Invocation $MyInvocation 300 | 301 | $VersionFile = Join-Path -Path $InstallRoot -ChildPath $RelativePathToVersionFile 302 | Say-Verbose "Local version file: $VersionFile" 303 | 304 | if (Test-Path $VersionFile) { 305 | $VersionText = cat $VersionFile 306 | Say-Verbose "Local version file text: $VersionText" 307 | return Get-Version-Info-From-Version-Text $VersionText 308 | } 309 | 310 | Say-Verbose "Local version file not found." 311 | 312 | return $null 313 | } 314 | 315 | function Is-Dotnet-Package-Installed([string]$InstallRoot, [string]$RelativePathToPackage, [string]$SpecificVersion) { 316 | Say-Invocation $MyInvocation 317 | 318 | $DotnetPackagePath = Join-Path -Path $InstallRoot -ChildPath $RelativePathToPackage | Join-Path -ChildPath $SpecificVersion 319 | Say-Verbose "Is-Dotnet-Package-Installed: Path to a package: $DotnetPackagePath" 320 | return Test-Path $DotnetPackagePath -PathType Container 321 | } 322 | 323 | function Get-Absolute-Path([string]$RelativeOrAbsolutePath) { 324 | # Too much spam 325 | # Say-Invocation $MyInvocation 326 | 327 | return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($RelativeOrAbsolutePath) 328 | } 329 | 330 | function Get-Path-Prefix-With-Version($path) { 331 | $match = [regex]::match($path, $VersionRegEx) 332 | if ($match.Success) { 333 | return $entry.FullName.Substring(0, $match.Index + $match.Length) 334 | } 335 | 336 | return $null 337 | } 338 | 339 | function Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package([System.IO.Compression.ZipArchive]$Zip, [string]$OutPath) { 340 | Say-Invocation $MyInvocation 341 | 342 | $ret = @() 343 | foreach ($entry in $Zip.Entries) { 344 | $dir = Get-Path-Prefix-With-Version $entry.FullName 345 | if ($dir -ne $null) { 346 | $path = Get-Absolute-Path $(Join-Path -Path $OutPath -ChildPath $dir) 347 | if (-Not (Test-Path $path -PathType Container)) { 348 | $ret += $dir 349 | } 350 | } 351 | } 352 | 353 | $ret = $ret | Sort-Object | Get-Unique 354 | 355 | $values = ($ret | foreach { "$_" }) -join ";" 356 | Say-Verbose "Directories to unpack: $values" 357 | 358 | return $ret 359 | } 360 | 361 | # Example zip content and extraction algorithm: 362 | # Rule: files if extracted are always being extracted to the same relative path locally 363 | # .\ 364 | # a.exe # file does not exist locally, extract 365 | # b.dll # file exists locally, override only if $OverrideFiles set 366 | # aaa\ # same rules as for files 367 | # ... 368 | # abc\1.0.0\ # directory contains version and exists locally 369 | # ... # do not extract content under versioned part 370 | # abc\asd\ # same rules as for files 371 | # ... 372 | # def\ghi\1.0.1\ # directory contains version and does not exist locally 373 | # ... # extract content 374 | function Extract-Dotnet-Package([string]$ZipPath, [string]$OutPath) { 375 | Say-Invocation $MyInvocation 376 | 377 | Load-Assembly -Assembly System.IO.Compression.FileSystem 378 | Set-Variable -Name Zip 379 | try { 380 | $Zip = [System.IO.Compression.ZipFile]::OpenRead($ZipPath) 381 | 382 | $DirectoriesToUnpack = Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package -Zip $Zip -OutPath $OutPath 383 | 384 | foreach ($entry in $Zip.Entries) { 385 | $PathWithVersion = Get-Path-Prefix-With-Version $entry.FullName 386 | if (($PathWithVersion -eq $null) -Or ($DirectoriesToUnpack -contains $PathWithVersion)) { 387 | $DestinationPath = Get-Absolute-Path $(Join-Path -Path $OutPath -ChildPath $entry.FullName) 388 | $DestinationDir = Split-Path -Parent $DestinationPath 389 | $OverrideFiles=$OverrideNonVersionedFiles -Or (-Not (Test-Path $DestinationPath)) 390 | if ((-Not $DestinationPath.EndsWith("\")) -And $OverrideFiles) { 391 | New-Item -ItemType Directory -Force -Path $DestinationDir | Out-Null 392 | [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $DestinationPath, $OverrideNonVersionedFiles) 393 | } 394 | } 395 | } 396 | } 397 | finally { 398 | if ($Zip -ne $null) { 399 | $Zip.Dispose() 400 | } 401 | } 402 | } 403 | 404 | function DownloadFile([Uri]$Uri, [string]$OutPath) { 405 | $Stream = $null 406 | 407 | try { 408 | $Response = GetHTTPResponse -Uri $Uri 409 | $Stream = $Response.Content.ReadAsStreamAsync().Result 410 | $File = [System.IO.File]::Create($OutPath) 411 | $Stream.CopyTo($File) 412 | $File.Close() 413 | } 414 | finally { 415 | if ($Stream -ne $null) { 416 | $Stream.Dispose() 417 | } 418 | } 419 | } 420 | 421 | function Prepend-Sdk-InstallRoot-To-Path([string]$InstallRoot, [string]$BinFolderRelativePath) { 422 | $BinPath = Get-Absolute-Path $(Join-Path -Path $InstallRoot -ChildPath $BinFolderRelativePath) 423 | if (-Not $NoPath) { 424 | Say "Adding to current process PATH: `"$BinPath`". Note: This change will not be visible if PowerShell was run as a child process." 425 | $env:path = "$BinPath;" + $env:path 426 | } 427 | else { 428 | Say "Binaries of dotnet can be found in $BinPath" 429 | } 430 | } 431 | 432 | $CLIArchitecture = Get-CLIArchitecture-From-Architecture $Architecture 433 | $SpecificVersion = Get-Specific-Version-From-Version -AzureFeed $AzureFeed -Channel $Channel -Version $Version 434 | $DownloadLink = Get-Download-Link -AzureFeed $AzureFeed -Channel $Channel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture 435 | $AltDownloadLink = Get-AltDownload-Link -AzureFeed $AzureFeed -Channel $Channel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture 436 | 437 | if ($DryRun) { 438 | Say "Payload URLs:" 439 | Say "Primary - $DownloadLink" 440 | Say "Alternate - $AltDownloadLink" 441 | Say "Repeatable invocation: .\$($MyInvocation.MyCommand) -Version $SpecificVersion -Channel $Channel -Architecture $CLIArchitecture -InstallDir $InstallDir" 442 | exit 0 443 | } 444 | 445 | $InstallRoot = Resolve-Installation-Path $InstallDir 446 | Say-Verbose "InstallRoot: $InstallRoot" 447 | 448 | $IsSdkInstalled = Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -RelativePathToPackage "sdk" -SpecificVersion $SpecificVersion 449 | Say-Verbose ".NET SDK installed? $IsSdkInstalled" 450 | if ($IsSdkInstalled) { 451 | Say ".NET SDK version $SpecificVersion is already installed." 452 | Prepend-Sdk-InstallRoot-To-Path -InstallRoot $InstallRoot -BinFolderRelativePath $BinFolderRelativePath 453 | exit 0 454 | } 455 | 456 | New-Item -ItemType Directory -Force -Path $InstallRoot | Out-Null 457 | 458 | $installDrive = $((Get-Item $InstallRoot).PSDrive.Name); 459 | Write-Output "${installDrive}:"; 460 | $free = Get-CimInstance -Class win32_logicaldisk | where Deviceid -eq "${installDrive}:" 461 | if ($free.Freespace / 1MB -le 100 ) { 462 | Say "There is not enough disk space on drive ${installDrive}:" 463 | exit 0 464 | } 465 | 466 | $ZipPath = [System.IO.Path]::GetTempFileName() 467 | Say "Downloading $DownloadLink" 468 | try { 469 | DownloadFile -Uri $DownloadLink -OutPath $ZipPath 470 | } 471 | catch { 472 | $DownloadLink = $AltDownloadLink 473 | $ZipPath = [System.IO.Path]::GetTempFileName() 474 | Say "Downloading $DownloadLink" 475 | DownloadFile -Uri $DownloadLink -OutPath $ZipPath 476 | } 477 | 478 | Say "Extracting zip from $DownloadLink" 479 | Extract-Dotnet-Package -ZipPath $ZipPath -OutPath $InstallRoot 480 | 481 | Remove-Item $ZipPath 482 | 483 | Prepend-Sdk-InstallRoot-To-Path -InstallRoot $InstallRoot -BinFolderRelativePath $BinFolderRelativePath 484 | 485 | Say "Installation finished" 486 | exit 0 487 | -------------------------------------------------------------------------------- /build/dotnet/dotnet-install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (c) .NET Foundation and contributors. All rights reserved. 3 | # Licensed under the MIT license. See LICENSE file in the project root for full license information. 4 | # 5 | 6 | # Stop script on NZEC 7 | set -e 8 | # Stop script if unbound variable found (use ${var:-} if intentional) 9 | set -u 10 | # By default cmd1 | cmd2 returns exit code of cmd2 regardless of cmd1 success 11 | # This is causing it to fail 12 | set -o pipefail 13 | 14 | # Use in the the functions: eval $invocation 15 | invocation='say_verbose "Calling: ${yellow:-}${FUNCNAME[0]} ${green:-}$*${normal:-}"' 16 | 17 | # standard output may be used as a return value in the functions 18 | # we need a way to write text on the screen in the functions so that 19 | # it won't interfere with the return value. 20 | # Exposing stream 3 as a pipe to standard output of the script itself 21 | exec 3>&1 22 | 23 | # Setup some colors to use. These need to work in fairly limited shells, like the Ubuntu Docker container where there are only 8 colors. 24 | # See if stdout is a terminal 25 | if [ -t 1 ]; then 26 | # see if it supports colors 27 | ncolors=$(tput colors) 28 | if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then 29 | bold="$(tput bold || echo)" 30 | normal="$(tput sgr0 || echo)" 31 | black="$(tput setaf 0 || echo)" 32 | red="$(tput setaf 1 || echo)" 33 | green="$(tput setaf 2 || echo)" 34 | yellow="$(tput setaf 3 || echo)" 35 | blue="$(tput setaf 4 || echo)" 36 | magenta="$(tput setaf 5 || echo)" 37 | cyan="$(tput setaf 6 || echo)" 38 | white="$(tput setaf 7 || echo)" 39 | fi 40 | fi 41 | 42 | say_err() { 43 | printf "%b\n" "${red:-}dotnet_install: Error: $1${normal:-}" >&2 44 | } 45 | 46 | say() { 47 | # using stream 3 (defined in the beginning) to not interfere with stdout of functions 48 | # which may be used as return value 49 | printf "%b\n" "${cyan:-}dotnet-install:${normal:-} $1" >&3 50 | } 51 | 52 | say_verbose() { 53 | if [ "$verbose" = true ]; then 54 | say "$1" 55 | fi 56 | } 57 | 58 | get_os_download_name_from_platform() { 59 | eval $invocation 60 | 61 | platform="$1" 62 | case "$platform" in 63 | "centos.7") 64 | echo "centos" 65 | return 0 66 | ;; 67 | "debian.8") 68 | echo "debian" 69 | return 0 70 | ;; 71 | "fedora.23") 72 | echo "fedora.23" 73 | return 0 74 | ;; 75 | "fedora.24") 76 | echo "fedora.24" 77 | return 0 78 | ;; 79 | "opensuse.13.2") 80 | echo "opensuse.13.2" 81 | return 0 82 | ;; 83 | "opensuse.42.1") 84 | echo "opensuse.42.1" 85 | return 0 86 | ;; 87 | "rhel.7"*) 88 | echo "rhel" 89 | return 0 90 | ;; 91 | "ubuntu.14.04") 92 | echo "ubuntu" 93 | return 0 94 | ;; 95 | "ubuntu.16.04") 96 | echo "ubuntu.16.04" 97 | return 0 98 | ;; 99 | "ubuntu.16.10") 100 | echo "ubuntu.16.10" 101 | return 0 102 | ;; 103 | "alpine.3.4.3") 104 | echo "alpine" 105 | return 0 106 | ;; 107 | esac 108 | return 1 109 | } 110 | 111 | get_current_os_name() { 112 | eval $invocation 113 | 114 | local uname=$(uname) 115 | if [ "$uname" = "Darwin" ]; then 116 | echo "osx" 117 | return 0 118 | else 119 | if [ "$uname" = "Linux" ]; then 120 | echo "linux" 121 | return 0 122 | fi 123 | fi 124 | 125 | say_err "OS name could not be detected: $ID.$VERSION_ID" 126 | return 1 127 | } 128 | 129 | get_distro_specific_os_name() { 130 | eval $invocation 131 | 132 | local uname=$(uname) 133 | if [ "$uname" = "Darwin" ]; then 134 | echo "osx" 135 | return 0 136 | elif [ -n "$runtime_id" ]; then 137 | echo $(get_os_download_name_from_platform "${runtime_id%-*}" || echo "${runtime_id%-*}") 138 | return 0 139 | else 140 | if [ -e /etc/os-release ]; then 141 | . /etc/os-release 142 | os=$(get_os_download_name_from_platform "$ID.$VERSION_ID" || echo "") 143 | if [ -n "$os" ]; then 144 | echo "$os" 145 | return 0 146 | fi 147 | fi 148 | fi 149 | 150 | say_err "OS name could not be detected: $ID.$VERSION_ID" 151 | return 1 152 | } 153 | 154 | machine_has() { 155 | eval $invocation 156 | 157 | hash "$1" > /dev/null 2>&1 158 | return $? 159 | } 160 | 161 | 162 | check_min_reqs() { 163 | local hasMinimum=false 164 | if machine_has "curl"; then 165 | hasMinimum=true 166 | elif machine_has "wget"; then 167 | hasMinimum=true 168 | fi 169 | 170 | if [ "$hasMinimum" = "false" ]; then 171 | say_err "curl (recommended) or wget are required to download dotnet. Install missing prerequisite to proceed." 172 | return 1 173 | fi 174 | return 0 175 | } 176 | 177 | check_pre_reqs() { 178 | eval $invocation 179 | 180 | local failing=false; 181 | 182 | if [ "${DOTNET_INSTALL_SKIP_PREREQS:-}" = "1" ]; then 183 | return 0 184 | fi 185 | 186 | if [ "$(uname)" = "Linux" ]; then 187 | if ! [ -x "$(command -v ldconfig)" ]; then 188 | echo "ldconfig is not in PATH, trying /sbin/ldconfig." 189 | LDCONFIG_COMMAND="/sbin/ldconfig" 190 | else 191 | LDCONFIG_COMMAND="ldconfig" 192 | fi 193 | 194 | [ -z "$($LDCONFIG_COMMAND -p | grep libunwind)" ] && say_err "Unable to locate libunwind. Install libunwind to continue" && failing=true 195 | [ -z "$($LDCONFIG_COMMAND -p | grep libssl)" ] && say_err "Unable to locate libssl. Install libssl to continue" && failing=true 196 | [ -z "$($LDCONFIG_COMMAND -p | grep libicu)" ] && say_err "Unable to locate libicu. Install libicu to continue" && failing=true 197 | fi 198 | 199 | if [ "$failing" = true ]; then 200 | return 1 201 | fi 202 | 203 | return 0 204 | } 205 | 206 | # args: 207 | # input - $1 208 | to_lowercase() { 209 | #eval $invocation 210 | 211 | echo "$1" | tr '[:upper:]' '[:lower:]' 212 | return 0 213 | } 214 | 215 | # args: 216 | # input - $1 217 | remove_trailing_slash() { 218 | #eval $invocation 219 | 220 | local input=${1:-} 221 | echo "${input%/}" 222 | return 0 223 | } 224 | 225 | # args: 226 | # input - $1 227 | remove_beginning_slash() { 228 | #eval $invocation 229 | 230 | local input=${1:-} 231 | echo "${input#/}" 232 | return 0 233 | } 234 | 235 | # args: 236 | # root_path - $1 237 | # child_path - $2 - this parameter can be empty 238 | combine_paths() { 239 | eval $invocation 240 | 241 | # TODO: Consider making it work with any number of paths. For now: 242 | if [ ! -z "${3:-}" ]; then 243 | say_err "combine_paths: Function takes two parameters." 244 | return 1 245 | fi 246 | 247 | local root_path=$(remove_trailing_slash $1) 248 | local child_path=$(remove_beginning_slash ${2:-}) 249 | say_verbose "combine_paths: root_path=$root_path" 250 | say_verbose "combine_paths: child_path=$child_path" 251 | echo "$root_path/$child_path" 252 | return 0 253 | } 254 | 255 | get_machine_architecture() { 256 | eval $invocation 257 | 258 | # Currently the only one supported 259 | echo "x64" 260 | return 0 261 | } 262 | 263 | # args: 264 | # architecture - $1 265 | get_normalized_architecture_from_architecture() { 266 | eval $invocation 267 | 268 | local architecture=$(to_lowercase $1) 269 | case $architecture in 270 | \) 271 | echo "$(get_normalized_architecture_from_architecture $(get_machine_architecture))" 272 | return 0 273 | ;; 274 | amd64|x64) 275 | echo "x64" 276 | return 0 277 | ;; 278 | x86) 279 | say_err "Architecture \`x86\` currently not supported" 280 | return 1 281 | ;; 282 | esac 283 | 284 | say_err "Architecture \`$architecture\` not supported. If you think this is a bug, please report it at https://github.com/dotnet/cli/issues" 285 | return 1 286 | } 287 | 288 | # version_info is a conceptual two line string representing commit hash and 4-part version 289 | # format: 290 | # Line 1: # commit_hash 291 | # Line 2: # 4-part version 292 | 293 | # args: 294 | # version_text - stdin 295 | get_version_from_version_info() { 296 | eval $invocation 297 | 298 | cat | tail -n 1 299 | return 0 300 | } 301 | 302 | # args: 303 | # version_text - stdin 304 | get_commit_hash_from_version_info() { 305 | eval $invocation 306 | 307 | cat | head -n 1 308 | return 0 309 | } 310 | 311 | # args: 312 | # install_root - $1 313 | # relative_path_to_package - $2 314 | # specific_version - $3 315 | is_dotnet_package_installed() { 316 | eval $invocation 317 | 318 | local install_root=$1 319 | local relative_path_to_package=$2 320 | local specific_version=${3//[$'\t\r\n']} 321 | 322 | local dotnet_package_path=$(combine_paths $(combine_paths $install_root $relative_path_to_package) $specific_version) 323 | say_verbose "is_dotnet_package_installed: dotnet_package_path=$dotnet_package_path" 324 | 325 | if [ -d "$dotnet_package_path" ]; then 326 | return 0 327 | else 328 | return 1 329 | fi 330 | } 331 | 332 | # args: 333 | # azure_feed - $1 334 | # channel - $2 335 | # normalized_architecture - $3 336 | get_latest_version_info() { 337 | eval $invocation 338 | 339 | local azure_feed=$1 340 | local channel=$2 341 | local normalized_architecture=$3 342 | 343 | local version_file_url=null 344 | if [ "$shared_runtime" = true ]; then 345 | version_file_url="$uncached_feed/Runtime/$channel/latest.version" 346 | else 347 | version_file_url="$uncached_feed/Sdk/$channel/latest.version" 348 | fi 349 | say_verbose "get_latest_version_info: latest url: $version_file_url" 350 | 351 | download $version_file_url 352 | return $? 353 | } 354 | 355 | # args: 356 | # azure_feed - $1 357 | # channel - $2 358 | # normalized_architecture - $3 359 | # version - $4 360 | get_specific_version_from_version() { 361 | eval $invocation 362 | 363 | local azure_feed=$1 364 | local channel=$2 365 | local normalized_architecture=$3 366 | local version=$(to_lowercase $4) 367 | 368 | case $version in 369 | latest) 370 | local version_info 371 | version_info="$(get_latest_version_info $azure_feed $channel $normalized_architecture)" || return 1 372 | say_verbose "get_specific_version_from_version: version_info=$version_info" 373 | echo "$version_info" | get_version_from_version_info 374 | return 0 375 | ;; 376 | *) 377 | echo $version 378 | return 0 379 | ;; 380 | esac 381 | } 382 | 383 | # args: 384 | # azure_feed - $1 385 | # channel - $2 386 | # normalized_architecture - $3 387 | # specific_version - $4 388 | construct_download_link() { 389 | eval $invocation 390 | 391 | local azure_feed=$1 392 | local channel=$2 393 | local normalized_architecture=$3 394 | local specific_version=${4//[$'\t\r\n']} 395 | 396 | local osname 397 | osname=$(get_current_os_name) || return 1 398 | 399 | local download_link=null 400 | if [ "$shared_runtime" = true ]; then 401 | download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_version-$osname-$normalized_architecture.tar.gz" 402 | else 403 | download_link="$azure_feed/Sdk/$specific_version/dotnet-sdk-$specific_version-$osname-$normalized_architecture.tar.gz" 404 | fi 405 | 406 | echo "$download_link" 407 | return 0 408 | } 409 | 410 | # args: 411 | # azure_feed - $1 412 | # channel - $2 413 | # normalized_architecture - $3 414 | # specific_version - $4 415 | construct_alt_download_link() { 416 | eval $invocation 417 | 418 | local azure_feed=$1 419 | local channel=$2 420 | local normalized_architecture=$3 421 | local specific_version=${4//[$'\t\r\n']} 422 | 423 | local distro_specific_osname 424 | distro_specific_osname=$(get_distro_specific_os_name) || return 1 425 | 426 | local alt_download_link=null 427 | if [ "$shared_runtime" = true ]; then 428 | alt_download_link="$azure_feed/Runtime/$specific_version/dotnet-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz" 429 | else 430 | alt_download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz" 431 | fi 432 | 433 | echo "$alt_download_link" 434 | return 0 435 | } 436 | 437 | get_user_install_path() { 438 | eval $invocation 439 | 440 | if [ ! -z "${DOTNET_INSTALL_DIR:-}" ]; then 441 | echo $DOTNET_INSTALL_DIR 442 | else 443 | echo "$HOME/.dotnet" 444 | fi 445 | return 0 446 | } 447 | 448 | # args: 449 | # install_dir - $1 450 | resolve_installation_path() { 451 | eval $invocation 452 | 453 | local install_dir=$1 454 | if [ "$install_dir" = "" ]; then 455 | local user_install_path=$(get_user_install_path) 456 | say_verbose "resolve_installation_path: user_install_path=$user_install_path" 457 | echo "$user_install_path" 458 | return 0 459 | fi 460 | 461 | echo "$install_dir" 462 | return 0 463 | } 464 | 465 | # args: 466 | # install_root - $1 467 | get_installed_version_info() { 468 | eval $invocation 469 | 470 | local install_root=$1 471 | local version_file=$(combine_paths "$install_root" "$local_version_file_relative_path") 472 | say_verbose "Local version file: $version_file" 473 | if [ ! -z "$version_file" ] | [ -r "$version_file" ]; then 474 | local version_info="$(cat $version_file)" 475 | echo "$version_info" 476 | return 0 477 | fi 478 | 479 | say_verbose "Local version file not found." 480 | return 0 481 | } 482 | 483 | # args: 484 | # relative_or_absolute_path - $1 485 | get_absolute_path() { 486 | eval $invocation 487 | 488 | local relative_or_absolute_path=$1 489 | echo $(cd $(dirname "$1") && pwd -P)/$(basename "$1") 490 | return 0 491 | } 492 | 493 | # args: 494 | # input_files - stdin 495 | # root_path - $1 496 | # out_path - $2 497 | # override - $3 498 | copy_files_or_dirs_from_list() { 499 | eval $invocation 500 | 501 | local root_path=$(remove_trailing_slash $1) 502 | local out_path=$(remove_trailing_slash $2) 503 | local override=$3 504 | local override_switch=$(if [ "$override" = false ]; then printf -- "-n"; fi) 505 | 506 | cat | uniq | while read -r file_path; do 507 | local path=$(remove_beginning_slash ${file_path#$root_path}) 508 | local target=$out_path/$path 509 | if [ "$override" = true ] || (! ([ -d "$target" ] || [ -e "$target" ])); then 510 | mkdir -p $out_path/$(dirname $path) 511 | cp -R $override_switch $root_path/$path $target 512 | fi 513 | done 514 | } 515 | 516 | # args: 517 | # zip_path - $1 518 | # out_path - $2 519 | extract_dotnet_package() { 520 | eval $invocation 521 | 522 | local zip_path=$1 523 | local out_path=$2 524 | 525 | local temp_out_path=$(mktemp -d $temporary_file_template) 526 | 527 | local failed=false 528 | tar -xzf "$zip_path" -C "$temp_out_path" > /dev/null || failed=true 529 | 530 | local folders_with_version_regex='^.*/[0-9]+\.[0-9]+[^/]+/' 531 | find $temp_out_path -type f | grep -Eo $folders_with_version_regex | copy_files_or_dirs_from_list $temp_out_path $out_path false 532 | find $temp_out_path -type f | grep -Ev $folders_with_version_regex | copy_files_or_dirs_from_list $temp_out_path $out_path true 533 | 534 | rm -rf $temp_out_path 535 | 536 | if [ "$failed" = true ]; then 537 | say_err "Extraction failed" 538 | return 1 539 | fi 540 | } 541 | 542 | # args: 543 | # remote_path - $1 544 | # [out_path] - $2 - stdout if not provided 545 | download() { 546 | eval $invocation 547 | 548 | local remote_path=$1 549 | local out_path=${2:-} 550 | 551 | local failed=false 552 | if machine_has "curl"; then 553 | downloadcurl $remote_path $out_path || failed=true 554 | elif machine_has "wget"; then 555 | downloadwget $remote_path $out_path || failed=true 556 | else 557 | failed=true 558 | fi 559 | if [ "$failed" = true ]; then 560 | say_verbose "Download failed: $remote_path" 561 | return 1 562 | fi 563 | return 0 564 | } 565 | 566 | downloadcurl() { 567 | eval $invocation 568 | local remote_path=$1 569 | local out_path=${2:-} 570 | 571 | local failed=false 572 | if [ -z "$out_path" ]; then 573 | curl --retry 10 -sSL -f --create-dirs $remote_path || failed=true 574 | else 575 | curl --retry 10 -sSL -f --create-dirs -o $out_path $remote_path || failed=true 576 | fi 577 | if [ "$failed" = true ]; then 578 | say_verbose "Curl download failed" 579 | return 1 580 | fi 581 | return 0 582 | } 583 | 584 | downloadwget() { 585 | eval $invocation 586 | local remote_path=$1 587 | local out_path=${2:-} 588 | 589 | local failed=false 590 | if [ -z "$out_path" ]; then 591 | wget -q --tries 10 $remote_path || failed=true 592 | else 593 | wget -v --tries 10 -O $out_path $remote_path || failed=true 594 | fi 595 | if [ "$failed" = true ]; then 596 | say_verbose "Wget download failed" 597 | return 1 598 | fi 599 | return 0 600 | } 601 | 602 | calculate_vars() { 603 | eval $invocation 604 | 605 | normalized_architecture=$(get_normalized_architecture_from_architecture "$architecture") 606 | say_verbose "normalized_architecture=$normalized_architecture" 607 | 608 | specific_version=$(get_specific_version_from_version $azure_feed $channel $normalized_architecture $version) 609 | say_verbose "specific_version=$specific_version" 610 | if [ -z "$specific_version" ]; then 611 | say_err "Could not get version information." 612 | return 1 613 | fi 614 | 615 | download_link=$(construct_download_link $azure_feed $channel $normalized_architecture $specific_version) 616 | say_verbose "download_link=$download_link" 617 | 618 | alt_download_link=$(construct_alt_download_link $azure_feed $channel $normalized_architecture $specific_version) 619 | say_verbose "alt_download_link=$alt_download_link" 620 | 621 | install_root=$(resolve_installation_path $install_dir) 622 | say_verbose "install_root=$install_root" 623 | } 624 | 625 | install_dotnet() { 626 | eval $invocation 627 | local download_failed=false 628 | 629 | if is_dotnet_package_installed $install_root "sdk" $specific_version; then 630 | say ".NET SDK version $specific_version is already installed." 631 | return 0 632 | fi 633 | 634 | mkdir -p $install_root 635 | zip_path=$(mktemp $temporary_file_template) 636 | say_verbose "Zip path: $zip_path" 637 | 638 | say "Downloading link: $download_link" 639 | download "$download_link" $zip_path || download_failed=true 640 | 641 | # if the download fails, download the alt_download_link 642 | if [ "$download_failed" = true ]; then 643 | say "Cannot download: $download_link" 644 | zip_path=$(mktemp $temporary_file_template) 645 | say_verbose "Alternate zip path: $zip_path" 646 | say "Downloading alternate link: $alt_download_link" 647 | download "$alt_download_link" $zip_path 648 | fi 649 | 650 | say "Extracting zip" 651 | extract_dotnet_package $zip_path $install_root 652 | 653 | return 0 654 | } 655 | 656 | local_version_file_relative_path="/.version" 657 | bin_folder_relative_path="" 658 | temporary_file_template="${TMPDIR:-/tmp}/dotnet.XXXXXXXXX" 659 | 660 | channel="release/1.0.0" 661 | version="Latest" 662 | install_dir="" 663 | architecture="" 664 | debug_symbols=false 665 | dry_run=false 666 | no_path=false 667 | azure_feed="https://dotnetcli.azureedge.net/dotnet" 668 | uncached_feed="https://dotnetcli.blob.core.windows.net/dotnet" 669 | verbose=false 670 | shared_runtime=false 671 | runtime_id="" 672 | 673 | while [ $# -ne 0 ] 674 | do 675 | name=$1 676 | case $name in 677 | -c|--channel|-[Cc]hannel) 678 | shift 679 | channel=$1 680 | ;; 681 | -v|--version|-[Vv]ersion) 682 | shift 683 | version="$1" 684 | ;; 685 | -i|--install-dir|-[Ii]nstall[Dd]ir) 686 | shift 687 | install_dir="$1" 688 | ;; 689 | --arch|--architecture|-[Aa]rch|-[Aa]rchitecture) 690 | shift 691 | architecture="$1" 692 | ;; 693 | --shared-runtime|-[Ss]hared[Rr]untime) 694 | shared_runtime=true 695 | ;; 696 | --debug-symbols|-[Dd]ebug[Ss]ymbols) 697 | debug_symbols=true 698 | ;; 699 | --dry-run|-[Dd]ry[Rr]un) 700 | dry_run=true 701 | ;; 702 | --no-path|-[Nn]o[Pp]ath) 703 | no_path=true 704 | ;; 705 | --verbose|-[Vv]erbose) 706 | verbose=true 707 | ;; 708 | --azure-feed|-[Aa]zure[Ff]eed) 709 | shift 710 | azure_feed="$1" 711 | ;; 712 | --uncached-feed|-[Uu]ncached[Ff]eed) 713 | shift 714 | uncached_feed="$1" 715 | ;; 716 | --runtime-id|-[Rr]untime[Ii]d) 717 | shift 718 | runtime_id="$1" 719 | ;; 720 | -?|--?|-h|--help|-[Hh]elp) 721 | script_name="$(basename $0)" 722 | echo ".NET Tools Installer" 723 | echo "Usage: $script_name [-c|--channel ] [-v|--version ] [-p|--prefix ]" 724 | echo " $script_name -h|-?|--help" 725 | echo "" 726 | echo "$script_name is a simple command line interface for obtaining dotnet cli." 727 | echo "" 728 | echo "Options:" 729 | echo " -c,--channel Download from the CHANNEL specified (default: $channel)." 730 | echo " -Channel" 731 | echo " -v,--version Use specific version, or \`latest\`. Defaults to \`latest\`." 732 | echo " -Version" 733 | echo " -i,--install-dir Install under specified location (see Install Location below)" 734 | echo " -InstallDir" 735 | echo " --architecture Architecture of .NET Tools. Currently only x64 is supported." 736 | echo " --arch,-Architecture,-Arch" 737 | echo " --shared-runtime Installs just the shared runtime bits, not the entire SDK." 738 | echo " -SharedRuntime" 739 | echo " --debug-symbols,-DebugSymbols Specifies if symbols should be included in the installation." 740 | echo " --dry-run,-DryRun Do not perform installation. Display download link." 741 | echo " --no-path, -NoPath Do not set PATH for the current process." 742 | echo " --verbose,-Verbose Display diagnostics information." 743 | echo " --azure-feed,-AzureFeed Azure feed location. Defaults to $azure_feed, This parameter typically is not changed by the user." 744 | echo " --uncached-feed,-UncachedFeed Uncached feed location. This parameter typically is not changed by the user." 745 | echo " --runtime-id Installs the .NET Tools for the given platform (use linux-x64 for portable linux)." 746 | echo " -RuntimeId" 747 | echo " -?,--?,-h,--help,-Help Shows this help message" 748 | echo "" 749 | echo "Install Location:" 750 | echo " Location is chosen in following order:" 751 | echo " - --install-dir option" 752 | echo " - Environmental variable DOTNET_INSTALL_DIR" 753 | echo " - $HOME/.dotnet" 754 | exit 0 755 | ;; 756 | *) 757 | say_err "Unknown argument \`$name\`" 758 | exit 1 759 | ;; 760 | esac 761 | 762 | shift 763 | done 764 | 765 | check_min_reqs 766 | calculate_vars 767 | if [ "$dry_run" = true ]; then 768 | say "Payload URL: $download_link" 769 | say "Alternate payload URL: $alt_download_link" 770 | say "Repeatable invocation: ./$(basename $0) --version $specific_version --channel $channel --install-dir $install_dir" 771 | exit 0 772 | fi 773 | 774 | check_pre_reqs 775 | install_dotnet 776 | 777 | bin_path=$(get_absolute_path $(combine_paths $install_root $bin_folder_relative_path)) 778 | if [ "$no_path" = false ]; then 779 | say "Adding to current process PATH: \`$bin_path\`. Note: This change will be visible only when sourcing script." 780 | export PATH=$bin_path:$PATH 781 | else 782 | say "Binaries of dotnet can be found in $bin_path" 783 | fi 784 | 785 | say "Installation finished successfully." 786 | -------------------------------------------------------------------------------- /build/msbuild/KoreBuild.RepoTasks.Sdk/Sdk/Sdk.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | 7 | library 8 | 9 | 13 | 15.3.0-preview-000388-01 14 | 15 | 9.0.1 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /build/msbuild/KoreBuild.RepoTasks.Sdk/Sdk/Sdk.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /build/shared-runtime.version: -------------------------------------------------------------------------------- 1 | 2.0.0 2 | -------------------------------------------------------------------------------- /build/shared/sharedsources.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | true 20 | $(RepositoryRoot)artifacts\build 21 | netstandard1.0 22 | false 23 | $(PackageId) 24 | false 25 | contentFiles 26 | true 27 | 28 | 29 | 30 | 31 | true 32 | $(ContentTargetFolders)\cs\netstandard1.0\ 33 | 34 | 35 | true 36 | $(ContentTargetFolders)\any\any\ 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /build/targets/KoreBuild.Common.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | Release 9 | Debug 10 | $(MSBuildThisFileDirectory)..\..\ 11 | $([MSBuild]::EnsureTrailingSlash('$(RepositoryRoot)')) 12 | $(RepositoryRoot)artifacts\ 13 | $(ArtifactsDir)build\ 14 | 15 | 16 | -------------------------------------------------------------------------------- /build/targets/KoreBuild.Common.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | Prepare 14 | $(CompileDependsOn);Restore 15 | Compile 16 | Package 17 | Test 18 | Verify 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /build/targets/KoreBuild.DefaultBuildSettings.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | $(BUILD_NUMBER) 9 | 10 | 11 | 12 | 13 | 17 | <_SecondBasedTimeStamp>$([System.DateTime]::UtcNow.Subtract($([System.DateTime]::FromBinary(635556672000000000))).TotalSeconds.ToString("F0")) 18 | <_SecondBasedTimeStamp>t$([System.Int64]::Parse($(_SecondBasedTimeStamp)).ToString("x9")) 19 | $(_SecondBasedTimeStamp) 20 | 21 | 22 | -------------------------------------------------------------------------------- /build/targets/KoreBuild.SolutionBuild.targets: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | $(PrepareDependsOn);CleanArtifacts;CleanSolutions;_PrepareOutputPaths;ResolveGitInfo 14 | $(CompileDependsOn);_CreateCommitHashArtifact;BuildSolutions 15 | $(PackageDependsOn);PackageProjects;PackSharedSources 16 | $(TestDependsOn);TestProjects 17 | $(VerifyDependsOn);VerifyPackages 18 | $(CleanDependsOn);CleanArtifacts;CleanSolutions 19 | $(RebuildDependsOn);RebuildSolutions 20 | 21 | 22 | 29 | 30 | 31 | 32 | 33 | 34 | <_ResxTargets>$(MSBuildThisFileDirectory)Project.CSharp.Resx.targets 35 | <_ResxSlnProps>$(_SolutionProperties) 36 | 37 | <_ResxSlnProps>$(_ResxSlnProps);CustomAfterMicrosoftCommonTargets=$(_ResxTargets) 38 | <_ResxSlnProps>$(_ResxSlnProps);CustomAfterMicrosoftCommonCrossTargetingTargets=$(_ResxTargets) 39 | 40 | 41 | 47 | 48 | 49 | 57 | 58 | 59 | 60 | <_FilesToDelete Include="$(ArtifactsDir)**\*" Exclude="$(ArtifactsDir)msbuild\**\*" /> 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | $(APPVEYOR_REPO_COMMIT) 72 | $(APPVEYOR_REPO_BRANCH) 73 | $(TRAVIS_COMMIT) 74 | $(TRAVIS_BRANCH) 75 | 76 | 77 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | <_CommitArtifactFileName>commit 88 | 89 | 90 | 91 | 96 | 97 | 98 | 105 | 106 | <_UpdateFeeds Include="ARTIFACTS" Value="$(NUGET_VOLATILE_FEED_ARTIFACTS)" Condition="'$(NUGET_VOLATILE_FEED_ARTIFACTS)' != ''" /> 107 | <_UpdateFeeds Include="AspNetCore" Value="$(NUGET_VOLATILE_FEED_AspNetCore)" Condition="'$(NUGET_VOLATILE_FEED_AspNetCore)' != ''" /> 108 | 109 | 110 | 111 | 115 | 116 | 117 | 127 | 128 | <_SolutionWasBuilt>false 129 | 130 | <_BuildPropertiesToRemove>$(_BuildPropertiesToRemove);_SolutionWasBuilt 131 | 132 | true 133 | 134 | 135 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | <_SolutionProperties>$(_SolutionProperties);Configuration=$(Configuration) 145 | <_SolutionProperties Condition="'$(BuildNumber)' != ''">$(_SolutionProperties);BuildNumber=$(BuildNumber) 146 | <_SolutionProperties Condition="'$(CommitHash)' != ''">$(_SolutionProperties);CommitHash=$(CommitHash) 147 | <_SolutionProperties Condition="'$(GitBranch)' != ''">$(_SolutionProperties);GitBranch=$(GitBranch) 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 159 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 174 | 175 | 176 | <_SolutionWasBuilt>true 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 188 | 189 | 190 | <_SolutionWasBuilt>true 191 | 192 | 193 | 194 | 202 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 218 | 221 | 222 | 223 | 224 | 225 | 226 | %(RestoreGraphProjectInputItems.AdditionalProperties);$(_SolutionProperties) 227 | 228 | 229 | 230 | 231 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | $(_SolutionWasBuilt) 245 | 246 | 247 | 253 | 254 | 255 | 263 | 264 | 265 | 266 | 267 | 268 | 271 | 272 | 277 | 278 | 279 | 289 | 290 | 291 | trx 292 | false 293 | true 294 | false 295 | true 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 306 | 307 | 308 | 312 | RunConfiguration.NoAutoReporters=true $(VSTestCLIRunSettings) 313 | $(_SolutionWasBuilt) 314 | <_TestContinueOnError Condition="'$(IgnoreFailingTestProjects)' == 'true'">ErrorAndContinue 315 | <_TestContinueOnError Condition="'$(IgnoreFailingTestProjects)' != 'true'">ErrorAndStop 316 | 317 | 318 | 319 | 325 | 326 | 327 | 328 | 337 | 338 | $(RepositoryRoot)NuGetPackageVerifier.json 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 349 | 350 | 353 | 354 | 355 | 356 | -------------------------------------------------------------------------------- /build/targets/KoreBuild.SolutionItems.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(RepositoryRoot)shared/ 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | <_FunctionalTests Include="$(RepositoryRoot)test\*\*FunctionalTest*.csproj" Exclude="@(ExcludeFromTest)" /> 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /build/targets/Project.CSharp.Resx.targets: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | Resx 14 | 15 | 16 | 17 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /test/build-canary-repo.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Runs KoreBuild on a sample repository as a canary test 4 | .PARAMETER RepoUrl 5 | The url of the repo to git clone and build with KoreBuild 6 | #> 7 | param( 8 | [Alias("r")][string]$RepoUrl = 'https://github.com/aspnet/DependencyInjection.git') 9 | 10 | $ErrorActionPreference ='Stop' 11 | 12 | $workdir = "$PSScriptRoot/obj/" 13 | 14 | if (Test-Path $workdir) { 15 | Remove-Item -Recurse -Force $workdir 16 | } 17 | 18 | if (!(Get-Command git -ErrorAction Ignore)) { 19 | throw 'git is not available on the PATH' 20 | } 21 | 22 | & git clone -q $RepoUrl $workdir 23 | Copy-Item -Recurse "$PSScriptRoot/../build/" "$workdir/.build/" 24 | & $workdir/build.ps1 25 | -------------------------------------------------------------------------------- /test/build-canary-repo.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -efo pipefail 4 | 5 | repo_url='https://github.com/aspnet/DependencyInjection.git' 6 | while [[ $# > 0 ]]; do 7 | case $1 in 8 | -r|--repo-url|-RepoUrl) 9 | shift 10 | repo_url=$1 11 | ;; 12 | -h|--help) 13 | echo "Runs KoreBuild on a sample repository as a canary test" 14 | echo "" 15 | echo "Usage: $0 [-r|--repo-url ]" 16 | echo "" 17 | echo " -r|--repo-url The url of the repo to git clone and build with KoreBuild" 18 | exit 2 19 | ;; 20 | *) 21 | echo "Unrecognized argument $1" 22 | exit 1 23 | ;; 24 | esac 25 | shift 26 | done 27 | 28 | script_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 29 | 30 | workdir=$script_root/obj/ 31 | rm -rf $workdir 2>/dev/null && : 32 | 33 | git clone $repo_url $workdir 34 | cp -R $script_root/../build/ $workdir/.build/ 35 | $workdir/build.sh 36 | --------------------------------------------------------------------------------