Skip to content

Commit

Permalink
Bring Host build into separate project
Browse files Browse the repository at this point in the history
  • Loading branch information
brthor authored and eerhardt committed May 16, 2016
1 parent 07b785c commit 7bf08c5
Show file tree
Hide file tree
Showing 76 changed files with 1,065 additions and 320 deletions.
3 changes: 2 additions & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
REM Copyright (c) .NET Foundation and contributors. All rights reserved.
REM Licensed under the MIT license. See LICENSE file in the project root for full license information.

powershell -NoProfile -NoLogo -Command "%~dp0scripts\run-build.ps1 %*; exit $LastExitCode;"
powershell -NoProfile -NoLogo -Command "%~dp0build_projects\dotnet-host-build\build.ps1 %*; exit $LastExitCode;"
powershell -NoProfile -NoLogo -Command "%~dp0build_projects\dotnet-cli-build\build.ps1 %*; exit $LastExitCode;"
11 changes: 9 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@ done
temp="${args[@]}"
args=($temp)

dockerbuild()
{
BUILD_COMMAND=/opt/code/build_projects/dotnet-host-build/build.sh $DIR/scripts/dockerrun.sh --non-interactive "$@"
BUILD_COMMAND=/opt/code/build_projects/dotnet-cli-build/build.sh $DIR/scripts/dockerrun.sh --non-interactive "$@"
}

# Check if we need to build in docker
if [ ! -z "$BUILD_IN_DOCKER" ]; then
$DIR/scripts/dockerbuild.sh "${args[@]}"
dockerbuild "${args[@]}"
else
$DIR/scripts/run-build.sh "${args[@]}"
$DIR/build_projects/dotnet-host-build/build.sh "${args[@]}"
$DIR/build_projects/dotnet-cli-build/build.sh "${args[@]}"
fi

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ public class PrepareTargets
public static BuildTargetResult CheckInstallerBuildPlatformDependencies(BuildTargetContext c) => c.Success();

// All major targets will depend on this in order to ensure variables are set up right if they are run independently
[Target(nameof(GenerateVersions), nameof(UpdateTemplateVersions), nameof(CheckPrereqs), nameof(LocateStage0), nameof(ExpectedBuildArtifacts))]
[Target(
nameof(GenerateVersions),
nameof(UpdateTemplateVersions),
nameof(CheckPrereqs),
nameof(LocateStage0),
nameof(ExpectedBuildArtifacts),
nameof(RestorePackages))]
public static BuildTargetResult Init(BuildTargetContext c)
{
var configEnv = Environment.GetEnvironmentVariable("CONFIGURATION");
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -552,3 +552,4 @@ private static void DownloadPackagesForPush(string pathToDownload)
}
}
}

File renamed without changes.
25 changes: 10 additions & 15 deletions scripts/run-build.ps1 → build_projects/dotnet-cli-build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@ param(
[string]$Architecture="x64",
[string[]]$Targets=@("Default"),
[switch]$NoPackage,
[switch]$RunInstallerTestsInDocker,
[switch]$Help)

if($Help)
{
Write-Host "Usage: .\build.cmd [-Configuration <CONFIGURATION>] [-NoPackage] [-Help] [-Targets <TARGETS...>]"
Write-Host "Usage: .\build.ps1 [-Configuration <CONFIGURATION>] [-NoPackage] [-Help] [-Targets <TARGETS...>]"
Write-Host ""
Write-Host "Options:"
Write-Host " -Configuration <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug)"
Write-Host " -Architecture <ARCHITECTURE> Build the specified architecture (x64 or x86 (supported only on Windows), default: x64)"
Write-Host " -Targets <TARGETS...> Comma separated build targets to run (Init, Compile, Publish, etc.; Default is a full build and publish)"
Write-Host " -NoPackage Skip packaging targets"
Write-Host " -RunInstallerTestsInDocker Runs the .msi installer tests in a Docker container. Requires Windows 2016 TP4 or higher"
Write-Host " -Help Display this help message"
exit 0
}

$env:CONFIGURATION = $Configuration;
$RepoRoot = "$PSScriptRoot\..\.."

if($NoPackage)
{
Expand All @@ -36,13 +35,8 @@ else
$env:DOTNET_BUILD_SKIP_PACKAGING=0
}

if ($RunInstallerTestsInDocker)
{
$env:RunInstallerTestsInDocker=1
}

