From 7bf08c5bd5d3214d9ed068b8920852842ea65ac0 Mon Sep 17 00:00:00 2001 From: Bryan Date: Wed, 11 May 2016 17:20:40 -0700 Subject: [PATCH] Bring Host build into separate project --- build.cmd | 3 +- build.sh | 11 +- .../AnsiColorExtensions.cs | 0 .../AnsiConsole.cs | 0 .../ArgumentEscaper.cs | 0 .../BuildContext.cs | 0 .../BuildFailureException.cs | 0 .../BuildHelpers.cs | 0 .../BuildReporter.cs | 0 .../BuildSetup.cs | 0 .../BuildTarget.cs | 0 .../BuildTargetContext.cs | 0 .../BuildTargetResult.cs | 0 .../Command.cs | 0 .../CommandResult.cs | 0 .../Constants.cs | 0 .../CurrentArchitecture.cs | 0 .../CurrentPlatform.cs | 0 .../DebugHelper.cs | 0 .../Enumerations/BuildArchitecture.cs | 0 .../Enumerations/BuildPlatform.cs | 0 ...Microsoft.DotNet.Cli.Build.Framework.xproj | 0 .../Reporter.cs | 0 .../StandardGoals.cs | 0 .../TargetAttribute.cs | 0 .../BuildArchitecturesAttribute.cs | 0 .../BuildPlatformsAttribute.cs | 0 .../TargetConditions/EnvironmentAttribute.cs | 0 .../TargetConditionAttribute.cs | 0 .../UndefinedTargetException.cs | 0 .../project.json | 0 .../dotnet-cli-build/CompileTargets.cs | 277 +----------------- .../dotnet-cli-build/DebTargets.cs | 0 .../dotnet-cli-build/InstallerTargets.cs | 0 .../dotnet-cli-build/MsiTargets.cs | 0 .../dotnet-cli-build/PackageDependencies.cs | 0 .../dotnet-cli-build/PackageTargets.cs | 0 .../dotnet-cli-build/PkgTargets.cs | 0 .../dotnet-cli-build/PrepareTargets.cs | 8 +- .../dotnet-cli-build/Program.cs | 0 .../dotnet-cli-build/PublishTargets.cs | 1 + .../dotnet-cli-build/TestPackageProjects.cs | 0 .../dotnet-cli-build/TestTargets.cs | 0 .../dotnet-cli-build/build.ps1 | 25 +- .../dotnet-cli-build/build.sh | 25 +- .../dotnet-cli-build/dotnet-cli-build.xproj | 0 build_projects/dotnet-cli-build/project.json | 27 ++ .../dotnet-host-build/CompileTargets.cs | 232 +++++++++++++++ .../dotnet-host-build/PrepareTargets.cs | 207 +++++++++++++ build_projects/dotnet-host-build/Program.cs | 17 ++ .../dotnet-host-build/StubPackageBuilder.cs | 102 +++++++ build_projects/dotnet-host-build/build.ps1 | 81 +++++ build_projects/dotnet-host-build/build.sh | 118 ++++++++ .../dotnet-host-build/dotnet-host-build.xproj | 18 ++ build_projects/dotnet-host-build/project.json | 28 ++ .../PackageDependencies.cs | 96 ++++++ .../Publishing/AzurePublisher.cs | 0 .../Publishing/DebRepoPublisher.cs | 0 .../Utils/AptDependencyUtility.cs | 2 +- .../Utils/BranchInfo.cs | 47 +++ .../Utils/BuildVersion.cs | 0 .../Utils/Crossgen.cs | 0 .../shared-build-targets-utils}/Utils/Dirs.cs | 0 .../Utils/DotNetCli.cs | 16 +- .../Utils/EnvVars.cs | 0 .../shared-build-targets-utils}/Utils/FS.cs | 0 .../Utils/HostVersion.cs | 0 .../Utils/JsonUtils.cs | 0 .../Utils/Monikers.cs | 0 .../Utils/PEUtils.cs | 0 .../Utils/Utils.cs | 5 + .../Utils/Version.cs | 0 .../Utils/YumDependencyUtility.cs | 2 +- .../shared-build-targets-utils}/project.json | 5 +- .../shared-build-targets-utils.xproj | 19 ++ scripts/dockerbuild.sh | 13 - 76 files changed, 1065 insertions(+), 320 deletions(-) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/AnsiColorExtensions.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/AnsiConsole.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/ArgumentEscaper.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/BuildContext.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/BuildFailureException.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/BuildHelpers.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/BuildReporter.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/BuildTarget.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/BuildTargetContext.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/BuildTargetResult.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/Command.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/CommandResult.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/Constants.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/CurrentArchitecture.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/CurrentPlatform.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/DebugHelper.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildArchitecture.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildPlatform.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/Microsoft.DotNet.Cli.Build.Framework.xproj (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/Reporter.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/StandardGoals.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/TargetAttribute.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/BuildArchitecturesAttribute.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/BuildPlatformsAttribute.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/EnvironmentAttribute.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/TargetConditionAttribute.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/UndefinedTargetException.cs (100%) rename {scripts => build_projects}/Microsoft.DotNet.Cli.Build.Framework/project.json (100%) rename {scripts => build_projects}/dotnet-cli-build/CompileTargets.cs (60%) rename {scripts => build_projects}/dotnet-cli-build/DebTargets.cs (100%) rename {scripts => build_projects}/dotnet-cli-build/InstallerTargets.cs (100%) rename {scripts => build_projects}/dotnet-cli-build/MsiTargets.cs (100%) rename {scripts => build_projects}/dotnet-cli-build/PackageDependencies.cs (100%) rename {scripts => build_projects}/dotnet-cli-build/PackageTargets.cs (100%) rename {scripts => build_projects}/dotnet-cli-build/PkgTargets.cs (100%) rename {scripts => build_projects}/dotnet-cli-build/PrepareTargets.cs (98%) rename {scripts => build_projects}/dotnet-cli-build/Program.cs (100%) mode change 100755 => 100644 rename {scripts => build_projects}/dotnet-cli-build/PublishTargets.cs (99%) rename {scripts => build_projects}/dotnet-cli-build/TestPackageProjects.cs (100%) rename {scripts => build_projects}/dotnet-cli-build/TestTargets.cs (100%) rename scripts/run-build.ps1 => build_projects/dotnet-cli-build/build.ps1 (71%) rename scripts/run-build.sh => build_projects/dotnet-cli-build/build.sh (83%) rename {scripts => build_projects}/dotnet-cli-build/dotnet-cli-build.xproj (100%) create mode 100644 build_projects/dotnet-cli-build/project.json create mode 100644 build_projects/dotnet-host-build/CompileTargets.cs create mode 100644 build_projects/dotnet-host-build/PrepareTargets.cs create mode 100644 build_projects/dotnet-host-build/Program.cs create mode 100644 build_projects/dotnet-host-build/StubPackageBuilder.cs create mode 100644 build_projects/dotnet-host-build/build.ps1 create mode 100755 build_projects/dotnet-host-build/build.sh create mode 100644 build_projects/dotnet-host-build/dotnet-host-build.xproj create mode 100644 build_projects/dotnet-host-build/project.json create mode 100644 build_projects/shared-build-targets-utils/PackageDependencies.cs rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Publishing/AzurePublisher.cs (100%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Publishing/DebRepoPublisher.cs (100%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/AptDependencyUtility.cs (89%) create mode 100644 build_projects/shared-build-targets-utils/Utils/BranchInfo.cs rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/BuildVersion.cs (100%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/Crossgen.cs (100%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/Dirs.cs (100%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/DotNetCli.cs (78%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/EnvVars.cs (100%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/FS.cs (100%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/HostVersion.cs (100%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/JsonUtils.cs (100%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/Monikers.cs (100%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/PEUtils.cs (100%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/Utils.cs (96%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/Version.cs (100%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/Utils/YumDependencyUtility.cs (88%) rename {scripts/dotnet-cli-build => build_projects/shared-build-targets-utils}/project.json (87%) mode change 100755 => 100644 create mode 100644 build_projects/shared-build-targets-utils/shared-build-targets-utils.xproj delete mode 100755 scripts/dockerbuild.sh diff --git a/build.cmd b/build.cmd index 31cdaa27d..133def113 100644 --- a/build.cmd +++ b/build.cmd @@ -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;" diff --git a/build.sh b/build.sh index fa8100bff..429086595 100755 --- a/build.sh +++ b/build.sh @@ -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 diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/AnsiColorExtensions.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/AnsiColorExtensions.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/AnsiColorExtensions.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/AnsiColorExtensions.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/AnsiConsole.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/AnsiConsole.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/AnsiConsole.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/AnsiConsole.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/ArgumentEscaper.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/ArgumentEscaper.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/ArgumentEscaper.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/ArgumentEscaper.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildContext.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildContext.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/BuildContext.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildContext.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildFailureException.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildFailureException.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/BuildFailureException.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildFailureException.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildHelpers.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildHelpers.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/BuildHelpers.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildHelpers.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildReporter.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildReporter.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/BuildReporter.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildReporter.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTarget.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildTarget.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTarget.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildTarget.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTargetContext.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildTargetContext.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTargetContext.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildTargetContext.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTargetResult.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildTargetResult.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTargetResult.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/BuildTargetResult.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/Command.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/Command.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/Command.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/Command.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/CommandResult.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/CommandResult.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/CommandResult.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/CommandResult.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/Constants.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/Constants.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/Constants.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/Constants.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/CurrentArchitecture.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/CurrentArchitecture.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/CurrentArchitecture.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/CurrentArchitecture.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/CurrentPlatform.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/CurrentPlatform.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/CurrentPlatform.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/CurrentPlatform.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/DebugHelper.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/DebugHelper.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/DebugHelper.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/DebugHelper.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildArchitecture.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildArchitecture.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildArchitecture.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildArchitecture.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildPlatform.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildPlatform.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildPlatform.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildPlatform.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/Microsoft.DotNet.Cli.Build.Framework.xproj b/build_projects/Microsoft.DotNet.Cli.Build.Framework/Microsoft.DotNet.Cli.Build.Framework.xproj similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/Microsoft.DotNet.Cli.Build.Framework.xproj rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/Microsoft.DotNet.Cli.Build.Framework.xproj diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/Reporter.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/Reporter.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/Reporter.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/Reporter.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/StandardGoals.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/StandardGoals.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/StandardGoals.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/StandardGoals.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/TargetAttribute.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/TargetAttribute.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/TargetAttribute.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/TargetAttribute.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/BuildArchitecturesAttribute.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/BuildArchitecturesAttribute.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/BuildArchitecturesAttribute.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/BuildArchitecturesAttribute.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/BuildPlatformsAttribute.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/BuildPlatformsAttribute.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/BuildPlatformsAttribute.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/BuildPlatformsAttribute.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/EnvironmentAttribute.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/EnvironmentAttribute.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/EnvironmentAttribute.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/EnvironmentAttribute.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/TargetConditionAttribute.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/TargetConditionAttribute.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/TargetConditionAttribute.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/TargetConditionAttribute.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/UndefinedTargetException.cs b/build_projects/Microsoft.DotNet.Cli.Build.Framework/UndefinedTargetException.cs similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/UndefinedTargetException.cs rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/UndefinedTargetException.cs diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/project.json b/build_projects/Microsoft.DotNet.Cli.Build.Framework/project.json similarity index 100% rename from scripts/Microsoft.DotNet.Cli.Build.Framework/project.json rename to build_projects/Microsoft.DotNet.Cli.Build.Framework/project.json diff --git a/scripts/dotnet-cli-build/CompileTargets.cs b/build_projects/dotnet-cli-build/CompileTargets.cs similarity index 60% rename from scripts/dotnet-cli-build/CompileTargets.cs rename to build_projects/dotnet-cli-build/CompileTargets.cs index 7a629ceec..fbb0d27f7 100644 --- a/scripts/dotnet-cli-build/CompileTargets.cs +++ b/build_projects/dotnet-cli-build/CompileTargets.cs @@ -67,47 +67,20 @@ namespace Microsoft.DotNet.Cli.Build return c.Success(); } - // Moving PrepareTargets.RestorePackages after PackagePkgProjects because managed code depends on the - // Microsoft.NETCore.App package that is created during PackagePkgProjects. - [Target(nameof(PrepareTargets.Init), nameof(CompileCoreHost), nameof(PackagePkgProjects), nameof(RestoreLockedCoreHost), nameof(PrepareTargets.RestorePackages), nameof(CompileStage1), nameof(CompileStage2))] + [Target(nameof(PrepareTargets.Init), nameof(RestoreLockedCoreHost), nameof(CompileStage1), nameof(CompileStage2))] public static BuildTargetResult Compile(BuildTargetContext c) { return c.Success(); } - // We need to generate stub host packages so we can restore our standalone test assets against the metapackage - // we built earlier in the build - // https://github.com/dotnet/cli/issues/2438 - [Target] - public static BuildTargetResult GenerateStubHostPackages(BuildTargetContext c) - { - var hostVersion = c.BuildContext.Get("HostVersion"); - var currentRid = HostPackagePlatformRid; - PrepareDummyRuntimeNuGetPackage(DotNetCli.Stage0); - foreach (var hostPackage in hostVersion.LatestHostPackages) - { - foreach (var rid in HostPackageSupportedRids.Values.Distinct()) - { - if (!rid.Equals(currentRid)) - { - CreateDummyRuntimeNuGetPackage( - DotNetCli.Stage0, - hostPackage.Key, - rid, - hostPackage.Value, - Dirs.CorehostDummyPackages); - } - } - } - return c.Success(); - } - [Target(nameof(PrepareTargets.Init))] public static BuildTargetResult RestoreLockedCoreHost(BuildTargetContext c) { var hostVersion = c.BuildContext.Get("HostVersion"); var lockedHostFxrVersion = hostVersion.LockedHostFxrVersion; + var currentRid = HostPackagePlatformRid; + string projectJson = $@"{{ ""dependencies"": {{ ""Microsoft.NETCore.DotNetHostResolver"" : ""{lockedHostFxrVersion}"" @@ -125,7 +98,7 @@ namespace Microsoft.DotNet.Cli.Build var tempPjFile = Path.Combine(tempPjDirectory, "project.json"); File.WriteAllText(tempPjFile, projectJson); - DotNetCli.Stage0.Restore("--verbosity", "verbose", "--infer-runtimes", + DotNetCli.Stage0.Restore("--verbosity", "verbose", "--infer-runtimes", "--fallbacksource", Dirs.CorehostLocalPackages, "--fallbacksource", Dirs.CorehostDummyPackages) .WorkingDirectory(tempPjDirectory) @@ -146,176 +119,6 @@ namespace Microsoft.DotNet.Cli.Build return c.Success(); } - [Target(nameof(PrepareTargets.Init))] - public static BuildTargetResult CompileCoreHost(BuildTargetContext c) - { - var hostVersion = c.BuildContext.Get("HostVersion"); - - // Generate build files - var cmakeOut = Path.Combine(Dirs.CorehostLatest, "cmake"); - - Rmdir(cmakeOut); - Mkdirp(cmakeOut); - - var configuration = c.BuildContext.Get("Configuration"); - - // Run the build - string rid = GetRuntimeId(); - string corehostSrcDir = Path.Combine(c.BuildContext.BuildDirectory, "src", "corehost"); - string commitHash = c.BuildContext.Get("CommitHash"); - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Why does Windows directly call cmake but Linux/Mac calls "build.sh" in the corehost dir? - // See the comment in "src/corehost/build.sh" for details. It doesn't work for some reason. - var visualStudio = IsWinx86 ? "Visual Studio 14 2015" : "Visual Studio 14 2015 Win64"; - var archMacro = IsWinx86 ? "-DCLI_CMAKE_PLATFORM_ARCH_I386=1" : "-DCLI_CMAKE_PLATFORM_ARCH_AMD64=1"; - var ridMacro = $"-DCLI_CMAKE_RUNTIME_ID:STRING={rid}"; - var arch = IsWinx86 ? "x86" : "x64"; - var baseSupportedRid = $"win7-{arch}"; - var cmakeHostPolicyVer = $"-DCLI_CMAKE_HOST_POLICY_VER:STRING={hostVersion.LatestHostPolicyVersion}"; - var cmakeHostFxrVer = $"-DCLI_CMAKE_HOST_FXR_VER:STRING={hostVersion.LatestHostFxrVersion}"; - var cmakeBaseRid = $"-DCLI_CMAKE_PKG_RID:STRING={baseSupportedRid}"; - var cmakeCommitHash = $"-DCLI_CMAKE_COMMIT_HASH:STRING={commitHash}"; - - ExecIn(cmakeOut, "cmake", - corehostSrcDir, - archMacro, - ridMacro, - cmakeHostFxrVer, - cmakeHostPolicyVer, - cmakeBaseRid, - cmakeCommitHash, - "-G", - visualStudio); - - var pf32 = RuntimeInformation.OSArchitecture == Architecture.X64 ? - Environment.GetEnvironmentVariable("ProgramFiles(x86)") : - Environment.GetEnvironmentVariable("ProgramFiles"); - - if (configuration.Equals("Release")) - { - // Cmake calls it "RelWithDebInfo" in the generated MSBuild - configuration = "RelWithDebInfo"; - } - - Exec(Path.Combine(pf32, "MSBuild", "14.0", "Bin", "MSBuild.exe"), - Path.Combine(cmakeOut, "ALL_BUILD.vcxproj"), - $"/p:Configuration={configuration}"); - - // Copy the output out - File.Copy(Path.Combine(cmakeOut, "cli", configuration, "dotnet.exe"), Path.Combine(Dirs.CorehostLatest, "dotnet.exe"), overwrite: true); - File.Copy(Path.Combine(cmakeOut, "cli", configuration, "dotnet.pdb"), Path.Combine(Dirs.CorehostLatest, "dotnet.pdb"), overwrite: true); - File.Copy(Path.Combine(cmakeOut, "cli", "dll", configuration, "hostpolicy.dll"), Path.Combine(Dirs.CorehostLatest, "hostpolicy.dll"), overwrite: true); - File.Copy(Path.Combine(cmakeOut, "cli", "dll", configuration, "hostpolicy.pdb"), Path.Combine(Dirs.CorehostLatest, "hostpolicy.pdb"), overwrite: true); - File.Copy(Path.Combine(cmakeOut, "cli", "fxr", configuration, "hostfxr.dll"), Path.Combine(Dirs.CorehostLatest, "hostfxr.dll"), overwrite: true); - File.Copy(Path.Combine(cmakeOut, "cli", "fxr", configuration, "hostfxr.pdb"), Path.Combine(Dirs.CorehostLatest, "hostfxr.pdb"), overwrite: true); - } - else - { - ExecIn(cmakeOut, Path.Combine(c.BuildContext.BuildDirectory, "src", "corehost", "build.sh"), - "--arch", - "x64", - "--fxrver", - hostVersion.LatestHostFxrVersion, - "--policyver", - hostVersion.LatestHostPolicyVersion, - "--rid", - rid, - "--commithash", - commitHash); - - // Copy the output out - File.Copy(Path.Combine(cmakeOut, "cli", "dotnet"), Path.Combine(Dirs.CorehostLatest, "dotnet"), overwrite: true); - File.Copy(Path.Combine(cmakeOut, "cli", "dll", HostPolicyBaseName), Path.Combine(Dirs.CorehostLatest, HostPolicyBaseName), overwrite: true); - File.Copy(Path.Combine(cmakeOut, "cli", "fxr", DotnetHostFxrBaseName), Path.Combine(Dirs.CorehostLatest, DotnetHostFxrBaseName), overwrite: true); - } - return c.Success(); - } - - [Target(nameof(CompileTargets.GenerateStubHostPackages))] - public static BuildTargetResult PackagePkgProjects(BuildTargetContext c) - { - var arch = IsWinx86 ? "x86" : "x64"; - - var hostVersion = c.BuildContext.Get("HostVersion"); - var hostNugetversion = hostVersion.LatestHostVersion; - var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{hostNugetversion}{Environment.NewLine}"; - var pkgDir = Path.Combine(c.BuildContext.BuildDirectory, "pkg"); - File.WriteAllText(Path.Combine(pkgDir, "version.txt"), content); - - if (CurrentPlatform.IsWindows) - { - Command.Create(Path.Combine(pkgDir, "pack.cmd")) - // Workaround to arg escaping adding backslashes for arguments to .cmd scripts. - .Environment("__WorkaroundCliCoreHostBuildArch", arch) - .Environment("__WorkaroundCliCoreHostBinDir", Dirs.CorehostLatest) - .Environment("__WorkaroundCliCoreHostPolicyVer", hostVersion.LatestHostPolicyVersionNoSuffix) - .Environment("__WorkaroundCliCoreHostFxrVer", hostVersion.LatestHostFxrVersionNoSuffix) - .Environment("__WorkaroundCliCoreHostVer", hostVersion.LatestHostVersionNoSuffix) - .Environment("__WorkaroundCliCoreHostBuildMajor", hostVersion.LatestHostBuildMajor) - .Environment("__WorkaroundCliCoreHostVersionTag", hostVersion.LatestHostPrerelease) - .ForwardStdOut() - .ForwardStdErr() - .Execute() - .EnsureSuccessful(); - } - else - { - Exec(Path.Combine(pkgDir, "pack.sh"), - "--arch", - "x64", - "--hostbindir", - Dirs.CorehostLatest, - "--policyver", - hostVersion.LatestHostPolicyVersionNoSuffix, - "--fxrver", - hostVersion.LatestHostFxrVersionNoSuffix, - "--hostver", - hostVersion.LatestHostVersionNoSuffix, - "--build", - hostVersion.LatestHostBuildMajor, - "--vertag", - hostVersion.LatestHostPrerelease); - } - foreach (var file in Directory.GetFiles(Path.Combine(pkgDir, "bin", "packages"), "*.nupkg")) - { - var fileName = Path.GetFileName(file); - File.Copy(file, Path.Combine(Dirs.CorehostLocalPackages, fileName), true); - - Console.WriteLine($"Copying package {fileName} to artifacts directory {Dirs.CorehostLocalPackages}."); - } - foreach (var item in hostVersion.LatestHostPackages) - { - var fileFilter = $"runtime.{HostPackagePlatformRid}.{item.Key}.{item.Value}.nupkg"; - if (Directory.GetFiles(Dirs.CorehostLocalPackages, fileFilter).Length == 0) - { - throw new BuildFailureException($"Nupkg for {fileFilter} was not created."); - } - } - return c.Success(); - } - - private static string GetRuntimeId() - { - string info = DotNetCli.Stage0.Exec("", "--info").CaptureStdOut().Execute().StdOut; - string rid = Array.Find(info.Split(Environment.NewLine.ToCharArray()), (e) => e.Contains("RID:"))?.Replace("RID:", "").Trim(); - - // TODO: when Stage0 is updated with the new --info, remove this legacy check for --version - if (string.IsNullOrEmpty(rid)) - { - string version = DotNetCli.Stage0.Exec("", "--version").CaptureStdOut().Execute().StdOut; - rid = Array.Find(version.Split(Environment.NewLine.ToCharArray()), (e) => e.Contains("Runtime Id:")).Replace("Runtime Id:", "").Trim(); - } - - if (string.IsNullOrEmpty(rid)) - { - throw new BuildFailureException("Could not find the Runtime ID from Stage0 --info or --version"); - } - - return rid; - } - [Target(nameof(PrepareTargets.Init))] public static BuildTargetResult CompileStage1(BuildTargetContext c) { @@ -393,64 +196,6 @@ namespace Microsoft.DotNet.Cli.Build return c.Success(); } - - private static void PrepareDummyRuntimeNuGetPackage(DotNetCli dotnet) - { - var projectJson = new StringBuilder(); - projectJson.Append("{"); - projectJson.Append(" \"dependencies\": { \"NETStandard.Library\": \"1.5.0-rc2-24008\" },"); - projectJson.Append(" \"frameworks\": { \"netcoreapp1.0\": { \"imports\": [\"netstandard1.5\", \"dnxcore50\"] } },"); - projectJson.Append(" \"runtimes\": { \"win7-x64\": { } },"); - projectJson.Append("}"); - - var programCs = "using System; namespace ConsoleApplication { public class Program { public static void Main(string[] args) { Console.WriteLine(\"Hello World!\"); } } }"; - - var tempPjDirectory = Path.Combine(Dirs.Intermediate, "dummyNuGetPackageIntermediate"); - FS.Rmdir(tempPjDirectory); - - Directory.CreateDirectory(tempPjDirectory); - - var tempPjFile = Path.Combine(tempPjDirectory, "project.json"); - var tempSourceFile = Path.Combine(tempPjDirectory, "Program.cs"); - - File.WriteAllText(tempPjFile, projectJson.ToString()); - File.WriteAllText(tempSourceFile, programCs.ToString()); - - dotnet.Restore("--verbosity", "verbose", "--disable-parallel") - .WorkingDirectory(tempPjDirectory) - .Execute() - .EnsureSuccessful(); - dotnet.Build(tempPjFile, "--runtime", "win7-x64") - .WorkingDirectory(tempPjDirectory) - .Execute() - .EnsureSuccessful(); - } - - private static void CreateDummyRuntimeNuGetPackage(DotNetCli dotnet, string basePackageId, string rid, string version, string outputDir) - { - var packageId = $"runtime.{rid}.{basePackageId}"; - - var projectJson = new StringBuilder(); - projectJson.Append("{"); - projectJson.Append($" \"version\": \"{version}\","); - projectJson.Append($" \"name\": \"{packageId}\","); - projectJson.Append(" \"dependencies\": { \"NETStandard.Library\": \"1.5.0-rc2-24008\" },"); - projectJson.Append(" \"frameworks\": { \"netcoreapp1.0\": { \"imports\": [\"netstandard1.5\", \"dnxcore50\"] } },"); - projectJson.Append("}"); - - var tempPjDirectory = Path.Combine(Dirs.Intermediate, "dummyNuGetPackageIntermediate"); - var tempPjFile = Path.Combine(tempPjDirectory, "project.json"); - - File.WriteAllText(tempPjFile, projectJson.ToString()); - - dotnet.Pack( - tempPjFile, "--no-build", - "--output", outputDir) - .WorkingDirectory(tempPjDirectory) - .Execute() - .EnsureSuccessful(); - } - private static void CleanOutputDir(string directory) { foreach (var file in FilesToClean) @@ -492,9 +237,9 @@ namespace Microsoft.DotNet.Cli.Build string SharedFrameworkSourceRoot = GenerateSharedFrameworkProject(c, SharedFrameworkTemplateSourceRoot, sharedFrameworkRid); dotnetCli.Restore( - "--verbosity", "verbose", - "--disable-parallel", - "--infer-runtimes", + "--verbosity", "verbose", + "--disable-parallel", + "--infer-runtimes", "--fallbacksource", Dirs.CorehostLocalPackages) .WorkingDirectory(SharedFrameworkSourceRoot) .Execute() @@ -560,9 +305,9 @@ namespace Microsoft.DotNet.Cli.Build File.Copy( Path.Combine(Dirs.CorehostLocked, DotnetHostBaseName), Path.Combine(SharedFrameworkNameAndVersionRoot, DotnetHostBaseName), true); - File.Copy( - Path.Combine(Dirs.CorehostLocked, DotnetHostBaseName), - Path.Combine(SharedFrameworkNameAndVersionRoot, $"corehost{Constants.ExeSuffix}"), true); + File.Copy( + Path.Combine(Dirs.CorehostLocked, DotnetHostBaseName), + Path.Combine(SharedFrameworkNameAndVersionRoot, $"corehost{Constants.ExeSuffix}"), true); File.Copy( Path.Combine(Dirs.CorehostLocked, DotnetHostFxrBaseName), Path.Combine(SharedFrameworkNameAndVersionRoot, DotnetHostFxrBaseName), true); @@ -740,4 +485,4 @@ namespace Microsoft.DotNet.Cli.Build File.Delete(Path.Combine(path, $"{name}.pdb")); } } -} +} \ No newline at end of file diff --git a/scripts/dotnet-cli-build/DebTargets.cs b/build_projects/dotnet-cli-build/DebTargets.cs similarity index 100% rename from scripts/dotnet-cli-build/DebTargets.cs rename to build_projects/dotnet-cli-build/DebTargets.cs diff --git a/scripts/dotnet-cli-build/InstallerTargets.cs b/build_projects/dotnet-cli-build/InstallerTargets.cs similarity index 100% rename from scripts/dotnet-cli-build/InstallerTargets.cs rename to build_projects/dotnet-cli-build/InstallerTargets.cs diff --git a/scripts/dotnet-cli-build/MsiTargets.cs b/build_projects/dotnet-cli-build/MsiTargets.cs similarity index 100% rename from scripts/dotnet-cli-build/MsiTargets.cs rename to build_projects/dotnet-cli-build/MsiTargets.cs diff --git a/scripts/dotnet-cli-build/PackageDependencies.cs b/build_projects/dotnet-cli-build/PackageDependencies.cs similarity index 100% rename from scripts/dotnet-cli-build/PackageDependencies.cs rename to build_projects/dotnet-cli-build/PackageDependencies.cs diff --git a/scripts/dotnet-cli-build/PackageTargets.cs b/build_projects/dotnet-cli-build/PackageTargets.cs similarity index 100% rename from scripts/dotnet-cli-build/PackageTargets.cs rename to build_projects/dotnet-cli-build/PackageTargets.cs diff --git a/scripts/dotnet-cli-build/PkgTargets.cs b/build_projects/dotnet-cli-build/PkgTargets.cs similarity index 100% rename from scripts/dotnet-cli-build/PkgTargets.cs rename to build_projects/dotnet-cli-build/PkgTargets.cs diff --git a/scripts/dotnet-cli-build/PrepareTargets.cs b/build_projects/dotnet-cli-build/PrepareTargets.cs similarity index 98% rename from scripts/dotnet-cli-build/PrepareTargets.cs rename to build_projects/dotnet-cli-build/PrepareTargets.cs index 3ea825c30..de3805f7a 100644 --- a/scripts/dotnet-cli-build/PrepareTargets.cs +++ b/build_projects/dotnet-cli-build/PrepareTargets.cs @@ -33,7 +33,13 @@ namespace Microsoft.DotNet.Cli.Build 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"); diff --git a/scripts/dotnet-cli-build/Program.cs b/build_projects/dotnet-cli-build/Program.cs old mode 100755 new mode 100644 similarity index 100% rename from scripts/dotnet-cli-build/Program.cs rename to build_projects/dotnet-cli-build/Program.cs diff --git a/scripts/dotnet-cli-build/PublishTargets.cs b/build_projects/dotnet-cli-build/PublishTargets.cs similarity index 99% rename from scripts/dotnet-cli-build/PublishTargets.cs rename to build_projects/dotnet-cli-build/PublishTargets.cs index 847eb4148..bcf3a9eb2 100644 --- a/scripts/dotnet-cli-build/PublishTargets.cs +++ b/build_projects/dotnet-cli-build/PublishTargets.cs @@ -552,3 +552,4 @@ namespace Microsoft.DotNet.Cli.Build } } } + diff --git a/scripts/dotnet-cli-build/TestPackageProjects.cs b/build_projects/dotnet-cli-build/TestPackageProjects.cs similarity index 100% rename from scripts/dotnet-cli-build/TestPackageProjects.cs rename to build_projects/dotnet-cli-build/TestPackageProjects.cs diff --git a/scripts/dotnet-cli-build/TestTargets.cs b/build_projects/dotnet-cli-build/TestTargets.cs similarity index 100% rename from scripts/dotnet-cli-build/TestTargets.cs rename to build_projects/dotnet-cli-build/TestTargets.cs diff --git a/scripts/run-build.ps1 b/build_projects/dotnet-cli-build/build.ps1 similarity index 71% rename from scripts/run-build.ps1 rename to build_projects/dotnet-cli-build/build.ps1 index 13c1fa8ab..8c6d2bcfc 100644 --- a/scripts/run-build.ps1 +++ b/build_projects/dotnet-cli-build/build.ps1 @@ -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 ] [-NoPackage] [-Help] [-Targets ]" + Write-Host "Usage: .\build.ps1 [-Configuration ] [-NoPackage] [-Help] [-Targets ]" Write-Host "" Write-Host "Options:" Write-Host " -Configuration Build the specified Configuration (Debug or Release, default: Debug)" Write-Host " -Architecture Build the specified architecture (x64 or x86 (supported only on Windows), default: x64)" Write-Host " -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) { @@ -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] @@ -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)) @@ -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" } diff --git a/scripts/run-build.sh b/build_projects/dotnet-cli-build/build.sh similarity index 83% rename from scripts/run-build.sh rename to build_projects/dotnet-cli-build/build.sh index f811a6d41..1ef8f7ca1 100755 --- a/scripts/run-build.sh +++ b/build_projects/dotnet-cli-build/build.sh @@ -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)}')" @@ -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" @@ -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 $? diff --git a/scripts/dotnet-cli-build/dotnet-cli-build.xproj b/build_projects/dotnet-cli-build/dotnet-cli-build.xproj similarity index 100% rename from scripts/dotnet-cli-build/dotnet-cli-build.xproj rename to build_projects/dotnet-cli-build/dotnet-cli-build.xproj diff --git a/build_projects/dotnet-cli-build/project.json b/build_projects/dotnet-cli-build/project.json new file mode 100644 index 000000000..a0920323f --- /dev/null +++ b/build_projects/dotnet-cli-build/project.json @@ -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" + ] + } + } +} diff --git a/build_projects/dotnet-host-build/CompileTargets.cs b/build_projects/dotnet-host-build/CompileTargets.cs new file mode 100644 index 000000000..cf2b5464a --- /dev/null +++ b/build_projects/dotnet-host-build/CompileTargets.cs @@ -0,0 +1,232 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using Microsoft.DotNet.Cli.Build.Framework; +using Microsoft.DotNet.InternalAbstractions; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Microsoft.DotNet.Cli.Build; +using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; +using static Microsoft.DotNet.Cli.Build.FS; + +namespace Microsoft.DotNet.Host.Build +{ + public class CompileTargets + { + public static readonly bool IsWinx86 = CurrentPlatform.IsWindows && CurrentArchitecture.Isx86; + + public static string HostPackagePlatformRid => HostPackageSupportedRids[ + (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows) + ? $"win7-{RuntimeEnvironment.RuntimeArchitecture}" + : RuntimeEnvironment.GetRuntimeIdentifier()]; + + public static readonly Dictionary HostPackageSupportedRids = new Dictionary() + { + // Key: Current platform RID. Value: The actual publishable (non-dummy) package name produced by the build system for this RID. + { "win7-x64", "win7-x64" }, + { "win7-x86", "win7-x86" }, + { "osx.10.10-x64", "osx.10.10-x64" }, + { "osx.10.11-x64", "osx.10.10-x64" }, + { "ubuntu.14.04-x64", "ubuntu.14.04-x64" }, + { "centos.7-x64", "rhel.7-x64" }, + { "rhel.7-x64", "rhel.7-x64" }, + { "rhel.7.2-x64", "rhel.7-x64" }, + { "debian.8-x64", "debian.8-x64" } + }; + + + private static string DotnetHostBaseName => $"dotnet{Constants.ExeSuffix}"; + private static string DotnetHostFxrBaseName => $"{Constants.DynamicLibPrefix}hostfxr{Constants.DynamicLibSuffix}"; + private static string HostPolicyBaseName => $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"; + + [Target(nameof(PrepareTargets.Init), + nameof(CompileCoreHost), + nameof(PackagePkgProjects))] + public static BuildTargetResult Compile(BuildTargetContext c) + { + return c.Success(); + } + + // We need to generate stub host packages so we can restore our standalone test assets against the metapackage + // we built earlier in the build + // https://github.com/dotnet/cli/issues/2438 + [Target] + public static BuildTargetResult GenerateStubHostPackages(BuildTargetContext c) + { + var hostVersion = c.BuildContext.Get("HostVersion"); + var currentRid = HostPackagePlatformRid; + + var stubPackageBuilder = new StubPackageBuilder(DotNetCli.Stage0, Dirs.Intermediate, Dirs.CorehostDummyPackages); + + foreach (var hostPackage in hostVersion.LatestHostPackages) + { + foreach (var rid in HostPackageSupportedRids.Values.Distinct()) + { + if (!rid.Equals(currentRid)) + { + var basePackageId = hostPackage.Key; + var packageVersion = hostPackage.Value; + + var packageId = $"runtime.{rid}.{basePackageId}"; + + stubPackageBuilder.GeneratePackage(packageId, packageVersion); + } + } + } + return c.Success(); + } + + [Target] + public static BuildTargetResult CompileCoreHost(BuildTargetContext c) + { + var hostVersion = c.BuildContext.Get("HostVersion"); + + // Generate build files + var cmakeOut = Path.Combine(Dirs.CorehostLatest, "cmake"); + + Rmdir(cmakeOut); + Mkdirp(cmakeOut); + + var configuration = c.BuildContext.Get("Configuration"); + + // Run the build + string rid = DotNetCli.Stage0.GetRuntimeId(); + string corehostSrcDir = Path.Combine(c.BuildContext.BuildDirectory, "src", "corehost"); + string commitHash = c.BuildContext.Get("CommitHash"); + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + // Why does Windows directly call cmake but Linux/Mac calls "build.sh" in the corehost dir? + // See the comment in "src/corehost/build.sh" for details. It doesn't work for some reason. + var visualStudio = IsWinx86 ? "Visual Studio 14 2015" : "Visual Studio 14 2015 Win64"; + var archMacro = IsWinx86 ? "-DCLI_CMAKE_PLATFORM_ARCH_I386=1" : "-DCLI_CMAKE_PLATFORM_ARCH_AMD64=1"; + var ridMacro = $"-DCLI_CMAKE_RUNTIME_ID:STRING={rid}"; + var arch = IsWinx86 ? "x86" : "x64"; + var baseSupportedRid = $"win7-{arch}"; + var cmakeHostPolicyVer = $"-DCLI_CMAKE_HOST_POLICY_VER:STRING={hostVersion.LatestHostPolicyVersion}"; + var cmakeHostFxrVer = $"-DCLI_CMAKE_HOST_FXR_VER:STRING={hostVersion.LatestHostFxrVersion}"; + var cmakeBaseRid = $"-DCLI_CMAKE_PKG_RID:STRING={baseSupportedRid}"; + var cmakeCommitHash = $"-DCLI_CMAKE_COMMIT_HASH:STRING={commitHash}"; + + ExecIn(cmakeOut, "cmake", + corehostSrcDir, + archMacro, + ridMacro, + cmakeHostFxrVer, + cmakeHostPolicyVer, + cmakeBaseRid, + cmakeCommitHash, + "-G", + visualStudio); + + var pf32 = RuntimeInformation.OSArchitecture == Architecture.X64 ? + Environment.GetEnvironmentVariable("ProgramFiles(x86)") : + Environment.GetEnvironmentVariable("ProgramFiles"); + + if (configuration.Equals("Release")) + { + // Cmake calls it "RelWithDebInfo" in the generated MSBuild + configuration = "RelWithDebInfo"; + } + + Exec(Path.Combine(pf32, "MSBuild", "14.0", "Bin", "MSBuild.exe"), + Path.Combine(cmakeOut, "ALL_BUILD.vcxproj"), + $"/p:Configuration={configuration}"); + + // Copy the output out + File.Copy(Path.Combine(cmakeOut, "cli", configuration, "dotnet.exe"), Path.Combine(Dirs.CorehostLatest, "dotnet.exe"), overwrite: true); + File.Copy(Path.Combine(cmakeOut, "cli", configuration, "dotnet.pdb"), Path.Combine(Dirs.CorehostLatest, "dotnet.pdb"), overwrite: true); + File.Copy(Path.Combine(cmakeOut, "cli", "dll", configuration, "hostpolicy.dll"), Path.Combine(Dirs.CorehostLatest, "hostpolicy.dll"), overwrite: true); + File.Copy(Path.Combine(cmakeOut, "cli", "dll", configuration, "hostpolicy.pdb"), Path.Combine(Dirs.CorehostLatest, "hostpolicy.pdb"), overwrite: true); + File.Copy(Path.Combine(cmakeOut, "cli", "fxr", configuration, "hostfxr.dll"), Path.Combine(Dirs.CorehostLatest, "hostfxr.dll"), overwrite: true); + File.Copy(Path.Combine(cmakeOut, "cli", "fxr", configuration, "hostfxr.pdb"), Path.Combine(Dirs.CorehostLatest, "hostfxr.pdb"), overwrite: true); + } + else + { + ExecIn(cmakeOut, Path.Combine(c.BuildContext.BuildDirectory, "src", "corehost", "build.sh"), + "--arch", + "x64", + "--fxrver", + hostVersion.LatestHostFxrVersion, + "--policyver", + hostVersion.LatestHostPolicyVersion, + "--rid", + rid, + "--commithash", + commitHash); + + // Copy the output out + File.Copy(Path.Combine(cmakeOut, "cli", "dotnet"), Path.Combine(Dirs.CorehostLatest, "dotnet"), overwrite: true); + File.Copy(Path.Combine(cmakeOut, "cli", "dll", HostPolicyBaseName), Path.Combine(Dirs.CorehostLatest, HostPolicyBaseName), overwrite: true); + File.Copy(Path.Combine(cmakeOut, "cli", "fxr", DotnetHostFxrBaseName), Path.Combine(Dirs.CorehostLatest, DotnetHostFxrBaseName), overwrite: true); + } + return c.Success(); + } + + [Target(nameof(CompileTargets.GenerateStubHostPackages))] + public static BuildTargetResult PackagePkgProjects(BuildTargetContext c) + { + var arch = IsWinx86 ? "x86" : "x64"; + + var hostVersion = c.BuildContext.Get("HostVersion"); + var hostNugetversion = hostVersion.LatestHostVersion; + var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{hostNugetversion}{Environment.NewLine}"; + var pkgDir = Path.Combine(c.BuildContext.BuildDirectory, "pkg"); + File.WriteAllText(Path.Combine(pkgDir, "version.txt"), content); + + if (CurrentPlatform.IsWindows) + { + Command.Create(Path.Combine(pkgDir, "pack.cmd")) + // Workaround to arg escaping adding backslashes for arguments to .cmd scripts. + .Environment("__WorkaroundCliCoreHostBuildArch", arch) + .Environment("__WorkaroundCliCoreHostBinDir", Dirs.CorehostLatest) + .Environment("__WorkaroundCliCoreHostPolicyVer", hostVersion.LatestHostPolicyVersionNoSuffix) + .Environment("__WorkaroundCliCoreHostFxrVer", hostVersion.LatestHostFxrVersionNoSuffix) + .Environment("__WorkaroundCliCoreHostVer", hostVersion.LatestHostVersionNoSuffix) + .Environment("__WorkaroundCliCoreHostBuildMajor", hostVersion.LatestHostBuildMajor) + .Environment("__WorkaroundCliCoreHostVersionTag", hostVersion.LatestHostPrerelease) + .ForwardStdOut() + .ForwardStdErr() + .Execute() + .EnsureSuccessful(); + } + else + { + Exec(Path.Combine(pkgDir, "pack.sh"), + "--arch", + "x64", + "--hostbindir", + Dirs.CorehostLatest, + "--policyver", + hostVersion.LatestHostPolicyVersionNoSuffix, + "--fxrver", + hostVersion.LatestHostFxrVersionNoSuffix, + "--hostver", + hostVersion.LatestHostVersionNoSuffix, + "--build", + hostVersion.LatestHostBuildMajor, + "--vertag", + hostVersion.LatestHostPrerelease); + } + foreach (var file in Directory.GetFiles(Path.Combine(pkgDir, "bin", "packages"), "*.nupkg")) + { + var fileName = Path.GetFileName(file); + File.Copy(file, Path.Combine(Dirs.CorehostLocalPackages, fileName), true); + + Console.WriteLine($"Copying package {fileName} to artifacts directory {Dirs.CorehostLocalPackages}."); + } + foreach (var item in hostVersion.LatestHostPackages) + { + var fileFilter = $"runtime.{HostPackagePlatformRid}.{item.Key}.{item.Value}.nupkg"; + if (Directory.GetFiles(Dirs.CorehostLocalPackages, fileFilter).Length == 0) + { + throw new BuildFailureException($"Nupkg for {fileFilter} was not created."); + } + } + return c.Success(); + } + } +} diff --git a/build_projects/dotnet-host-build/PrepareTargets.cs b/build_projects/dotnet-host-build/PrepareTargets.cs new file mode 100644 index 000000000..137217ee6 --- /dev/null +++ b/build_projects/dotnet-host-build/PrepareTargets.cs @@ -0,0 +1,207 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Text.RegularExpressions; +using Microsoft.DotNet.Cli.Build.Framework; +using Microsoft.DotNet.InternalAbstractions; +using Newtonsoft.Json.Linq; +using Microsoft.DotNet.Cli.Build; +using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; +using static Microsoft.DotNet.Cli.Build.FS; +using static Microsoft.DotNet.Cli.Build.Utils; + +namespace Microsoft.DotNet.Host.Build +{ + public class PrepareTargets + { + [Target(nameof(Init))] + public static BuildTargetResult Prepare(BuildTargetContext c) => c.Success(); + + [Target(nameof(CheckPrereqCmakePresent), nameof(CheckPlatformDependencies))] + public static BuildTargetResult CheckPrereqs(BuildTargetContext c) => c.Success(); + + [Target(nameof(CheckCoreclrPlatformDependencies))] + public static BuildTargetResult CheckPlatformDependencies(BuildTargetContext c) => c.Success(); + + [Target(nameof(CheckUbuntuCoreclrAndCoreFxDependencies), nameof(CheckCentOSCoreclrAndCoreFxDependencies))] + public static BuildTargetResult CheckCoreclrPlatformDependencies(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(CheckPrereqs), nameof(LocateStage0), nameof(ExpectedBuildArtifacts))] + public static BuildTargetResult Init(BuildTargetContext c) + { + var configEnv = Environment.GetEnvironmentVariable("CONFIGURATION"); + + if (string.IsNullOrEmpty(configEnv)) + { + configEnv = "Debug"; + } + + c.BuildContext["Configuration"] = configEnv; + c.BuildContext["Channel"] = Environment.GetEnvironmentVariable("CHANNEL"); + + c.Info($"Building {c.BuildContext["Configuration"]} to: {Dirs.Output}"); + c.Info("Build Environment:"); + c.Info($" Operating System: {RuntimeEnvironment.OperatingSystem} {RuntimeEnvironment.OperatingSystemVersion}"); + c.Info($" Platform: {RuntimeEnvironment.OperatingSystemPlatform}"); + + return c.Success(); + } + + [Target] + public static BuildTargetResult GenerateVersions(BuildTargetContext c) + { + var gitResult = Cmd("git", "rev-list", "--count", "HEAD") + .CaptureStdOut() + .Execute(); + gitResult.EnsureSuccessful(); + var commitCount = int.Parse(gitResult.StdOut); + + gitResult = Cmd("git", "rev-parse", "HEAD") + .CaptureStdOut() + .Execute(); + gitResult.EnsureSuccessful(); + var commitHash = gitResult.StdOut.Trim(); + + var hostVersion = new HostVersion() + { + CommitCount = commitCount + }; + + c.BuildContext["HostVersion"] = hostVersion; + c.BuildContext["CommitHash"] = commitHash; + + c.Info($"Building Version: {hostVersion.LatestHostVersionNoSuffix} (NuGet Packages: {hostVersion.LatestHostVersion})"); + c.Info($"From Commit: {commitHash}"); + + return c.Success(); + } + + [Target] + public static BuildTargetResult LocateStage0(BuildTargetContext c) + { + // We should have been run in the repo root, so locate the stage 0 relative to current directory + var stage0 = DotNetCli.Stage0.BinPath; + + if (!Directory.Exists(stage0)) + { + return c.Failed($"Stage 0 directory does not exist: {stage0}"); + } + + // Identify the version + string versionFile = Directory.GetFiles(stage0, ".version", SearchOption.AllDirectories).FirstOrDefault(); + + if (string.IsNullOrEmpty(versionFile)) + { + throw new Exception($"'.version' file not found in '{stage0}' folder"); + } + + var version = File.ReadAllLines(versionFile); + c.Info($"Using Stage 0 Version: {version[1]}"); + + return c.Success(); + } + + [Target] + public static BuildTargetResult ExpectedBuildArtifacts(BuildTargetContext c) + { + var config = Environment.GetEnvironmentVariable("CONFIGURATION"); + var versionBadgeName = $"{CurrentPlatform.Current}_{CurrentArchitecture.Current}_{config}_version_badge.svg"; + c.BuildContext["VersionBadge"] = Path.Combine(Dirs.Output, versionBadgeName); + + var hostVersion = c.BuildContext.Get("HostVersion").LockedHostVersion; + return c.Success(); + } + + [Target] + [BuildPlatforms(BuildPlatform.Ubuntu)] + public static BuildTargetResult CheckUbuntuCoreclrAndCoreFxDependencies(BuildTargetContext c) + { + var errorMessageBuilder = new StringBuilder(); + var stage0 = DotNetCli.Stage0.BinPath; + + foreach (var package in PackageDependencies.UbuntuCoreclrAndCoreFxDependencies) + { + if (!AptDependencyUtility.PackageIsInstalled(package)) + { + errorMessageBuilder.Append($"Error: Coreclr package dependency {package} missing."); + errorMessageBuilder.Append(Environment.NewLine); + errorMessageBuilder.Append($"-> install with apt-get install {package}"); + errorMessageBuilder.Append(Environment.NewLine); + } + } + + if (errorMessageBuilder.Length == 0) + { + return c.Success(); + } + else + { + return c.Failed(errorMessageBuilder.ToString()); + } + } + + [Target] + [BuildPlatforms(BuildPlatform.CentOS)] + public static BuildTargetResult CheckCentOSCoreclrAndCoreFxDependencies(BuildTargetContext c) + { + var errorMessageBuilder = new StringBuilder(); + + foreach (var package in PackageDependencies.CentosCoreclrAndCoreFxDependencies) + { + if (!YumDependencyUtility.PackageIsInstalled(package)) + { + errorMessageBuilder.Append($"Error: Coreclr package dependency {package} missing."); + errorMessageBuilder.Append(Environment.NewLine); + errorMessageBuilder.Append($"-> install with yum install {package}"); + errorMessageBuilder.Append(Environment.NewLine); + } + } + + if (errorMessageBuilder.Length == 0) + { + return c.Success(); + } + else + { + return c.Failed(errorMessageBuilder.ToString()); + } + } + + [Target] + public static BuildTargetResult CheckPrereqCmakePresent(BuildTargetContext c) + { + try + { + Command.Create("cmake", "--version") + .CaptureStdOut() + .CaptureStdErr() + .Execute(); + } + catch (Exception ex) + { + string message = $@"Error running cmake: {ex.Message} +cmake is required to build the native host 'corehost'"; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + message += Environment.NewLine + "Download it from https://www.cmake.org"; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + message += Environment.NewLine + "Ubuntu: 'sudo apt-get install cmake'"; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + message += Environment.NewLine + "OS X w/Homebrew: 'brew install cmake'"; + } + return c.Failed(message); + } + + return c.Success(); + } + } +} diff --git a/build_projects/dotnet-host-build/Program.cs b/build_projects/dotnet-host-build/Program.cs new file mode 100644 index 000000000..129531b13 --- /dev/null +++ b/build_projects/dotnet-host-build/Program.cs @@ -0,0 +1,17 @@ +using Microsoft.DotNet.Cli.Build.Framework; + +namespace Microsoft.DotNet.Host.Build +{ + public class Program + { + public static int Main(string[] args) + { + DebugHelper.HandleDebugSwitch(ref args); + + return BuildSetup.Create(".NET Core Host") + .UseStandardGoals() + .UseAllTargetsFromAssembly() + .Run(args); + } + } +} diff --git a/build_projects/dotnet-host-build/StubPackageBuilder.cs b/build_projects/dotnet-host-build/StubPackageBuilder.cs new file mode 100644 index 000000000..1e787d314 --- /dev/null +++ b/build_projects/dotnet-host-build/StubPackageBuilder.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Text; +using Microsoft.DotNet.Cli.Build.Framework; +using Microsoft.WindowsAzure.Storage; +using Microsoft.WindowsAzure.Storage.Blob; +using Microsoft.DotNet.Cli.Build; + +using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; + +namespace Microsoft.DotNet.Host.Build +{ + public class StubPackageBuilder + { + private DotNetCli _dotnet; + private string _intermediateDirectory; + private string _outputDirectory; + + private bool _stubBitsBuilt = false; + + public StubPackageBuilder(DotNetCli dotnet, string intermediateDirectory, string outputDirectory) + { + _dotnet = dotnet; + _intermediateDirectory = intermediateDirectory; + _outputDirectory = outputDirectory; + } + + public void GeneratePackage(string packageId, string version) + { + if (! _stubBitsBuilt) + { + BuildStubBits(_dotnet, _intermediateDirectory); + } + + CreateStubPackage(_dotnet, packageId, version, _intermediateDirectory, _outputDirectory); + } + + private void BuildStubBits(DotNetCli dotnet, string intermediateDirectory) + { + var projectJson = new StringBuilder(); + projectJson.Append("{"); + projectJson.Append(" \"dependencies\": { \"NETStandard.Library\": \"1.5.0-rc2-24008\" },"); + projectJson.Append(" \"frameworks\": { \"netcoreapp1.0\": { \"imports\": [\"netstandard1.5\", \"dnxcore50\"] } },"); + projectJson.Append(" \"runtimes\": { \"win7-x64\": { } },"); + projectJson.Append("}"); + + var programCs = "using System; namespace ConsoleApplication { public class Program { public static void Main(string[] args) { Console.WriteLine(\"Hello World!\"); } } }"; + + var tempPjDirectory = Path.Combine(intermediateDirectory, "dummyNuGetPackageIntermediate"); + FS.Rmdir(tempPjDirectory); + + Directory.CreateDirectory(tempPjDirectory); + + var tempPjFile = Path.Combine(tempPjDirectory, "project.json"); + var tempSourceFile = Path.Combine(tempPjDirectory, "Program.cs"); + + File.WriteAllText(tempPjFile, projectJson.ToString()); + File.WriteAllText(tempSourceFile, programCs.ToString()); + + dotnet.Restore("--verbosity", "verbose", "--disable-parallel") + .WorkingDirectory(tempPjDirectory) + .Execute() + .EnsureSuccessful(); + dotnet.Build(tempPjFile, "--runtime", "win7-x64") + .WorkingDirectory(tempPjDirectory) + .Execute() + .EnsureSuccessful(); + + _stubBitsBuilt = true; + } + + private static void CreateStubPackage(DotNetCli dotnet, + string packageId, + string version, + string intermediateDirectory, + string outputDirectory) + { + var projectJson = new StringBuilder(); + projectJson.Append("{"); + projectJson.Append($" \"version\": \"{version}\","); + projectJson.Append($" \"name\": \"{packageId}\","); + projectJson.Append(" \"dependencies\": { \"NETStandard.Library\": \"1.5.0-rc2-24008\" },"); + projectJson.Append(" \"frameworks\": { \"netcoreapp1.0\": { \"imports\": [\"netstandard1.5\", \"dnxcore50\"] } },"); + projectJson.Append("}"); + + var tempPjDirectory = Path.Combine(intermediateDirectory, "dummyNuGetPackageIntermediate"); + var tempPjFile = Path.Combine(tempPjDirectory, "project.json"); + + File.WriteAllText(tempPjFile, projectJson.ToString()); + + dotnet.Pack( + tempPjFile, "--no-build", + "--output", outputDirectory) + .WorkingDirectory(tempPjDirectory) + .Execute() + .EnsureSuccessful(); + } + } +} diff --git a/build_projects/dotnet-host-build/build.ps1 b/build_projects/dotnet-host-build/build.ps1 new file mode 100644 index 000000000..4e6ae8aa6 --- /dev/null +++ b/build_projects/dotnet-host-build/build.ps1 @@ -0,0 +1,81 @@ +# +# 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. +# + +param( + [string]$Configuration="Debug", + [string]$Architecture="x64", + [string[]]$Targets=@("Default"), + [switch]$NoPackage, + [switch]$Help) + +if($Help) +{ + Write-Host "Usage: .\build.ps1 [-Configuration ] [-NoPackage] [-Help] [-Targets ]" + Write-Host "" + Write-Host "Options:" + Write-Host " -Configuration Build the specified Configuration (Debug or Release, default: Debug)" + Write-Host " -Architecture Build the specified architecture (x64 or x86 (supported only on Windows), default: x64)" + Write-Host " -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 " -Help Display this help message" + exit 0 +} + +$env:CONFIGURATION = $Configuration; +$RepoRoot = "$PSScriptRoot\..\.." + +if($NoPackage) +{ + $env:DOTNET_BUILD_SKIP_PACKAGING=1 +} +else +{ + $env:DOTNET_BUILD_SKIP_PACKAGING=0 +} + +# Load Branch Info +cat "$RepoRoot\branchinfo.txt" | ForEach-Object { + if(!$_.StartsWith("#") -and ![String]::IsNullOrWhiteSpace($_)) { + $splat = $_.Split([char[]]@("="), 2) + Set-Content "env:\$($splat[0])" -Value $splat[1] + } +} + +# 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="$RepoRoot\.dotnet_stage0\Windows\$Architecture" +} + +if (!(Test-Path $env:DOTNET_INSTALL_DIR)) +{ + mkdir $env:DOTNET_INSTALL_DIR | Out-Null +} + +# Install a stage 0 +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\.." +dotnet restore --infer-runtimes +if($LASTEXITCODE -ne 0) { throw "Failed to restore" } +popd + +# Publish the builder +Write-Host "Compiling Build Scripts..." +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\bin\dotnet-host-build.exe" @Targets +if($LASTEXITCODE -ne 0) { throw "Build failed" } diff --git a/build_projects/dotnet-host-build/build.sh b/build_projects/dotnet-host-build/build.sh new file mode 100755 index 000000000..f214f6c27 --- /dev/null +++ b/build_projects/dotnet-host-build/build.sh @@ -0,0 +1,118 @@ +#!/usr/bin/env bash +# +# 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. +# + +set -e + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +OLDPATH="$PATH" + +REPOROOT="$DIR/../.." +source "$REPOROOT/scripts/common/_prettyprint.sh" + +while [[ $# > 0 ]]; do + lowerI="$(echo $1 | awk '{print tolower($0)}')" + case $lowerI in + -c|--configuration) + export CONFIGURATION=$2 + shift + ;; + --targets) + IFS=',' read -r -a targets <<< $2 + shift + ;; + --nopackage) + export DOTNET_BUILD_SKIP_PACKAGING=1 + ;; + --skip-prereqs) + # Allow CI to disable prereqs check since the CI has the pre-reqs but not ldconfig it seems + export DOTNET_INSTALL_SKIP_PREREQS=1 + ;; + --help) + echo "Usage: $0 [--configuration ] [--skip-prereqs] [--nopackage] [--docker ] [--help] [--targets ]" + echo "" + echo "Options:" + echo " --configuration Build the specified Configuration (Debug or Release, default: Debug)" + echo " --targets Comma separated build targets to run (Init, Compile, Publish, etc.; Default is a full build and publish)" + echo " --nopackage Skip packaging targets" + echo " --skip-prereqs Skip checks for pre-reqs in dotnet_install" + echo " --docker Build in Docker using the Dockerfile located in scripts/docker/IMAGENAME" + echo " --help Display this help message" + echo " The build targets to run (Init, Compile, Publish, etc.; Default is a full build and publish)" + exit 0 + ;; + *) + break + ;; + esac + + shift +done + +# Set up the environment to be used for building with clang. +if which "clang-3.5" > /dev/null 2>&1; then + export CC="$(which clang-3.5)" + export CXX="$(which clang++-3.5)" +elif which "clang-3.6" > /dev/null 2>&1; then + export CC="$(which clang-3.6)" + export CXX="$(which clang++-3.6)" +elif which clang > /dev/null 2>&1; then + export CC="$(which clang)" + export CXX="$(which clang++)" +else + error "Unable to find Clang Compiler" + error "Install clang-3.5 or clang3.6" + exit 1 +fi + +# Load Branch Info +while read line; do + if [[ $line != \#* ]]; then + IFS='=' read -ra splat <<< "$line" + export ${splat[0]}="${splat[1]}" + fi +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=$REPOROOT/.dotnet_stage0/$(uname) +[ -d "$DOTNET_INSTALL_DIR" ] || mkdir -p $DOTNET_INSTALL_DIR + +$REPOROOT/scripts/obtain/dotnet-install.sh --channel $CHANNEL --verbose + +# Put stage 0 on the PATH (for this shell only) +PATH="$DOTNET_INSTALL_DIR:$PATH" + +# Increases the file descriptors limit for this bash. It prevents an issue we were hitting during restore +FILE_DESCRIPTOR_LIMIT=$( ulimit -n ) +if [ $FILE_DESCRIPTOR_LIMIT -lt 1024 ] +then + echo "Increasing file description limit to 1024" + ulimit -n 1024 +fi + +# Restore the build scripts +echo "Restoring Build Script projects..." +( + cd "$DIR/.." + dotnet restore --infer-runtimes +) + +# Build the builder +echo "Compiling Build Scripts..." +dotnet publish "$DIR" -o "$DIR/bin" --framework netcoreapp1.0 + +export PATH="$OLDPATH" +# Run the builder +echo "Invoking Build Scripts..." +echo "Configuration: $CONFIGURATION" + +$DIR/bin/dotnet-host-build ${targets[@]} +exit $? diff --git a/build_projects/dotnet-host-build/dotnet-host-build.xproj b/build_projects/dotnet-host-build/dotnet-host-build.xproj new file mode 100644 index 000000000..fd8546624 --- /dev/null +++ b/build_projects/dotnet-host-build/dotnet-host-build.xproj @@ -0,0 +1,18 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + d7b9695d-23eb-4ea8-b8ab-707a0092e1d5 + Microsoft.DotNet.Cli.Build + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin + + + 2.0 + + + \ No newline at end of file diff --git a/build_projects/dotnet-host-build/project.json b/build_projects/dotnet-host-build/project.json new file mode 100644 index 000000000..ba495688d --- /dev/null +++ b/build_projects/dotnet-host-build/project.json @@ -0,0 +1,28 @@ +{ + "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" + ] + } + } +} diff --git a/build_projects/shared-build-targets-utils/PackageDependencies.cs b/build_projects/shared-build-targets-utils/PackageDependencies.cs new file mode 100644 index 000000000..e66e52592 --- /dev/null +++ b/build_projects/shared-build-targets-utils/PackageDependencies.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.DotNet.Cli.Build +{ + public class PackageDependencies + { + public static string[] DebianPackageBuildDependencies + { + get + { + return new string[] + { + "devscripts", + "debhelper", + "build-essential" + }; + + } + } + + public static string[] UbuntuCoreclrAndCoreFxDependencies + { + get + { + return new string[] + { + "libc6", + "libedit2", + "libffi6", + "libgcc1", + "libicu52", + "liblldb-3.6", + "libllvm3.6", + "liblttng-ust0", + "liblzma5", + "libncurses5", + "libpython2.7", + "libstdc++6", + "libtinfo5", + "libunwind8", + "liburcu1", + "libuuid1", + "zlib1g", + "libasn1-8-heimdal", + "libcomerr2", + "libcurl3", + "libgcrypt11", + "libgnutls26", + "libgpg-error0", + "libgssapi3-heimdal", + "libgssapi-krb5-2", + "libhcrypto4-heimdal", + "libheimbase1-heimdal", + "libheimntlm0-heimdal", + "libhx509-5-heimdal", + "libidn11", + "libk5crypto3", + "libkeyutils1", + "libkrb5-26-heimdal", + "libkrb5-3", + "libkrb5support0", + "libldap-2.4-2", + "libp11-kit0", + "libroken18-heimdal", + "librtmp0", + "libsasl2-2", + "libsqlite3-0", + "libssl1.0.0", + "libtasn1-6", + "libwind0-heimdal" + }; + } + } + + public static string[] CentosCoreclrAndCoreFxDependencies + { + get + { + return new string[] + { + "unzip", + "libunwind", + "gettext", + "libcurl-devel", + "openssl-devel", + "zlib", + "libicu-devel" + }; + } + } + + } +} diff --git a/scripts/dotnet-cli-build/Publishing/AzurePublisher.cs b/build_projects/shared-build-targets-utils/Publishing/AzurePublisher.cs similarity index 100% rename from scripts/dotnet-cli-build/Publishing/AzurePublisher.cs rename to build_projects/shared-build-targets-utils/Publishing/AzurePublisher.cs diff --git a/scripts/dotnet-cli-build/Publishing/DebRepoPublisher.cs b/build_projects/shared-build-targets-utils/Publishing/DebRepoPublisher.cs similarity index 100% rename from scripts/dotnet-cli-build/Publishing/DebRepoPublisher.cs rename to build_projects/shared-build-targets-utils/Publishing/DebRepoPublisher.cs diff --git a/scripts/dotnet-cli-build/Utils/AptDependencyUtility.cs b/build_projects/shared-build-targets-utils/Utils/AptDependencyUtility.cs similarity index 89% rename from scripts/dotnet-cli-build/Utils/AptDependencyUtility.cs rename to build_projects/shared-build-targets-utils/Utils/AptDependencyUtility.cs index 031aa6981..c8343c615 100644 --- a/scripts/dotnet-cli-build/Utils/AptDependencyUtility.cs +++ b/build_projects/shared-build-targets-utils/Utils/AptDependencyUtility.cs @@ -10,7 +10,7 @@ namespace Microsoft.DotNet.Cli.Build { public class AptDependencyUtility { - internal static bool PackageIsInstalled(string packageName) + public static bool PackageIsInstalled(string packageName) { var result = Command.Create("dpkg", "-s", packageName) .CaptureStdOut() diff --git a/build_projects/shared-build-targets-utils/Utils/BranchInfo.cs b/build_projects/shared-build-targets-utils/Utils/BranchInfo.cs new file mode 100644 index 000000000..7927b428a --- /dev/null +++ b/build_projects/shared-build-targets-utils/Utils/BranchInfo.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Text; +using Microsoft.DotNet.Cli.Build.Framework; +using Microsoft.WindowsAzure.Storage; +using Microsoft.WindowsAzure.Storage.Blob; + +using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; + +namespace Microsoft.DotNet.Cli.Build +{ + public class BranchInfo + { + private static readonly string s_branchInfoFileName = "branchinfo.txt"; + + private string _repoRoot; + private string _branchInfoFile; + + public IDictionary Entries { get; set; } + + public BranchInfo(string repoRoot) + { + _repoRoot = repoRoot; + _branchInfoFile = Path.Combine(_repoRoot, s_branchInfoFileName); + + Entries = ReadBranchInfo(_branchInfoFile); + } + + private IDictionary ReadBranchInfo(string path) + { + var lines = File.ReadAllLines(path); + var dict = new Dictionary(); + foreach (var line in lines) + { + if (!line.Trim().StartsWith("#") && !string.IsNullOrWhiteSpace(line)) + { + var splat = line.Split(new[] { '=' }, 2); + dict[splat[0]] = splat[1]; + } + } + return dict; + } + } +} diff --git a/scripts/dotnet-cli-build/Utils/BuildVersion.cs b/build_projects/shared-build-targets-utils/Utils/BuildVersion.cs similarity index 100% rename from scripts/dotnet-cli-build/Utils/BuildVersion.cs rename to build_projects/shared-build-targets-utils/Utils/BuildVersion.cs diff --git a/scripts/dotnet-cli-build/Utils/Crossgen.cs b/build_projects/shared-build-targets-utils/Utils/Crossgen.cs similarity index 100% rename from scripts/dotnet-cli-build/Utils/Crossgen.cs rename to build_projects/shared-build-targets-utils/Utils/Crossgen.cs diff --git a/scripts/dotnet-cli-build/Utils/Dirs.cs b/build_projects/shared-build-targets-utils/Utils/Dirs.cs similarity index 100% rename from scripts/dotnet-cli-build/Utils/Dirs.cs rename to build_projects/shared-build-targets-utils/Utils/Dirs.cs diff --git a/scripts/dotnet-cli-build/Utils/DotNetCli.cs b/build_projects/shared-build-targets-utils/Utils/DotNetCli.cs similarity index 78% rename from scripts/dotnet-cli-build/Utils/DotNetCli.cs rename to build_projects/shared-build-targets-utils/Utils/DotNetCli.cs index eb4966dbe..2d9570388 100644 --- a/scripts/dotnet-cli-build/Utils/DotNetCli.cs +++ b/build_projects/shared-build-targets-utils/Utils/DotNetCli.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using System.Linq; using System.Runtime.InteropServices; using Microsoft.DotNet.Cli.Build.Framework; @@ -38,6 +39,19 @@ namespace Microsoft.DotNet.Cli.Build public Command Test(params string[] args) => Exec("test", args); public Command Publish(params string[] args) => Exec("publish", args); + public string GetRuntimeId() + { + string info = Exec("", "--info").CaptureStdOut().Execute().StdOut; + string rid = Array.Find(info.Split(Environment.NewLine.ToCharArray()), (e) => e.Contains("RID:"))?.Replace("RID:", "").Trim(); + + if (string.IsNullOrEmpty(rid)) + { + throw new BuildFailureException("Could not find the Runtime ID from Stage0 --info or --version"); + } + + return rid; + } + private static string GetStage0Path() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) diff --git a/scripts/dotnet-cli-build/Utils/EnvVars.cs b/build_projects/shared-build-targets-utils/Utils/EnvVars.cs similarity index 100% rename from scripts/dotnet-cli-build/Utils/EnvVars.cs rename to build_projects/shared-build-targets-utils/Utils/EnvVars.cs diff --git a/scripts/dotnet-cli-build/Utils/FS.cs b/build_projects/shared-build-targets-utils/Utils/FS.cs similarity index 100% rename from scripts/dotnet-cli-build/Utils/FS.cs rename to build_projects/shared-build-targets-utils/Utils/FS.cs diff --git a/scripts/dotnet-cli-build/Utils/HostVersion.cs b/build_projects/shared-build-targets-utils/Utils/HostVersion.cs similarity index 100% rename from scripts/dotnet-cli-build/Utils/HostVersion.cs rename to build_projects/shared-build-targets-utils/Utils/HostVersion.cs diff --git a/scripts/dotnet-cli-build/Utils/JsonUtils.cs b/build_projects/shared-build-targets-utils/Utils/JsonUtils.cs similarity index 100% rename from scripts/dotnet-cli-build/Utils/JsonUtils.cs rename to build_projects/shared-build-targets-utils/Utils/JsonUtils.cs diff --git a/scripts/dotnet-cli-build/Utils/Monikers.cs b/build_projects/shared-build-targets-utils/Utils/Monikers.cs similarity index 100% rename from scripts/dotnet-cli-build/Utils/Monikers.cs rename to build_projects/shared-build-targets-utils/Utils/Monikers.cs diff --git a/scripts/dotnet-cli-build/Utils/PEUtils.cs b/build_projects/shared-build-targets-utils/Utils/PEUtils.cs similarity index 100% rename from scripts/dotnet-cli-build/Utils/PEUtils.cs rename to build_projects/shared-build-targets-utils/Utils/PEUtils.cs diff --git a/scripts/dotnet-cli-build/Utils/Utils.cs b/build_projects/shared-build-targets-utils/Utils/Utils.cs similarity index 96% rename from scripts/dotnet-cli-build/Utils/Utils.cs rename to build_projects/shared-build-targets-utils/Utils/Utils.cs index 283c4dd7b..8a483e76b 100644 --- a/scripts/dotnet-cli-build/Utils/Utils.cs +++ b/build_projects/shared-build-targets-utils/Utils/Utils.cs @@ -136,6 +136,11 @@ namespace Microsoft.DotNet.Cli.Build } } + public static string GetVersionFileContent(string commitHash, string version) + { + return $@"{commitHash}{Environment.NewLine}{version}{Environment.NewLine}"; + } + public static string GetSharedFrameworkVersionFileContent(BuildTargetContext c) { string SharedFrameworkNugetVersion = c.BuildContext.Get("SharedFrameworkNugetVersion"); diff --git a/scripts/dotnet-cli-build/Utils/Version.cs b/build_projects/shared-build-targets-utils/Utils/Version.cs similarity index 100% rename from scripts/dotnet-cli-build/Utils/Version.cs rename to build_projects/shared-build-targets-utils/Utils/Version.cs diff --git a/scripts/dotnet-cli-build/Utils/YumDependencyUtility.cs b/build_projects/shared-build-targets-utils/Utils/YumDependencyUtility.cs similarity index 88% rename from scripts/dotnet-cli-build/Utils/YumDependencyUtility.cs rename to build_projects/shared-build-targets-utils/Utils/YumDependencyUtility.cs index 09e2f04ef..480c6ce40 100644 --- a/scripts/dotnet-cli-build/Utils/YumDependencyUtility.cs +++ b/build_projects/shared-build-targets-utils/Utils/YumDependencyUtility.cs @@ -8,7 +8,7 @@ namespace Microsoft.DotNet.Cli.Build { public class YumDependencyUtility { - internal static bool PackageIsInstalled(string packageName) + public static bool PackageIsInstalled(string packageName) { var result = Command.Create("yum", "list", "installed", packageName) .CaptureStdOut() diff --git a/scripts/dotnet-cli-build/project.json b/build_projects/shared-build-targets-utils/project.json old mode 100755 new mode 100644 similarity index 87% rename from scripts/dotnet-cli-build/project.json rename to build_projects/shared-build-targets-utils/project.json index 7aca6173a..5d47f468c --- a/scripts/dotnet-cli-build/project.json +++ b/build_projects/shared-build-targets-utils/project.json @@ -1,9 +1,6 @@ { "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", @@ -15,7 +12,7 @@ "WindowsAzure.Storage": "6.2.2-preview" }, "frameworks": { - "netstandardapp1.5": { + "netstandard1.5": { "imports": [ "dnxcore50", "portable-net45+win8" diff --git a/build_projects/shared-build-targets-utils/shared-build-targets-utils.xproj b/build_projects/shared-build-targets-utils/shared-build-targets-utils.xproj new file mode 100644 index 000000000..920227a4c --- /dev/null +++ b/build_projects/shared-build-targets-utils/shared-build-targets-utils.xproj @@ -0,0 +1,19 @@ + + + + 14.0.25123 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + b768bd29-12bf-4c7c-b093-03193fe244d1 + shared-build-targets-utils + .\obj + .\bin\ + + + + 2.0 + + + \ No newline at end of file diff --git a/scripts/dockerbuild.sh b/scripts/dockerbuild.sh deleted file mode 100755 index 34351f8b0..000000000 --- a/scripts/dockerbuild.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -e - -SOURCE="${BASH_SOURCE[0]}" -while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located -done -DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - -BUILD_COMMAND=/opt/code/scripts/run-build.sh $DIR/dockerrun.sh --non-interactive "$@"