Add customizations required to test CLI tools with MSBuild

This commit is contained in:
Nate McMaster 2016-11-02 15:24:07 -07:00
Родитель 68c2072b77
Коммит 2a775bac7a
8 изменённых файлов: 282 добавлений и 149 удалений

Просмотреть файл

@ -14,18 +14,18 @@ $dotnetVersionFile = $koreBuildFolder + "\cli.version.win"
$dotnetChannel = "preview"
$dotnetVersion = Get-Content $dotnetVersionFile
if ($env:KOREBUILD_DOTNET_CHANNEL)
if ($env:KOREBUILD_DOTNET_CHANNEL)
{
$dotnetChannel = $env:KOREBUILD_DOTNET_CHANNEL
}
if ($env:KOREBUILD_DOTNET_VERSION)
if ($env:KOREBUILD_DOTNET_VERSION)
{
$dotnetVersion = $env:KOREBUILD_DOTNET_VERSION
}
$dotnetLocalInstallFolder = "$env:LOCALAPPDATA\Microsoft\dotnet\"
$newPath = "$dotnetLocalInstallFolder;$env:PATH"
if ($env:KOREBUILD_SKIP_RUNTIME_INSTALL -eq "1")
if ($env:KOREBUILD_SKIP_RUNTIME_INSTALL -eq "1")
{
Write-Host "Skipping runtime installation because KOREBUILD_SKIP_RUNTIME_INSTALL = 1"
# Add to the _end_ of the path in case preferred .NET CLI is not in the default location.
@ -33,6 +33,9 @@ if ($env:KOREBUILD_SKIP_RUNTIME_INSTALL -eq "1")
}
else
{
# Install an MSBuild version of dotnet-cli
& "$koreBuildFolder/dotnet/dotnet-install.ps1" -InstallDir "$koreBuildFolder/dotnet" -Version (Get-Content "$koreBuildFolder\cli.version.msbuild") -Architecture x64 -Channel "rel-1.0.0"
# Install the version of dotnet-cli used to compile
& "$koreBuildFolder\dotnet\dotnet-install.ps1" -Channel $dotnetChannel -Version $dotnetVersion -Architecture x64
}
if (!($env:Path.Split(';') -icontains $dotnetLocalInstallFolder))
@ -45,14 +48,14 @@ if (!($env:Path.Split(';') -icontains $dotnetLocalInstallFolder))
$sharedPath = (Join-Path (Split-Path ((get-command dotnet.exe).Path) -Parent) "shared");
(Get-ChildItem $sharedPath -Recurse *dotnet.exe) | %{ $_.FullName } | Remove-Item;
if (!(Test-Path "$koreBuildFolder\Sake"))
if (!(Test-Path "$koreBuildFolder\Sake"))
{
$toolsProject = "$koreBuildFolder\project.json"
if (!(Test-Path $toolsProject))
{
if (Test-Path "$toolsProject.norestore")
{
mv "$toolsProject.norestore" "$toolsProject"
mv "$toolsProject.norestore" "$toolsProject"
}
else
{
@ -67,7 +70,7 @@ if (!(Test-Path "$koreBuildFolder\Sake"))
}
$makeFilePath = "makefile.shade"
if (!(Test-Path $makeFilePath))
if (!(Test-Path $makeFilePath))
{
$makeFilePath = "$koreBuildFolder\shade\makefile.shade"
}

Просмотреть файл

@ -54,6 +54,10 @@ else
export KOREBUILD_FOLDER="$(dirname $koreBuildFolder)"
chmod +x $koreBuildFolder/dotnet/dotnet-install.sh
# Install an MSBuild version of dotnet-cli
$koreBuildFolder/dotnet/dotnet-install.sh --install-dir "$koreBuildFolder/dotnet" --channel rel-1.0.0 --version $(cat $koreBuildFolder/cli.version.msbuild)
# Install the version of dotnet-cli used to compile
$koreBuildFolder/dotnet/dotnet-install.sh --channel $KOREBUILD_DOTNET_CHANNEL --version $KOREBUILD_DOTNET_VERSION
# Add .NET installation directory to the path if it isn't yet included.

Просмотреть файл

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="aspnetmaster" value="https://dotnet.myget.org/f/aspnetcore-master/api/v3/index.json" />
<add key="aspnetcore-tools" value="https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -0,0 +1 @@
1.0.0-preview3-004007

138
build/dotnet/dotnet-install.ps1 поставляемый
Просмотреть файл

@ -45,12 +45,14 @@
.PARAMETER Verbose
Displays diagnostics information.
.PARAMETER AzureFeed
Default: https://dotnetcli.blob.core.windows.net/dotnet
Default: https://dotnetcli.azureedge.net/dotnet
This parameter should not be usually changed by user. It allows to change URL for the Azure feed used by this installer.
.PARAMETER ProxyAddress
If set, the installer will use the proxy when making web requests
#>
[cmdletbinding()]
param(
[string]$Channel="preview",
[string]$Channel="rel-1.0.0",
[string]$Version="Latest",
[string]$InstallDir="<auto>",
[string]$Architecture="<auto>",
@ -58,7 +60,9 @@ param(
[switch]$DebugSymbols, # TODO: Switch does not work yet. Symbols zip is not being uploaded yet.
[switch]$DryRun,
[switch]$NoPath,
[string]$AzureFeed="https://dotnetcli.blob.core.windows.net/dotnet"
[string]$AzureFeed="https://dotnetcli.azureedge.net/dotnet",
[string]$UncachedFeed="https://dotnetcli.blob.core.windows.net/dotnet",
[string]$ProxyAddress
)
Set-StrictMode -Version Latest
@ -115,25 +119,73 @@ function Get-Version-Info-From-Version-Text([string]$VersionText) {
return $VersionInfo
}
function Load-Assembly([string] $Assembly) {
try {
Add-Type -Assembly $Assembly | Out-Null
}
catch {
# On Nano Server, Powershell Core Edition is used. Add-Type is unable to resolve base class assemblies because they are not GAC'd.
# Loading the base class assemblies is not unnecessary as the types will automatically get resolved.
}
}
function GetHTTPResponse([Uri] $Uri)
{
$HttpClient = $null
try {
# HttpClient is used vs Invoke-WebRequest in order to support Nano Server which doesn't support the Invoke-WebRequest cmdlet.
Load-Assembly -Assembly System.Net.Http
if($ProxyAddress){
$HttpClientHandler = New-Object System.Net.Http.HttpClientHandler
$HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{Address=$ProxyAddress}
$HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler
}
else {
$HttpClient = New-Object System.Net.Http.HttpClient
}
$Response = $HttpClient.GetAsync($Uri).Result
if (($Response -eq $null) -or (-not ($Response.IsSuccessStatusCode)))
{
$ErrorMsg = "Failed to download $Uri."
if ($Response -ne $null)
{
$ErrorMsg += " $Response"
}
throw $ErrorMsg
}
return $Response
}
finally {
if ($HttpClient -ne $null) {
$HttpClient.Dispose()
}
}
}
function Get-Latest-Version-Info([string]$AzureFeed, [string]$AzureChannel, [string]$CLIArchitecture) {
Say-Invocation $MyInvocation
$VersionFileUrl = $null
if ($SharedRuntime) {
$VersionFileUrl = "$AzureFeed/$AzureChannel/dnvm/latest.sharedfx.win.$CLIArchitecture.version"
$VersionFileUrl = "$UncachedFeed/$AzureChannel/dnvm/latest.sharedfx.win.$CLIArchitecture.version"
}
else {
$VersionFileUrl = "$AzureFeed/$AzureChannel/dnvm/latest.win.$CLIArchitecture.version"
$VersionFileUrl = "$UncachedFeed/Sdk/$AzureChannel/latest.version"
}
$Response = Invoke-WebRequest -UseBasicParsing $VersionFileUrl
switch ($Response.Headers.'Content-Type'){
{ ($_ -eq "application/octet-stream") } { $VersionText = [Text.Encoding]::UTF8.GetString($Response.Content) }
{ ($_ -eq "text/plain") } { $VersionText = $Response.Content }
default { throw "``$Response.Headers.'Content-Type'`` is an unknown .version file content type." }
$Response = GetHTTPResponse -Uri $VersionFileUrl
$StringContent = $Response.Content.ReadAsStringAsync().Result
switch ($Response.Content.Headers.ContentType) {
{ ($_ -eq "application/octet-stream") } { $VersionText = [Text.Encoding]::UTF8.GetString($StringContent) }
{ ($_ -eq "text/plain") } { $VersionText = $StringContent }
default { throw "``$Response.Content.Headers.ContentType`` is an unknown .version file content type." }
}
$VersionInfo = Get-Version-Info-From-Version-Text $VersionText
@ -147,10 +199,8 @@ function Get-Azure-Channel-From-Channel([string]$Channel) {
# For compatibility with build scripts accept also directly Azure channels names
switch ($Channel.ToLower()) {
{ ($_ -eq "future") -or ($_ -eq "dev") } { return "dev" }
{ ($_ -eq "beta") } { return "beta" }
{ ($_ -eq "preview") } { return "preview" }
{ $_ -eq "production" } { throw "Production channel does not exist yet" }
default { throw "``$Channel`` is an invalid channel name. Use one of the following: ``future``, ``preview``, ``production``" }
default { return $_ }
}
}
@ -169,22 +219,19 @@ function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$AzureCha
function Get-Download-Links([string]$AzureFeed, [string]$AzureChannel, [string]$SpecificVersion, [string]$CLIArchitecture) {
Say-Invocation $MyInvocation
$ret = @()
$files = @()
if ($SharedRuntime) {
$files += "dotnet";
$PayloadURL = "$AzureFeed/$AzureChannel/Binaries/$SpecificVersion/dotnet-win-$CLIArchitecture.$SpecificVersion.zip"
}
else {
$files += "dotnet-dev";
}
foreach ($file in $files) {
$PayloadURL = "$AzureFeed/$AzureChannel/Binaries/$SpecificVersion/$file-win-$CLIArchitecture.$SpecificVersion.zip"
Say-Verbose "Constructed payload URL: $PayloadURL"
$ret += $PayloadURL
$PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-dev-win-$CLIArchitecture.$SpecificVersion.zip"
}
Say-Verbose "Constructed payload URL: $PayloadURL"
$ret += $PayloadURL
return $ret
}
@ -212,7 +259,7 @@ function Get-Version-Info-From-Version-File([string]$InstallRoot, [string]$Relat
$VersionFile = Join-Path -Path $InstallRoot -ChildPath $RelativePathToVersionFile
Say-Verbose "Local version file: $VersionFile"
if (Test-Path $VersionFile) {
$VersionText = cat $VersionFile
Say-Verbose "Local version file text: $VersionText"
@ -226,7 +273,7 @@ function Get-Version-Info-From-Version-File([string]$InstallRoot, [string]$Relat
function Is-Dotnet-Package-Installed([string]$InstallRoot, [string]$RelativePathToPackage, [string]$SpecificVersion) {
Say-Invocation $MyInvocation
$DotnetPackagePath = Join-Path -Path $InstallRoot -ChildPath $RelativePathToPackage | Join-Path -ChildPath $SpecificVersion
Say-Verbose "Is-Dotnet-Package-Installed: Path to a package: $DotnetPackagePath"
return Test-Path $DotnetPackagePath -PathType Container
@ -244,13 +291,13 @@ function Get-Path-Prefix-With-Version($path) {
if ($match.Success) {
return $entry.FullName.Substring(0, $match.Index + $match.Length)
}
return $null
}
function Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package([System.IO.Compression.ZipArchive]$Zip, [string]$OutPath) {
Say-Invocation $MyInvocation
$ret = @()
foreach ($entry in $Zip.Entries) {
$dir = Get-Path-Prefix-With-Version $entry.FullName
@ -261,12 +308,12 @@ function Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package([Sys
}
}
}
$ret = $ret | Sort-Object | Get-Unique
$values = ($ret | foreach { "$_" }) -join ";"
Say-Verbose "Directories to unpack: $values"
return $ret
}
@ -286,13 +333,13 @@ function Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package([Sys
function Extract-Dotnet-Package([string]$ZipPath, [string]$OutPath) {
Say-Invocation $MyInvocation
Add-Type -Assembly System.IO.Compression.FileSystem | Out-Null
Load-Assembly -Assembly System.IO.Compression.FileSystem
Set-Variable -Name Zip
try {
$Zip = [System.IO.Compression.ZipFile]::OpenRead($ZipPath)
$DirectoriesToUnpack = Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package -Zip $Zip -OutPath $OutPath
foreach ($entry in $Zip.Entries) {
$PathWithVersion = Get-Path-Prefix-With-Version $entry.FullName
if (($PathWithVersion -eq $null) -Or ($DirectoriesToUnpack -contains $PathWithVersion)) {
@ -313,6 +360,23 @@ function Extract-Dotnet-Package([string]$ZipPath, [string]$OutPath) {
}
}
function DownloadFile([Uri]$Uri, [string]$OutPath) {
$Stream = $null
try {
$Response = GetHTTPResponse -Uri $Uri
$Stream = $Response.Content.ReadAsStreamAsync().Result
$File = [System.IO.File]::Create($OutPath)
$Stream.CopyTo($File)
$File.Close()
}
finally {
if ($Stream -ne $null) {
$Stream.Dispose()
}
}
}
$AzureChannel = Get-Azure-Channel-From-Channel -Channel $Channel
$CLIArchitecture = Get-CLIArchitecture-From-Architecture $Architecture
$SpecificVersion = Get-Specific-Version-From-Version -AzureFeed $AzureFeed -AzureChannel $AzureChannel -CLIArchitecture $CLIArchitecture -Version $Version
@ -342,7 +406,7 @@ New-Item -ItemType Directory -Force -Path $InstallRoot | Out-Null
foreach ($DownloadLink in $DownloadLinks) {
$ZipPath = [System.IO.Path]::GetTempFileName()
Say "Downloading $DownloadLink"
$resp = Invoke-WebRequest -UseBasicParsing $DownloadLink -OutFile $ZipPath
DownloadFile -Uri $DownloadLink -OutPath $ZipPath
Say "Extracting zip from $DownloadLink"
Extract-Dotnet-Package -ZipPath $ZipPath -OutPath $InstallRoot
@ -360,4 +424,4 @@ else {
}
Say "Installation finished"
exit 0
exit 0

228
build/dotnet/dotnet-install.sh поставляемый
Просмотреть файл

@ -27,16 +27,16 @@ if [ -t 1 ]; then
# see if it supports colors
ncolors=$(tput colors)
if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
bold="$(tput bold)"
normal="$(tput sgr0)"
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"
cyan="$(tput setaf 6)"
white="$(tput setaf 7)"
bold="$(tput bold || echo)"
normal="$(tput sgr0 || echo)"
black="$(tput setaf 0 || echo)"
red="$(tput setaf 1 || echo)"
green="$(tput setaf 2 || echo)"
yellow="$(tput setaf 3 || echo)"
blue="$(tput setaf 4 || echo)"
magenta="$(tput setaf 5 || echo)"
cyan="$(tput setaf 6 || echo)"
white="$(tput setaf 7 || echo)"
fi
fi
@ -64,29 +64,65 @@ get_current_os_name() {
echo "osx"
return 0
else
# Detect Distro
if [ "$(cat /etc/*-release | grep -cim1 ubuntu)" -eq 1 ]; then
echo "ubuntu"
return 0
elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then
echo "centos"
return 0
elif [ "$(cat /etc/*-release | grep -cim1 rhel)" -eq 1 ]; then
echo "rhel"
return 0
elif [ "$(cat /etc/*-release | grep -cim1 debian)" -eq 1 ]; then
echo "debian"
return 0
if [ -e /etc/os-release ]; then
. /etc/os-release
case "$ID.$VERSION_ID" in
"centos.7")
echo "centos"
return 0
;;
"debian.8")
echo "debian"
return 0
;;
"fedora.23")
echo "fedora.23"
return 0
;;
"fedora.24")
echo "fedora.24"
return 0
;;
"opensuse.13.2")
echo "opensuse.13.2"
return 0
;;
"opensuse.42.1")
echo "opensuse.42.1"
return 0
;;
"rhel.7.0" | "rhel.7.1" | "rhel.7.2")
echo "rhel"
return 0
;;
"ubuntu.14.04")
echo "ubuntu"
return 0
;;
"ubuntu.16.04")
echo "ubuntu.16.04"
return 0
;;
"ubuntu.16.10")
echo "ubuntu.16.10"
return 0
;;
"alpine.3.4.3")
echo "alpine"
return 0
;;
esac
fi
fi
say_err "OS name could not be detected"
say_err "OS name could not be detected: $ID.$VERSION_ID"
return 1
}
machine_has() {
eval $invocation
which "$1" > /dev/null 2>&1
return $?
}
@ -96,13 +132,13 @@ check_min_reqs() {
say_err "curl is required to download dotnet. Install curl to proceed."
return 1
fi
return 0
}
check_pre_reqs() {
eval $invocation
local failing=false;
if [ "${DOTNET_INSTALL_SKIP_PREREQS:-}" = "1" ]; then
@ -126,7 +162,7 @@ check_pre_reqs() {
if [ "$failing" = true ]; then
return 1
fi
return 0
}
@ -134,7 +170,7 @@ check_pre_reqs() {
# input - $1
to_lowercase() {
#eval $invocation
echo "$1" | tr '[:upper:]' '[:lower:]'
return 0
}
@ -143,7 +179,7 @@ to_lowercase() {
# input - $1
remove_trailing_slash() {
#eval $invocation
local input=${1:-}
echo "${input%/}"
return 0
@ -153,7 +189,7 @@ remove_trailing_slash() {
# input - $1
remove_beginning_slash() {
#eval $invocation
local input=${1:-}
echo "${input#/}"
return 0
@ -164,13 +200,13 @@ remove_beginning_slash() {
# child_path - $2 - this parameter can be empty
combine_paths() {
eval $invocation
# TODO: Consider making it work with any number of paths. For now:
if [ ! -z "${3:-}" ]; then
say_err "combine_paths: Function takes two parameters."
return 1
fi
local root_path=$(remove_trailing_slash $1)
local child_path=$(remove_beginning_slash ${2:-})
say_verbose "combine_paths: root_path=$root_path"
@ -181,7 +217,7 @@ combine_paths() {
get_machine_architecture() {
eval $invocation
# Currently the only one supported
echo "x64"
return 0
@ -191,7 +227,7 @@ get_machine_architecture() {
# architecture - $1
get_normalized_architecture_from_architecture() {
eval $invocation
local architecture=$(to_lowercase $1)
case $architecture in
\<auto\>)
@ -207,7 +243,7 @@ get_normalized_architecture_from_architecture() {
return 1
;;
esac
say_err "Architecture ``$architecture`` not supported. If you think this is a bug, please report it at https://github.com/dotnet/cli/issues"
return 1
}
@ -221,7 +257,7 @@ get_normalized_architecture_from_architecture() {
# version_text - stdin
get_version_from_version_info() {
eval $invocation
cat | tail -n 1
return 0
}
@ -230,7 +266,7 @@ get_version_from_version_info() {
# version_text - stdin
get_commit_hash_from_version_info() {
eval $invocation
cat | head -n 1
return 0
}
@ -241,14 +277,14 @@ get_commit_hash_from_version_info() {
# specific_version - $3
is_dotnet_package_installed() {
eval $invocation
local install_root=$1
local relative_path_to_package=$2
local specific_version=${3//[$'\t\r\n']}
local dotnet_package_path=$(combine_paths $(combine_paths $install_root $relative_path_to_package) $specific_version)
say_verbose "is_dotnet_package_installed: dotnet_package_path=$dotnet_package_path"
if [ -d "$dotnet_package_path" ]; then
return 0
else
@ -262,21 +298,22 @@ is_dotnet_package_installed() {
# normalized_architecture - $3
get_latest_version_info() {
eval $invocation
local azure_feed=$1
local azure_channel=$2
local normalized_architecture=$3
local osname=$(get_current_os_name)
local osname
osname=$(get_current_os_name) || return 1
local version_file_url=null
if [ "$shared_runtime" = true ]; then
version_file_url="$azure_feed/$azure_channel/dnvm/latest.sharedfx.$osname.$normalized_architecture.version"
version_file_url="$uncached_feed/$azure_channel/dnvm/latest.sharedfx.$osname.$normalized_architecture.version"
else
version_file_url="$azure_feed/$azure_channel/dnvm/latest.$osname.$normalized_architecture.version"
version_file_url="$uncached_feed/Sdk/$azure_channel/latest.version"
fi
say_verbose "get_latest_version_info: latest url: $version_file_url"
download $version_file_url
return $?
}
@ -285,28 +322,20 @@ get_latest_version_info() {
# channel - $1
get_azure_channel_from_channel() {
eval $invocation
local channel=$(to_lowercase $1)
case $channel in
future|dev)
echo "dev"
return 0
;;
beta)
echo "beta"
return 0
;;
preview)
echo "preview"
return 0
;;
production)
say_err "Production channel does not exist yet"
return 1
esac
say_err "``$1`` is an invalid channel name. Use one of the following: ``future``, ``preview``, ``production``"
return 1
echo $channel
return 0
}
# args:
@ -316,15 +345,16 @@ get_azure_channel_from_channel() {
# version - $4
get_specific_version_from_version() {
eval $invocation
local azure_feed=$1
local azure_channel=$2
local normalized_architecture=$3
local version=$(to_lowercase $4)
case $version in
latest)
local version_info="$(get_latest_version_info $azure_feed $azure_channel $normalized_architecture)"
local version_info
version_info="$(get_latest_version_info $azure_feed $azure_channel $normalized_architecture)" || return 1
say_verbose "get_specific_version_from_version: version_info=$version_info"
echo "$version_info" | get_version_from_version_info
return 0
@ -347,28 +377,29 @@ get_specific_version_from_version() {
# specific_version - $4
construct_download_link() {
eval $invocation
local azure_feed=$1
local azure_channel=$2
local normalized_architecture=$3
local specific_version=${4//[$'\t\r\n']}
local osname=$(get_current_os_name)
local osname
osname=$(get_current_os_name) || return 1
local download_link=null
if [ "$shared_runtime" = true ]; then
download_link="$azure_feed/$azure_channel/Binaries/$specific_version/dotnet-$osname-$normalized_architecture.$specific_version.tar.gz"
else
download_link="$azure_feed/$azure_channel/Binaries/$specific_version/dotnet-dev-$osname-$normalized_architecture.$specific_version.tar.gz"
download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$osname-$normalized_architecture.$specific_version.tar.gz"
fi
echo "$download_link"
return 0
}
get_user_share_path() {
eval $invocation
if [ ! -z "${DOTNET_INSTALL_DIR:-}" ]; then
echo $DOTNET_INSTALL_DIR
else
@ -381,7 +412,7 @@ get_user_share_path() {
# install_dir - $1
resolve_installation_path() {
eval $invocation
local install_dir=$1
if [ "$install_dir" = "<auto>" ]; then
local user_share_path=$(get_user_share_path)
@ -389,7 +420,7 @@ resolve_installation_path() {
echo "$user_share_path"
return 0
fi
echo "$install_dir"
return 0
}
@ -398,7 +429,7 @@ resolve_installation_path() {
# install_root - $1
get_installed_version_info() {
eval $invocation
local install_root=$1
local version_file=$(combine_paths "$install_root" "$local_version_file_relative_path")
say_verbose "Local version file: $version_file"
@ -407,7 +438,7 @@ get_installed_version_info() {
echo "$version_info"
return 0
fi
say_verbose "Local version file not found."
return 0
}
@ -416,7 +447,7 @@ get_installed_version_info() {
# relative_or_absolute_path - $1
get_absolute_path() {
eval $invocation
local relative_or_absolute_path=$1
echo $(cd $(dirname "$1") && pwd -P)/$(basename "$1")
return 0
@ -434,7 +465,7 @@ copy_files_or_dirs_from_list() {
local out_path=$(remove_trailing_slash $2)
local override=$3
local override_switch=$(if [ "$override" = false ]; then printf -- "-n"; fi)
cat | uniq | while read -r file_path; do
local path=$(remove_beginning_slash ${file_path#$root_path})
local target=$out_path/$path
@ -450,21 +481,21 @@ copy_files_or_dirs_from_list() {
# out_path - $2
extract_dotnet_package() {
eval $invocation
local zip_path=$1
local out_path=$2
local temp_out_path=$(mktemp -d $temporary_file_template)
local failed=false
tar -xzf "$zip_path" -C "$temp_out_path" > /dev/null || failed=true
local folders_with_version_regex='^.*/[0-9]+\.[0-9]+[^/]+/'
find $temp_out_path -type f | grep -Eo $folders_with_version_regex | copy_files_or_dirs_from_list $temp_out_path $out_path false
find $temp_out_path -type f | grep -Ev $folders_with_version_regex | copy_files_or_dirs_from_list $temp_out_path $out_path true
rm -rf $temp_out_path
if [ "$failed" = true ]; then
say_err "Extraction failed"
return 1
@ -476,7 +507,7 @@ extract_dotnet_package() {
# [out_path] - $2 - stdout if not provided
download() {
eval $invocation
local remote_path=$1
local out_path=${2:-}
@ -486,7 +517,7 @@ download() {
else
curl --fail -s -o $out_path $remote_path || failed=true
fi
if [ "$failed" = true ]; then
say_err "Download failed"
return 1
@ -495,46 +526,46 @@ download() {
calculate_vars() {
eval $invocation
azure_channel=$(get_azure_channel_from_channel "$channel")
say_verbose "azure_channel=$azure_channel"
normalized_architecture=$(get_normalized_architecture_from_architecture "$architecture")
say_verbose "normalized_architecture=$normalized_architecture"
specific_version=$(get_specific_version_from_version $azure_feed $azure_channel $normalized_architecture $version)
say_verbose "specific_version=$specific_version"
if [ -z "$specific_version" ]; then
say_err "Could not get version information."
return 1
fi
download_link=$(construct_download_link $azure_feed $azure_channel $normalized_architecture $specific_version)
say_verbose "download_link=$download_link"
install_root=$(resolve_installation_path $install_dir)
say_verbose "install_root=$install_root"
}
install_dotnet() {
eval $invocation
if is_dotnet_package_installed $install_root "sdk" $specific_version; then
say ".NET SDK version $specific_version is already installed."
return 0
fi
mkdir -p $install_root
zip_path=$(mktemp $temporary_file_template)
say_verbose "Zip path: $zip_path"
say "Downloading $download_link"
download "$download_link" $zip_path
say_verbose "Downloaded file exists and readable? $(if [ -r $zip_path ]; then echo "yes"; else echo "no"; fi)"
say "Extracting zip"
extract_dotnet_package $zip_path $install_root
return 0
}
@ -542,14 +573,15 @@ local_version_file_relative_path="/.version"
bin_folder_relative_path=""
temporary_file_template="${TMPDIR:-/tmp}/dotnet.XXXXXXXXX"
channel="preview"
channel="rel-1.0.0"
version="Latest"
install_dir="<auto>"
architecture="<auto>"
debug_symbols=false
dry_run=false
no_path=false
azure_feed="https://dotnetcli.blob.core.windows.net/dotnet"
azure_feed="https://dotnetcli.azureedge.net/dotnet"
uncached_feed="https://dotnetcli.blob.core.windows.net/dotnet"
verbose=false
shared_runtime=false
@ -653,4 +685,4 @@ else
say "Binaries of dotnet can be found in $bin_path"
fi
say "Installation finished successfuly."
say "Installation finished successfully."

Просмотреть файл

@ -4,6 +4,7 @@
},
"dependencies": {
"Sake": "0.2.2",
"NuGetPackageVerifier": "1.0.0"
"NuGetPackageVerifier": "1.0.1-*",
"dotnet-test-xunit": "2.2.0-preview2-build1029"
}
}

Просмотреть файл

@ -133,7 +133,7 @@ default SAMPLES_PROJECT_GLOB = "samples/*/project.json"
var project = (JsonObject)Json.Deserialize(projectText);
var isSharedProject = project.Keys.Contains("shared");
// We don't want to embed the commit hash in it because
// We don't want to embed the commit hash in it because
// the consumers would get that file
if (!isSharedProject)
{
@ -157,14 +157,21 @@ default SAMPLES_PROJECT_GLOB = "samples/*/project.json"
{
projectGlobs.Add(SAMPLES_PROJECT_GLOB);
}
if (projectGlobs.Any())
{
DotnetBuild(string.Join(" ", projectGlobs.ToArray()), Configuration, BuildFramework);
}
}
if (srcProjects != null)
#build-pack .build-compile target='compile'
@{
if (Directory.Exists("src"))
{
Directory.CreateDirectory(BUILD_DIR);
var srcProjects = Files.Include(SRC_PROJECT_GLOB).ToList();
if (srcProjects != null && srcProjects.Count > 0)
{
srcProjects.ForEach(projectFile =>
{
DotnetPack(projectFile, BUILD_DIR, Configuration, E("KOREBUILD_DOTNET_PACK_OPTIONS") + " --no-build");
@ -174,6 +181,7 @@ default SAMPLES_PROJECT_GLOB = "samples/*/project.json"
{
File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true);
}
}
}
}
@ -243,6 +251,28 @@ default SAMPLES_PROJECT_GLOB = "samples/*/project.json"
}
}
#xunit-test-msbuild
@{
var projectFiles = Files.Include(TEST_PROJECT_GLOB);
foreach (var projectFile in projectFiles)
{
var projectDir = Path.GetDirectoryName(projectFile);
var projectName = Path.GetFileName(projectDir);
var targetDir = Path.Combine(projectDir, "bin", Configuration, "netcoreapp1.0");
var depsFile = Path.Combine(targetDir, projectName + ".deps.json");
var configFile = Path.Combine(targetDir, projectName + ".runtimeconfig.json");
var assembly = Path.Combine(targetDir, projectName + ".dll");
var msbuildDotnet = Path.Combine(BASE_DIR, ".build/dotnet/dotnet");
Exec(msbuildDotnet, string.Format(
@"exec --depsfile ""{0}"" --runtimeconfig ""{1}"" ""{2}"" ""{3}"" {4}",
depsFile,
configFile,
Path.Combine(BASE_DIR, ".build/dotnet-test-xunit/2.2.0-preview2-build1029/lib/netcoreapp1.0/dotnet-test-xunit.dll"),
assembly,
E("KOREBUILD_DOTNET_TEST_OPTIONS")));
}
}
#make-roslyn-fast
ngen-roslyn
@ -373,7 +403,7 @@ functions @{
{
get { return E("KOREBUILD_BUILD_SRC_ONLY") == "1"; }
}
bool AddAssemblyInfo
{
get { return E("KOREBUILD_ADD_ASSEMBLY_INFO") == "1"; }