# Load Branch Info
cat "$PSScriptRoot\..\branchinfo.txt" | ForEach-Object {
cat "$RepoRoot\branchinfo.txt" | ForEach-Object {
if(!$_.StartsWith("#") -and ![String]::IsNullOrWhiteSpace($_)) {
$splat = $_.Split([char[]]@("="), 2)
Set-Content "env:\$($splat[0])" -Value $splat[1]
Expand All @@ -52,7 +46,7 @@ cat "$PSScriptRoot\..\branchinfo.txt" | ForEach-Object {
# Use a repo-local install directory (but not the artifacts directory because that gets cleaned a lot
if (!$env:DOTNET_INSTALL_DIR)
{
$env:DOTNET_INSTALL_DIR="$PSScriptRoot\..\.dotnet_stage0\Windows\$Architecture"
$env:DOTNET_INSTALL_DIR="$RepoRoot\.dotnet_stage0\Windows\$Architecture"
}

if (!(Test-Path $env:DOTNET_INSTALL_DIR))
Expand All @@ -61,26 +55,27 @@ if (!(Test-Path $env:DOTNET_INSTALL_DIR))
}

# Install a stage 0
Write-Host "Installing .NET Core CLI ($Architecture) Stage 0 from '$env:CHANNEL' channel"
& "$PSScriptRoot\obtain\dotnet-install.ps1" -Channel $env:CHANNEL -Architecture $Architecture -Verbose
Write-Host "Installing .NET Core CLI Stage 0 from branchinfo channel"
& "$RepoRoot\scripts\obtain\dotnet-install.ps1" -Channel $env:CHANNEL -Architecture $Architecture -Verbose
if($LASTEXITCODE -ne 0) { throw "Failed to install stage0" }

# Put the stage0 on the path
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"

# Restore the build scripts
Write-Host "Restoring Build Script projects..."
pushd $PSScriptRoot
pushd "$PSScriptRoot\.."
dotnet restore --infer-runtimes
if($LASTEXITCODE -ne 0) { throw "Failed to restore" }
popd

# Publish the builder
Write-Host "Compiling Build Scripts..."
dotnet publish "$PSScriptRoot\dotnet-cli-build" -o "$PSScriptRoot/dotnet-cli-build/bin" --framework netstandardapp1.5
dotnet publish "$PSScriptRoot" -o "$PSScriptRoot\bin" --framework netcoreapp1.0
if($LASTEXITCODE -ne 0) { throw "Failed to compile build scripts" }

# Run the builder
Write-Host "Invoking Build Scripts..."
Write-Host " Configuration: $env:CONFIGURATION"
& "$PSScriptRoot\dotnet-cli-build\bin\dotnet-cli-build.exe" @Targets
& "$PSScriptRoot\bin\dotnet-cli-build.exe" @Targets
if($LASTEXITCODE -ne 0) { throw "Build failed" }
25 changes: 10 additions & 15 deletions scripts/run-build.sh → build_projects/dotnet-cli-build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
OLDPATH="$PATH"

source "$DIR/common/_prettyprint.sh"
REPOROOT="$DIR/../.."
source "$REPOROOT/scripts/common/_prettyprint.sh"

while [[ $# > 0 ]]; do
lowerI="$(echo $1 | awk '{print tolower($0)}')"
Expand Down Expand Up @@ -78,13 +79,13 @@ while read line; do
IFS='=' read -ra splat <<< "$line"
export ${splat[0]}="${splat[1]}"
fi
done < "$DIR/../branchinfo.txt"
done < "$REPOROOT/branchinfo.txt"

# Use a repo-local install directory (but not the artifacts directory because that gets cleaned a lot
[ -z "$DOTNET_INSTALL_DIR" ] && export DOTNET_INSTALL_DIR=$DIR/../.dotnet_stage0/$(uname)
[ -d $DOTNET_INSTALL_DIR ] || mkdir -p $DOTNET_INSTALL_DIR
[ -z "$DOTNET_INSTALL_DIR" ] && export DOTNET_INSTALL_DIR=$REPOROOT/.dotnet_stage0/$(uname)
[ -d "$DOTNET_INSTALL_DIR" ] || mkdir -p $DOTNET_INSTALL_DIR

$DIR/obtain/dotnet-install.sh --channel $CHANNEL --verbose
$REPOROOT/scripts/obtain/dotnet-install.sh --channel $CHANNEL --verbose

# Put stage 0 on the PATH (for this shell only)
PATH="$DOTNET_INSTALL_DIR:$PATH"
Expand All @@ -100,24 +101,18 @@ fi
# Restore the build scripts
echo "Restoring Build Script projects..."
(
cd $DIR
cd "$DIR/.."
dotnet restore --infer-runtimes
)

# Build the builder
echo "Compiling Build Scripts..."
dotnet publish "$DIR/dotnet-cli-build" -o "$DIR/dotnet-cli-build/bin" --framework netstandardapp1.5
dotnet publish "$DIR" -o "$DIR/bin" --framework netcoreapp1.0

export PATH="$OLDPATH"
# Run the builder
echo "Invoking Build Scripts..."
echo "Configuration: $CONFIGURATION"

if [ -f "$DIR/dotnet-cli-build/bin/dotnet-cli-build" ]; then
$DIR/dotnet-cli-build/bin/dotnet-cli-build ${targets[@]}
exit $?
else
# We're on an older CLI. This is temporary while Ubuntu and CentOS VSO builds are stalled.
$DIR/dotnet-cli-build/bin/Debug/dnxcore50/dotnet-cli-build "${targets[@]}"
exit $?
fi
$DIR/bin/dotnet-cli-build ${targets[@]}
exit $?
27 changes: 27 additions & 0 deletions build_projects/dotnet-cli-build/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": "1.0.0-*",
"description": "Build scripts for dotnet-cli",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24027",
"Microsoft.CSharp": "4.0.1-rc2-24027",
"System.Dynamic.Runtime": "4.0.11-rc2-24027",
"System.Reflection.Metadata": "1.3.0-rc2-24027",
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027",
"System.Xml.XmlSerializer": "4.0.11-rc2-24027",
"WindowsAzure.Storage": "6.2.2-preview",

"Microsoft.DotNet.Cli.Build.Framework": {"target":"project"},
"shared-build-targets-utils": {"target": "project"}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dnxcore50",
"portable-net45+win8"
]
}
}
}
Loading

0 comments on commit 7bf08c5

Please sign in to comment.