зеркало из https://github.com/aspnet/KoreBuild.git
Add customizations required to test CLI tools with MSBuild
This commit is contained in:
Родитель
68c2072b77
Коммит
2a775bac7a
|
@ -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))
|
||||
|
|
|
@ -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
|
|
@ -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,26 +119,74 @@ 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
|
||||
$Response = GetHTTPResponse -Uri $VersionFileUrl
|
||||
$StringContent = $Response.Content.ReadAsStringAsync().Result
|
||||
|
||||
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." }
|
||||
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
|
||||
|
||||
return $VersionInfo
|
||||
|
@ -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 $_ }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,19 +221,16 @@ function Get-Download-Links([string]$AzureFeed, [string]$AzureChannel, [string]$
|
|||
Say-Invocation $MyInvocation
|
||||
|
||||
$ret = @()
|
||||
$files = @()
|
||||
|
||||
if ($SharedRuntime) {
|
||||
$files += "dotnet";
|
||||
$PayloadURL = "$AzureFeed/$AzureChannel/Binaries/$SpecificVersion/dotnet-win-$CLIArchitecture.$SpecificVersion.zip"
|
||||
}
|
||||
else {
|
||||
$files += "dotnet-dev";
|
||||
$PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-dev-win-$CLIArchitecture.$SpecificVersion.zip"
|
||||
}
|
||||
|
||||
foreach ($file in $files) {
|
||||
$PayloadURL = "$AzureFeed/$AzureChannel/Binaries/$SpecificVersion/$file-win-$CLIArchitecture.$SpecificVersion.zip"
|
||||
Say-Verbose "Constructed payload URL: $PayloadURL"
|
||||
$ret += $PayloadURL
|
||||
}
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
@ -286,7 +333,7 @@ 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)
|
||||
|
@ -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
|
||||
|
|
|
@ -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,23 +64,59 @@ 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
|
||||
if [ -e /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
|
||||
case "$ID.$VERSION_ID" in
|
||||
"centos.7")
|
||||
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
|
||||
;;
|
||||
"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
|
||||
}
|
||||
|
||||
|
@ -267,13 +303,14 @@ get_latest_version_info() {
|
|||
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"
|
||||
|
||||
|
@ -292,21 +329,13 @@ get_azure_channel_from_channel() {
|
|||
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:
|
||||
|
@ -324,7 +353,8 @@ get_specific_version_from_version() {
|
|||
|
||||
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
|
||||
|
@ -353,13 +383,14 @@ construct_download_link() {
|
|||
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"
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -162,8 +162,15 @@ default SAMPLES_PROJECT_GLOB = "samples/*/project.json"
|
|||
{
|
||||
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 =>
|
||||
{
|
||||
|
@ -176,6 +183,7 @@ default SAMPLES_PROJECT_GLOB = "samples/*/project.json"
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#native-compile target='compile' if='!IsLinux && Directory.Exists(Path.Combine(BASE_DIR, "src"))'
|
||||
var programFilesX86 = '${Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}'
|
||||
|
@ -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
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче