2015-11-16 11:21:57 -08:00
#
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
2015-11-10 17:30:01 -08:00
param ( [ string ] $Configuration = " Debug " )
$ErrorActionPreference = " Stop "
. $PSScriptRoot \ _common . ps1
# Capture PATH for later
$StartPath = $env:PATH
$StartDotNetHome = $env:DOTNET_HOME
try {
# Check prereqs
if ( ! ( Get-Command -ErrorAction SilentlyContinue cmake ) ) {
throw @"
cmake is required to build the native host 'corehost' "
Download it from https : / / www . cmake . org
" @
}
# Install a stage 0
header " Installing dotnet stage 0 "
& " $PSScriptRoot \install.ps1 "
# Put stage 0 on the path
2015-11-16 10:20:47 -08:00
$DotNetTools = $env:DOTNET_INSTALL_DIR
if ( ! $DotNetTools ) {
$DotNetTools = " $( $env:LOCALAPPDATA ) \Microsoft\dotnet "
}
if ( Test-Path " $DotNetTools \cli\dotnet.exe " ) {
2015-11-10 17:30:01 -08:00
Write-Warning " Your stage0 is using the old layout "
2015-11-16 10:20:47 -08:00
$DnxDir = " $DotNetTools \cli\dnx "
$env:PATH = " $DotNetTools \cli; $StartPath "
} elseif ( Test-Path " $DotNetTools \cli\bin\dotnet.exe " ) {
$DnxDir = " $DotNetTools \cli\bin\dnx "
$env:PATH = " $DotNetTools \cli\bin; $StartPath "
} else {
throw " Couldn't find stage0 dotnet tools! "
2015-11-10 17:30:01 -08:00
}
# Restore packages
header " Restoring packages "
dotnet restore " $RepoRoot " - -quiet - -runtime " osx.10.10-x64 " - -runtime " ubuntu.14.04-x64 " - -runtime " win7-x64 "
header " Building corehost "
pushd " $RepoRoot \src\corehost "
try {
if ( ! ( Test-Path " cmake\ $Rid " ) ) {
mkdir " cmake\ $Rid " | Out-Null
}
cd " cmake\ $Rid "
cmake . . \ . . -G " Visual Studio 14 2015 Win64 "
$pf = $env:ProgramFiles
if ( Test-Path " env:\ProgramFiles(x86) " ) {
$pf = ( cat " env:\ProgramFiles(x86) " )
}
& " $pf \MSBuild\14.0\Bin\MSBuild.exe " ALL_BUILD . vcxproj / p: Configuration = " $Configuration "
if ( ! ( Test-Path $HostDir ) ) {
mkdir $HostDir | Out-Null
}
cp " $RepoRoot \src\corehost\cmake\ $Rid \ $Configuration \corehost.exe " $HostDir
2015-11-16 10:45:19 -08:00
if ( Test-Path " $RepoRoot \src\corehost\cmake\ $Rid \ $Configuration \corehost.pdb " )
{
cp " $RepoRoot \src\corehost\cmake\ $Rid \ $Configuration \corehost.pdb " $HostDir
}
2015-11-10 17:30:01 -08:00
} finally {
popd
}
# Build Stage 1
header " Building stage1 dotnet using downloaded stage0 ... "
& " $PSScriptRoot \build\build-stage.ps1 " -Tfm: $Tfm -Rid: $Rid -Configuration: $Configuration -OutputDir: $Stage1Dir -RepoRoot: $RepoRoot -HostDir: $HostDir
# Build Stage 2 using Stage 1
$env:PATH = " $Stage1Dir \bin; $StartPath "
header " Building stage2 dotnet using just-built stage1 ... "
& " $PSScriptRoot \build\build-stage.ps1 " -Tfm: $Tfm -Rid: $Rid -Configuration: $Configuration -OutputDir: $Stage2Dir -RepoRoot: $RepoRoot -HostDir: $HostDir
# Crossgen Roslyn
header " Crossgening Roslyn compiler ... "
cmd / c " $PSScriptRoot \crossgen\crossgen_roslyn.cmd " " $Stage2Dir "
# Copy dnx into stage 2
2015-11-17 11:45:31 -08:00
cp -rec " $DnxDir \ " " $Stage2Dir \bin\dnx\ "
2015-11-10 17:30:01 -08:00
# Copy in the dotnet-restore script
cp " $PSScriptRoot \dotnet-restore.cmd " " $Stage2Dir \bin\dotnet-restore.cmd "
2015-11-17 13:52:24 -08:00
# Copy in AppDeps
header " Acquiring Native App Dependencies "
cmd / c " $PSScriptRoot \build\build_appdeps.cmd " " $Stage2Dir "
2015-11-10 17:30:01 -08:00
# Smoke test stage2
$env:PATH = " $Stage2Dir \bin; $StartPath "
$env:DOTNET_HOME = " $Stage2Dir "
& " $PSScriptRoot \test\smoke-test.ps1 "
} finally {
$env:PATH = $StartPath
$env:DOTNET_HOME = $StartDotNetHome
}