From d524732bbb5c2984ad35bb461ed94c87dcb70c12 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Tue, 2 Feb 2016 10:04:50 -0800 Subject: [PATCH] working on build scripts --- .gitignore | 3 + Microsoft.DotNet.Cli.sln | 73 ++++ branchinfo.txt | 7 + build.cmd | 2 +- build.sh | 23 +- .../AnsiColorExtensions.cs | 52 +++ .../AnsiConsole.cs | 143 +++++++ .../ArgumentEscaper.cs | 206 +++++++++ .../BuildContext.cs | 132 ++++++ .../BuildFailureException.cs | 42 ++ .../BuildHelpers.cs | 42 ++ .../BuildReporter.cs | 27 ++ .../BuildSetup.cs | 148 +++++++ .../BuildTarget.cs | 24 ++ .../BuildTargetContext.cs | 39 ++ .../BuildTargetResult.cs | 41 ++ .../Command.cs | 327 ++++++++++++++ .../CommandResult.cs | 34 ++ .../Constants.cs | 23 + .../DebugHelper.cs | 29 ++ ...Microsoft.DotNet.Cli.Build.Framework.xproj | 19 + .../Reporter.cs | 65 +++ .../StandardGoals.cs | 22 + .../TargetAttribute.cs | 24 ++ .../project.json | 12 + scripts/build/build.ps1 | 53 --- scripts/build/build.sh | 59 --- scripts/build/build_appdeps.ps1 | 19 - scripts/build/build_appdeps.sh | 39 -- scripts/build/build_info.sh | 16 - scripts/build/fix-mode-flags.sh | 19 - scripts/build/generate-version.ps1 | 65 --- scripts/build/generate-version.sh | 13 - scripts/build/place-binary.cmd | 24 -- scripts/build/place-binary.sh | 33 -- scripts/build/process-args.sh | 35 -- scripts/build/restore-packages.ps1 | 18 - scripts/build/restore-packages.sh | 27 -- scripts/ci_build.cmd | 4 +- scripts/ci_build.sh | 46 +- scripts/common/_clang.sh | 21 - scripts/common/_common.ps1 | 37 +- scripts/common/_common.sh | 18 +- scripts/common/_configuration.ps1 | 24 -- scripts/common/_configuration.sh | 25 -- scripts/common/_nuget.ps1 | 14 - scripts/common/_nuget.sh | 26 -- scripts/common/_rid.sh | 37 -- scripts/common/_utility.ps1 | 2 +- scripts/compile/compile-corehost.ps1 | 46 -- scripts/compile/compile-corehost.sh | 35 -- scripts/compile/compile-stage-1.ps1 | 14 - scripts/compile/compile-stage-1.sh | 26 -- scripts/compile/compile-stage-2.ps1 | 27 -- scripts/compile/compile-stage-2.sh | 29 -- scripts/compile/compile-stage.ps1 | 84 ---- scripts/compile/compile-stage.sh | 103 ----- scripts/compile/compile.ps1 | 28 -- scripts/compile/compile.sh | 26 -- scripts/configuration/buildProjects.csv | 1 - scripts/configuration/testPackageProjects.csv | 2 - scripts/configuration/testProjects.csv | 8 - scripts/configuration/testScripts.csv | 1 - scripts/crossgen/crossgen_roslyn.cmd | 83 ---- scripts/crossgen/crossgen_roslyn.sh | 87 ---- scripts/docker/dockerbuild.sh | 48 --- scripts/docker/dockerrun.sh | 26 -- scripts/docker/windows_dockerbuild.sh | 110 ----- ...d-test-prerequisites.sh => dockerbuild.sh} | 16 +- scripts/dockerrun.sh | 102 +++++ scripts/dotnet-cli-build/CompileTargets.cs | 401 ++++++++++++++++++ scripts/dotnet-cli-build/PrepareTargets.cs | 219 ++++++++++ scripts/dotnet-cli-build/Program.cs | 12 + scripts/dotnet-cli-build/TestTargets.cs | 241 +++++++++++ .../dotnet-cli-build/Utils/BuildVersion.cs | 47 ++ scripts/dotnet-cli-build/Utils/Dirs.cs | 38 ++ scripts/dotnet-cli-build/Utils/DotNetCli.cs | 51 +++ scripts/dotnet-cli-build/Utils/FS.cs | 114 +++++ scripts/dotnet-cli-build/Utils/Utils.cs | 38 ++ .../dotnet-cli-build/dotnet-cli-build.xproj | 18 + scripts/dotnet-cli-build/project.json | 18 + scripts/global.json | 3 + scripts/obtain/install-tools.ps1 | 16 - scripts/obtain/install-tools.sh | 24 -- scripts/package/package-dnvm.sh | 2 +- scripts/package/package.ps1 | 3 +- scripts/package/package.sh | 5 +- scripts/run-build.ps1 | 55 +++ scripts/run-build.sh | 80 ++++ scripts/test/build-tests.ps1 | 17 - scripts/test/build-tests.sh | 27 -- scripts/test/check-prereqs.ps1 | 11 - scripts/test/check-prereqs.sh | 22 - scripts/test/package-command-test.ps1 | 34 -- scripts/test/package-command-test.sh | 48 --- scripts/test/restore-tests.ps1 | 11 - scripts/test/run-tests.ps1 | 67 --- scripts/test/run-tests.sh | 67 --- .../test/setup/build-test-prerequisites.ps1 | 17 - .../test/setup/restore-test-prerequisites.ps1 | 14 - .../test/setup/restore-test-prerequisites.sh | 24 -- scripts/test/setup/setup-tests.ps1 | 12 - scripts/test/setup/setup-tests.sh | 23 - scripts/test/test.ps1 | 18 - scripts/test/test.sh | 30 -- scripts/test/validate-dependencies.ps1 | 21 - scripts/test/validate-dependencies.sh | 30 -- .../StreamForwarder.cs | 2 +- .../restore-tests.sh => src/corehost/build.sh | 16 +- src/dotnet/commands/dotnet-restore/NuGet3.cs | 2 +- test/EndToEnd/EndToEndTest.cs | 8 +- 111 files changed, 3052 insertions(+), 1989 deletions(-) create mode 100644 branchinfo.txt create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/AnsiColorExtensions.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/AnsiConsole.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/ArgumentEscaper.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/BuildContext.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/BuildFailureException.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/BuildHelpers.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/BuildReporter.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTarget.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTargetContext.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTargetResult.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/Command.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/CommandResult.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/Constants.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/DebugHelper.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/Microsoft.DotNet.Cli.Build.Framework.xproj create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/Reporter.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/StandardGoals.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/TargetAttribute.cs create mode 100644 scripts/Microsoft.DotNet.Cli.Build.Framework/project.json delete mode 100644 scripts/build/build.ps1 delete mode 100755 scripts/build/build.sh delete mode 100644 scripts/build/build_appdeps.ps1 delete mode 100755 scripts/build/build_appdeps.sh delete mode 100755 scripts/build/build_info.sh delete mode 100755 scripts/build/fix-mode-flags.sh delete mode 100644 scripts/build/generate-version.ps1 delete mode 100755 scripts/build/generate-version.sh delete mode 100644 scripts/build/place-binary.cmd delete mode 100755 scripts/build/place-binary.sh delete mode 100755 scripts/build/process-args.sh delete mode 100644 scripts/build/restore-packages.ps1 delete mode 100755 scripts/build/restore-packages.sh delete mode 100644 scripts/common/_clang.sh delete mode 100644 scripts/common/_configuration.ps1 delete mode 100644 scripts/common/_configuration.sh delete mode 100644 scripts/common/_nuget.ps1 delete mode 100644 scripts/common/_nuget.sh delete mode 100644 scripts/common/_rid.sh delete mode 100644 scripts/compile/compile-corehost.ps1 delete mode 100755 scripts/compile/compile-corehost.sh delete mode 100644 scripts/compile/compile-stage-1.ps1 delete mode 100755 scripts/compile/compile-stage-1.sh delete mode 100644 scripts/compile/compile-stage-2.ps1 delete mode 100755 scripts/compile/compile-stage-2.sh delete mode 100644 scripts/compile/compile-stage.ps1 delete mode 100755 scripts/compile/compile-stage.sh delete mode 100644 scripts/compile/compile.ps1 delete mode 100755 scripts/compile/compile.sh delete mode 100644 scripts/configuration/buildProjects.csv delete mode 100644 scripts/configuration/testPackageProjects.csv delete mode 100644 scripts/configuration/testProjects.csv delete mode 100644 scripts/configuration/testScripts.csv delete mode 100644 scripts/crossgen/crossgen_roslyn.cmd delete mode 100755 scripts/crossgen/crossgen_roslyn.sh delete mode 100755 scripts/docker/dockerbuild.sh delete mode 100755 scripts/docker/dockerrun.sh delete mode 100755 scripts/docker/windows_dockerbuild.sh rename scripts/{test/setup/build-test-prerequisites.sh => dockerbuild.sh} (52%) create mode 100755 scripts/dockerrun.sh create mode 100644 scripts/dotnet-cli-build/CompileTargets.cs create mode 100644 scripts/dotnet-cli-build/PrepareTargets.cs create mode 100755 scripts/dotnet-cli-build/Program.cs create mode 100644 scripts/dotnet-cli-build/TestTargets.cs create mode 100644 scripts/dotnet-cli-build/Utils/BuildVersion.cs create mode 100644 scripts/dotnet-cli-build/Utils/Dirs.cs create mode 100644 scripts/dotnet-cli-build/Utils/DotNetCli.cs create mode 100644 scripts/dotnet-cli-build/Utils/FS.cs create mode 100644 scripts/dotnet-cli-build/Utils/Utils.cs create mode 100644 scripts/dotnet-cli-build/dotnet-cli-build.xproj create mode 100755 scripts/dotnet-cli-build/project.json create mode 100644 scripts/global.json delete mode 100644 scripts/obtain/install-tools.ps1 delete mode 100755 scripts/obtain/install-tools.sh create mode 100644 scripts/run-build.ps1 create mode 100755 scripts/run-build.sh delete mode 100644 scripts/test/build-tests.ps1 delete mode 100755 scripts/test/build-tests.sh delete mode 100644 scripts/test/check-prereqs.ps1 delete mode 100755 scripts/test/check-prereqs.sh delete mode 100644 scripts/test/package-command-test.ps1 delete mode 100755 scripts/test/package-command-test.sh delete mode 100644 scripts/test/restore-tests.ps1 delete mode 100644 scripts/test/run-tests.ps1 delete mode 100755 scripts/test/run-tests.sh delete mode 100644 scripts/test/setup/build-test-prerequisites.ps1 delete mode 100644 scripts/test/setup/restore-test-prerequisites.ps1 delete mode 100755 scripts/test/setup/restore-test-prerequisites.sh delete mode 100644 scripts/test/setup/setup-tests.ps1 delete mode 100755 scripts/test/setup/setup-tests.sh delete mode 100644 scripts/test/test.ps1 delete mode 100755 scripts/test/test.sh delete mode 100644 scripts/test/validate-dependencies.ps1 delete mode 100755 scripts/test/validate-dependencies.sh rename scripts/test/restore-tests.sh => src/corehost/build.sh (56%) diff --git a/.gitignore b/.gitignore index b620a468b..3f156e9b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ ### Repo-specific things ### +# Test results +*-testResults.xml + # NuGet keeps dropping Library/ diff --git a/Microsoft.DotNet.Cli.sln b/Microsoft.DotNet.Cli.sln index 41f709b3b..ce13bb1b6 100644 --- a/Microsoft.DotNet.Cli.sln +++ b/Microsoft.DotNet.Cli.sln @@ -50,6 +50,11 @@ EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "dotnet-projectmodel-server.Tests", "test\dotnet-projectmodel-server.Tests\dotnet-projectmodel-server.Tests.xproj", "{11C77123-E4DA-499F-8900-80C88C2C69F2}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Files", "src\Microsoft.DotNet.Files\Microsoft.DotNet.Files.xproj", "{D521DD9F-0614-4929-93B4-D8FA5682C174}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{88278B81-7649-45DC-8A6A-D3A645C5AFC3}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "dotnet-cli-build", "scripts\dotnet-cli-build\dotnet-cli-build.xproj", "{D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Cli.Build.Framework", "scripts\Microsoft.DotNet.Cli.Build.Framework\Microsoft.DotNet.Cli.Build.Framework.xproj", "{49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "dotnet-compile.UnitTests", "test\dotnet-compile.UnitTests\dotnet-compile.UnitTests.xproj", "{920B71D8-62DA-4F5E-8A26-926C113F1D97}" EndProject @@ -443,6 +448,70 @@ Global {947DD232-8D9B-4B78-9C6A-94F807D22222}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU {947DD232-8D9B-4B78-9C6A-94F807D22222}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU {947DD232-8D9B-4B78-9C6A-94F807D22222}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.Debug|x64.ActiveCfg = Debug|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.Debug|x64.Build.0 = Debug|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.Release|Any CPU.Build.0 = Release|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.Release|x64.ActiveCfg = Release|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.Release|x64.Build.0 = Release|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.Debug|x64.ActiveCfg = Debug|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.Debug|x64.Build.0 = Debug|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.Release|Any CPU.Build.0 = Release|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.Release|x64.ActiveCfg = Release|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.Release|x64.Build.0 = Release|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.Debug|x64.ActiveCfg = Debug|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.Debug|x64.Build.0 = Debug|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.Release|Any CPU.Build.0 = Release|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.Release|x64.ActiveCfg = Release|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.Release|x64.Build.0 = Release|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.Debug|x64.ActiveCfg = Debug|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.Debug|x64.Build.0 = Debug|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.Release|Any CPU.Build.0 = Release|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.Release|x64.ActiveCfg = Release|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.Release|x64.Build.0 = Release|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.RelWithDebInfo|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -472,5 +541,9 @@ Global {0138CB8F-4AA9-4029-A21E-C07C30F425BA} = {713CBFBB-5392-438D-B766-A9A585EF1BB8} {947DD232-8D9B-4B78-9C6A-94F807D2DD58} = {713CBFBB-5392-438D-B766-A9A585EF1BB8} {947DD232-8D9B-4B78-9C6A-94F807D22222} = {713CBFBB-5392-438D-B766-A9A585EF1BB8} + {09C52F96-EFDD-4448-95EC-6D362DD60BAA} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7} + {44E7D1AC-DCF1-4A18-9C22-F09E6BB302B5} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7} + {D7B9695D-23EB-4EA8-B8AB-707A0092E1D5} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3} + {49BEB486-AB5A-4416-91EA-8CD34ABB0C9D} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3} EndGlobalSection EndGlobal diff --git a/branchinfo.txt b/branchinfo.txt new file mode 100644 index 000000000..7ac005498 --- /dev/null +++ b/branchinfo.txt @@ -0,0 +1,7 @@ +# This is a file containing environment variables specific to this branch +# Any line that is not blank and does not start with '#' is interpreted as a variable to set +# Each line is expected to be in the format "[Name]=[Value]". +MAJOR_VERSION=1 +MINOR_VERSION=0 +PATCH_VERSION=0 +RELEASE_SUFFIX=beta diff --git a/build.cmd b/build.cmd index 9b72ee74b..615538658 100644 --- a/build.cmd +++ b/build.cmd @@ -6,4 +6,4 @@ REM Licensed under the MIT license. See LICENSE file in the project root for ful REM Crossgen Workaround set ComPlus_ReadyToRun=0 -powershell -NoProfile -NoLogo -Command "%~dp0scripts\build\build.ps1 %*; exit $LastExitCode;" +powershell -NoProfile -NoLogo -Command "%~dp0scripts\run-build.ps1 %*; exit $LastExitCode;" diff --git a/build.sh b/build.sh index 36895885b..fb885b57b 100755 --- a/build.sh +++ b/build.sh @@ -16,26 +16,9 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" -source "$DIR/scripts/common/_common.sh" -source "$REPOROOT/scripts/build/process-args.sh" - -# splitting build from package is required to work around dotnet/coreclr#2215 -# once that is fixed, we should remove the NOPACKAGE flag and do the full build either in -# or out of docker. +# Check if we need to build in docker if [ ! -z "$BUILD_IN_DOCKER" ]; then - export BUILD_COMMAND=". /opt/code/scripts/build/process-args.sh $@ ; . /opt/code/scripts/build/build.sh" - $REPOROOT/scripts/docker/dockerbuild.sh + $DIR/scripts/dockerbuild.sh "$@" else - $REPOROOT/scripts/build/build.sh -fi - -if [ ! -z "$NOPACKAGE" ]; then - header "Skipping packaging" -else - if [ ! -z "$PACKAGE_IN_DOCKER" ]; then - export BUILD_COMMAND="/opt/code/scripts/package/package.sh" - $REPOROOT/scripts/docker/dockerbuild.sh - else - $REPOROOT/scripts/package/package.sh - fi + $DIR/scripts/run-build.sh "$@" fi diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/AnsiColorExtensions.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/AnsiColorExtensions.cs new file mode 100644 index 000000000..874fc7608 --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/AnsiColorExtensions.cs @@ -0,0 +1,52 @@ +// 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. + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public static class AnsiColorExtensions + { + public static string Black(this string text) + { + return "\x1B[30m" + text + "\x1B[39m"; + } + + public static string Red(this string text) + { + return "\x1B[31m" + text + "\x1B[39m"; + } + public static string Green(this string text) + { + return "\x1B[32m" + text + "\x1B[39m"; + } + + public static string Yellow(this string text) + { + return "\x1B[33m" + text + "\x1B[39m"; + } + + public static string Blue(this string text) + { + return "\x1B[34m" + text + "\x1B[39m"; + } + + public static string Magenta(this string text) + { + return "\x1B[35m" + text + "\x1B[39m"; + } + + public static string Cyan(this string text) + { + return "\x1B[36m" + text + "\x1B[39m"; + } + + public static string White(this string text) + { + return "\x1B[37m" + text + "\x1B[39m"; + } + + public static string Bold(this string text) + { + return "\x1B[1m" + text + "\x1B[22m"; + } + } +} diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/AnsiConsole.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/AnsiConsole.cs new file mode 100644 index 000000000..8458eb629 --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/AnsiConsole.cs @@ -0,0 +1,143 @@ +// 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. + +using System; +using System.IO; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public class AnsiConsole + { + private AnsiConsole(TextWriter writer, bool useConsoleColor) + { + Writer = writer; + + _useConsoleColor = useConsoleColor; + if (_useConsoleColor) + { + OriginalForegroundColor = Console.ForegroundColor; + } + } + + private int _boldRecursion; + private bool _useConsoleColor; + + public static AnsiConsole GetOutput(bool useConsoleColor) + { + return new AnsiConsole(Console.Out, useConsoleColor); + } + + public static AnsiConsole GetError(bool useConsoleColor) + { + return new AnsiConsole(Console.Error, useConsoleColor); + } + + public TextWriter Writer { get; } + + public ConsoleColor OriginalForegroundColor { get; } + + private void SetColor(ConsoleColor color) + { + Console.ForegroundColor = (ConsoleColor)(((int)Console.ForegroundColor & 0x08) | ((int)color & 0x07)); + } + + private void SetBold(bool bold) + { + _boldRecursion += bold ? 1 : -1; + if (_boldRecursion > 1 || (_boldRecursion == 1 && !bold)) + { + return; + } + + Console.ForegroundColor = (ConsoleColor)((int)Console.ForegroundColor ^ 0x08); + } + + public void WriteLine(string message) + { + if (!_useConsoleColor) + { + Writer.WriteLine(message); + return; + } + + var escapeScan = 0; + for (;;) + { + var escapeIndex = message.IndexOf("\x1b[", escapeScan); + if (escapeIndex == -1) + { + var text = message.Substring(escapeScan); + Writer.Write(text); + break; + } + else + { + var startIndex = escapeIndex + 2; + var endIndex = startIndex; + while (endIndex != message.Length && + message[endIndex] >= 0x20 && + message[endIndex] <= 0x3f) + { + endIndex += 1; + } + + var text = message.Substring(escapeScan, escapeIndex - escapeScan); + Writer.Write(text); + if (endIndex == message.Length) + { + break; + } + + switch (message[endIndex]) + { + case 'm': + int value; + if (int.TryParse(message.Substring(startIndex, endIndex - startIndex), out value)) + { + switch (value) + { + case 1: + SetBold(true); + break; + case 22: + SetBold(false); + break; + case 30: + SetColor(ConsoleColor.Black); + break; + case 31: + SetColor(ConsoleColor.Red); + break; + case 32: + SetColor(ConsoleColor.Green); + break; + case 33: + SetColor(ConsoleColor.Yellow); + break; + case 34: + SetColor(ConsoleColor.Blue); + break; + case 35: + SetColor(ConsoleColor.Magenta); + break; + case 36: + SetColor(ConsoleColor.Cyan); + break; + case 37: + SetColor(ConsoleColor.Gray); + break; + case 39: + SetColor(OriginalForegroundColor); + break; + } + } + break; + } + + escapeScan = endIndex + 1; + } + } + Writer.WriteLine(); + } + } +} diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/ArgumentEscaper.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/ArgumentEscaper.cs new file mode 100644 index 000000000..7b1958057 --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/ArgumentEscaper.cs @@ -0,0 +1,206 @@ +// 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. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public static class ArgumentEscaper + { + /// + /// Undo the processing which took place to create string[] args in Main, + /// so that the next process will receive the same string[] args + /// + /// See here for more info: + /// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx + /// + /// + /// + public static string EscapeAndConcatenateArgArrayForProcessStart(IEnumerable args) + { + return string.Join(" ", EscapeArgArray(args)); + } + + /// + /// Undo the processing which took place to create string[] args in Main, + /// so that the next process will receive the same string[] args + /// + /// See here for more info: + /// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx + /// + /// + /// + public static string EscapeAndConcatenateArgArrayForCmdProcessStart(IEnumerable args) + { + return string.Join(" ", EscapeArgArrayForCmd(args)); + } + + /// + /// Undo the processing which took place to create string[] args in Main, + /// so that the next process will receive the same string[] args + /// + /// See here for more info: + /// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx + /// + /// + /// + private static IEnumerable EscapeArgArray(IEnumerable args) + { + var escapedArgs = new List(); + + foreach (var arg in args) + { + escapedArgs.Add(EscapeArg(arg)); + } + + return escapedArgs; + } + + /// + /// This prefixes every character with the '^' character to force cmd to + /// interpret the argument string literally. An alternative option would + /// be to do this only for cmd metacharacters. + /// + /// See here for more info: + /// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx + /// + /// + /// + private static IEnumerable EscapeArgArrayForCmd(IEnumerable arguments) + { + var escapedArgs = new List(); + + foreach (var arg in arguments) + { + escapedArgs.Add(EscapeArgForCmd(arg)); + } + + return escapedArgs; + } + + private static string EscapeArg(string arg) + { + var sb = new StringBuilder(); + + var quoted = ShouldSurroundWithQuotes(arg); + if (quoted) sb.Append("\""); + + for (int i = 0; i < arg.Length; ++i) + { + var backslashCount = 0; + + // Consume All Backslashes + while (i < arg.Length && arg[i] == '\\') + { + backslashCount++; + i++; + } + + // Escape any backslashes at the end of the arg + // This ensures the outside quote is interpreted as + // an argument delimiter + if (i == arg.Length) + { + sb.Append('\\', 2 * backslashCount); + } + + // Escape any preceding backslashes and the quote + else if (arg[i] == '"') + { + sb.Append('\\', (2 * backslashCount) + 1); + sb.Append('"'); + } + + // Output any consumed backslashes and the character + else + { + sb.Append('\\', backslashCount); + sb.Append(arg[i]); + } + } + + if (quoted) sb.Append("\""); + + return sb.ToString(); + } + + /// + /// Prepare as single argument to + /// roundtrip properly through cmd. + /// + /// This prefixes every character with the '^' character to force cmd to + /// interpret the argument string literally. An alternative option would + /// be to do this only for cmd metacharacters. + /// + /// See here for more info: + /// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx + /// + /// + /// + private static string EscapeArgForCmd(string argument) + { + var sb = new StringBuilder(); + + var quoted = ShouldSurroundWithQuotes(argument); + + if (quoted) sb.Append("^\""); + + foreach (var character in argument) + { + + if (character == '"') + { + + sb.Append('^'); + sb.Append('"'); + sb.Append('^'); + sb.Append(character); + } + else + { + sb.Append("^"); + sb.Append(character); + } + } + + if (quoted) sb.Append("^\""); + + return sb.ToString(); + } + + /// + /// Prepare as single argument to + /// roundtrip properly through cmd. + /// + /// This prefixes every character with the '^' character to force cmd to + /// interpret the argument string literally. An alternative option would + /// be to do this only for cmd metacharacters. + /// + /// See here for more info: + /// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx + /// + /// + /// + internal static bool ShouldSurroundWithQuotes(string argument) + { + // Don't quote already quoted strings + if (argument.StartsWith("\"", StringComparison.Ordinal) && + argument.EndsWith("\"", StringComparison.Ordinal)) + { + return false; + } + + // Only quote if whitespace exists in the string + if (argument.Contains(" ") || argument.Contains("\t") || argument.Contains("\n")) + { + return true; + } + + return true; + } + } +} diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildContext.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildContext.cs new file mode 100644 index 000000000..312fdd6ce --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildContext.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public class BuildContext + { + private IDictionary _completedTargets = new Dictionary(StringComparer.OrdinalIgnoreCase); + + public static readonly string DefaultTarget = "Default"; + + private int _maxTargetLen; + private Stack _targetStack = new Stack(); + + public IDictionary Targets { get; } + + public IDictionary Properties = new Dictionary(); + + public string BuildDirectory { get; } + + public object this[string name] + { + get { return Properties.ContainsKey(name) ? Properties[name] : null; } + set { Properties[name] = value; } + } + + public BuildContext(IDictionary targets, string buildDirectory) + { + Targets = targets; + BuildDirectory = buildDirectory; + _maxTargetLen = targets.Values.Select(t => t.Name.Length).Max(); + } + + public BuildTargetResult RunTarget(string name) => RunTarget(name, force: false); + + public BuildTargetResult RunTarget(string name, bool force) + { + BuildTarget target; + if (!Targets.TryGetValue(name, out target)) + { + Reporter.Verbose.WriteLine($"Skipping undefined target: {name}"); + } + + // Check if it's been completed + BuildTargetResult result; + if (!force && _completedTargets.TryGetValue(name, out result)) + { + Reporter.Verbose.WriteLine($"Skipping completed target: {target.Name}"); + return result; + } + + + // It hasn't, or we're forcing, so run it + result = ExecTarget(target); + _completedTargets[target.Name] = result; + return result; + } + + public void Verbose(string message) + { + Reporter.Output.WriteLine("trace".White() + $": {message}"); + } + + public void Info(string message) + { + Reporter.Output.WriteLine("info ".Green() + $": {message}"); + } + + public void Warn(string message) + { + Reporter.Output.WriteLine("warn ".Yellow() + $": {message}"); + } + + public void Error(string message) + { + Reporter.Error.WriteLine("error".Red().Bold() + $": {message}"); + } + + private BuildTargetResult ExecTarget(BuildTarget target) + { + var sectionName = $"{target.Name.PadRight(_maxTargetLen + 2).Yellow()} ({target.Source.White()})"; + BuildReporter.BeginSection("TARGET", sectionName); + + BuildTargetResult result; + + // Run the dependencies + var dependencyResults = new Dictionary(); + var failedDependencyResult = RunDependencies(target, dependencyResults); + if (failedDependencyResult != null) + { + result = failedDependencyResult; + } + else if (target.Body != null) + { + try + { + result = target.Body(new BuildTargetContext(this, target, dependencyResults)); + } + catch (Exception ex) + { + result = new BuildTargetResult(target, success: false, exception: ex); + } + } + else + { + result = new BuildTargetResult(target, success: true); + } + BuildReporter.EndSection("TARGET", sectionName, result.Success); + + return result; + } + + private BuildTargetResult RunDependencies(BuildTarget target, Dictionary dependencyResults) + { + BuildTargetResult result = null; + foreach (var dependency in target.Dependencies) + { + result = RunTarget(dependency); + dependencyResults[dependency] = result; + + if (!result.Success) + { + return result; + } + } + + return null; + } + } +} diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildFailureException.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildFailureException.cs new file mode 100644 index 000000000..665c0243a --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildFailureException.cs @@ -0,0 +1,42 @@ +using System; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public class BuildFailureException : Exception + { + public BuildTarget Target { get; } + + public BuildFailureException() + { + } + + public BuildFailureException(BuildTarget target) : base($"The '{target.Name}' target failed") + { + Target = target; + } + + public BuildFailureException(BuildTarget target, Exception innerException) : base($"The '{target.Name}' target failed", innerException) + { + Target = target; + } + + public BuildFailureException(string message) : base(message) + { + } + + public BuildFailureException(string message, BuildTarget target) : base(message) + { + Target = target; + } + + public BuildFailureException(string message, Exception innerException) : base(message, innerException) + { + } + + public BuildFailureException(string message, Exception innerException, BuildTarget target) : base(message, innerException) + { + Target = target; + } + + } +} \ No newline at end of file diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildHelpers.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildHelpers.cs new file mode 100644 index 000000000..cb7aa8ede --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildHelpers.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public static class BuildHelpers + { + public static int ExecInSilent(string workingDirectory, string command, params string[] args) => ExecInSilent(workingDirectory, command, (IEnumerable)args); + public static int ExecInSilent(string workingDirectory, string command, IEnumerable args) => ExecCore(command, args, workingDirectory, silent: true); + + public static int ExecIn(string workingDirectory, string command, params string[] args) => ExecIn(workingDirectory, command, (IEnumerable)args); + public static int ExecIn(string workingDirectory, string command, IEnumerable args) => ExecCore(command, args, workingDirectory, silent: false); + + public static int ExecSilent(string command, params string[] args) => ExecSilent(command, (IEnumerable)args); + public static int ExecSilent(string command, IEnumerable args) => ExecCore(command, args, workingDirectory: null, silent: true); + + public static int Exec(string command, params string[] args) => Exec(command, (IEnumerable)args); + public static int Exec(string command, IEnumerable args) => ExecCore(command, args, workingDirectory: null, silent: false); + + public static Command Cmd(string command, params string[] args) => Cmd(command, (IEnumerable)args); + public static Command Cmd(string command, IEnumerable args) + { + return Command.Create(command, args); + } + + internal static int ExecCore(string command, IEnumerable args, string workingDirectory, bool silent) + { + var cmd = Cmd(command, args); + if(!string.IsNullOrEmpty(workingDirectory)) + { + cmd.WorkingDirectory(workingDirectory); + } + if(silent) + { + cmd.CaptureStdErr().CaptureStdOut(); + } + var result = cmd.Execute(); + + result.EnsureSuccessful(); + return result.ExitCode; + } + } +} diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildReporter.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildReporter.cs new file mode 100644 index 000000000..bbefb7cf6 --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildReporter.cs @@ -0,0 +1,27 @@ +using System; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public static class BuildReporter + { + public static void BeginSection(string type, string name) + { + Reporter.Output.WriteLine($"[{type.PadRight(10)} >]".Green() + $" [....] [{DateTime.Now:O}]".Blue() + $" {name}"); + } + + public static void EndSection(string type, string name, bool success) + { + var header = $"[{type.PadRight(10)} <]"; + if(success) + { + header = header.Green(); + } + else + { + header = header.Red(); + } + var successString = success ? " OK " : "FAIL"; + Reporter.Output.WriteLine(header + $" [{successString}] [{DateTime.Now:O}]".Blue() + $" {name}"); + } + } +} diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs new file mode 100644 index 000000000..34eb86afa --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildSetup.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public class BuildSetup + { + private Dictionary _targets = new Dictionary(); + + public IList _overrides = new List(); + + public string ProductName { get; } + + public BuildSetup(string productName) + { + ProductName = productName; + } + + public static BuildSetup Create(string productName) + { + return new BuildSetup(productName); + } + + public BuildSetup UseTargets(IEnumerable targets) + { + foreach (var target in targets) + { + BuildTarget previousTarget; + if (_targets.TryGetValue(target.Name, out previousTarget)) + { + _overrides.Add(new TargetOverride(target.Name, previousTarget.Source, target.Source)); + } + _targets[target.Name] = target; + } + return this; + } + + public BuildSetup UseAllTargetsFromAssembly() + { + var asm = typeof(T).GetTypeInfo().Assembly; + return UseTargets(asm.GetExportedTypes().SelectMany(t => CollectTargets(t))); + } + + public BuildSetup UseTargetsFrom() + { + return UseTargets(CollectTargets(typeof(T))); + } + + public int Run(string[] args) + { + DebugHelper.HandleDebugSwitch(ref args); + + var targets = new[] { BuildContext.DefaultTarget }; + if(args.Length > 0) + { + targets = args; + } + + Reporter.Output.WriteBanner($"Building {ProductName}"); + + if (_overrides.Any()) + { + foreach (var targetOverride in _overrides) + { + Reporter.Verbose.WriteLine($"Target {targetOverride.Name} from {targetOverride.OriginalSource} was overridden in {targetOverride.OverrideSource}".Black()); + } + } + + var context = new BuildContext(_targets, Directory.GetCurrentDirectory()); + BuildTargetResult result = null; + try + { + foreach (var target in targets) + { + result = context.RunTarget(target); + if(!result.Success) + { + break; + } + } + } + catch (Exception ex) + { + Reporter.Error.WriteLine(ex.ToString().Red()); + return 1; + } + + if(result != null && !result.Success) + { + Reporter.Error.WriteLine($"Build failed: {result.ErrorMessage}".Red()); + return 1; + } + else + { + Reporter.Output.WriteLine("Build succeeded".Green()); + return 0; + } + } + + private static IEnumerable CollectTargets(Type typ) + { + return from m in typ.GetMethods() + let attr = m.GetCustomAttribute() + where attr != null + select CreateTarget(m, attr); + } + + private static BuildTarget CreateTarget(MethodInfo m, TargetAttribute attr) + { + return new BuildTarget( + attr.Name ?? m.Name, + $"{m.DeclaringType.FullName}.{m.Name}", + attr.Dependencies, + (Func)m.CreateDelegate(typeof(Func))); + } + + private string GenerateSourceString(string file, int? line, string member) + { + if (!string.IsNullOrEmpty(file) && line != null) + { + return $"{file}:{line}"; + } + else if (!string.IsNullOrEmpty(member)) + { + return member; + } + return string.Empty; + } + + public class TargetOverride + { + public string Name { get; } + public string OriginalSource { get; } + public string OverrideSource { get; } + + public TargetOverride(string name, string originalSource, string overrideSource) + { + Name = name; + OriginalSource = originalSource; + OverrideSource = overrideSource; + } + } + } +} diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTarget.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTarget.cs new file mode 100644 index 000000000..303e0ae66 --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTarget.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public class BuildTarget + { + public string Name { get; } + public string Source { get; } + public IEnumerable Dependencies { get; } + public Func Body { get; } + + public BuildTarget(string name, string source) : this(name, source, Enumerable.Empty(), null) { } + public BuildTarget(string name, string source, IEnumerable dependencies) : this(name, source, dependencies, null) { } + public BuildTarget(string name, string source, IEnumerable dependencies, Func body) + { + Name = name; + Source = source; + Dependencies = dependencies; + Body = body; + } + } +} \ No newline at end of file diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTargetContext.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTargetContext.cs new file mode 100644 index 000000000..376234dc2 --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTargetContext.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public class BuildTargetContext + { + private IDictionary _dependencyResults; + + public BuildContext BuildContext { get; } + public BuildTarget Target { get; } + + public BuildTargetContext(BuildContext buildContext, BuildTarget target, IDictionary dependencyResults) + { + BuildContext = buildContext; + Target = target; + _dependencyResults = dependencyResults; + } + + public BuildTargetResult Success() + { + return new BuildTargetResult(Target, success: true); + } + + public BuildTargetResult Failed() => Failed(errorMessage: string.Empty); + + public BuildTargetResult Failed(string errorMessage) + { + return new BuildTargetResult(Target, success: false, errorMessage: errorMessage); + } + + public void Info(string message) => BuildContext.Info(message); + public void Warn(string message) => BuildContext.Warn(message); + public void Error(string message) => BuildContext.Error(message); + public void Verbose(string message) => BuildContext.Verbose(message); + } +} diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTargetResult.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTargetResult.cs new file mode 100644 index 000000000..cadf74a03 --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/BuildTargetResult.cs @@ -0,0 +1,41 @@ +using System; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public class BuildTargetResult + { + public BuildTarget Target { get; } + public bool Success { get; } + public string ErrorMessage { get; } + public Exception Exception { get; } + + public BuildTargetResult(BuildTarget target, bool success) : this(target, success, errorMessage: string.Empty) { } + + public BuildTargetResult(BuildTarget target, bool success, Exception exception) : this(target, success, exception.ToString()) + { + Exception = exception; + } + + public BuildTargetResult(BuildTarget target, bool success, string errorMessage) + { + Target = target; + Success = success; + ErrorMessage = errorMessage; + } + + public void EnsureSuccessful() + { + if(!Success) + { + if(string.IsNullOrEmpty(ErrorMessage)) + { + throw new BuildFailureException(Target, Exception); + } + else + { + throw new BuildFailureException(ErrorMessage, Exception, Target); + } + } + } + } +} \ No newline at end of file diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/Command.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/Command.cs new file mode 100644 index 000000000..625b3f776 --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/Command.cs @@ -0,0 +1,327 @@ +// 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. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public class Command + { + private Process _process; + + private StringWriter _stdOutCapture; + private StringWriter _stdErrCapture; + + private Action _stdOutForward; + private Action _stdErrForward; + + private Action _stdOutHandler; + private Action _stdErrHandler; + + private bool _running = false; + + private Command(string executable, string args) + { + // Set the things we need + var psi = new ProcessStartInfo() + { + FileName = executable, + Arguments = args + }; + + _process = new Process() + { + StartInfo = psi + }; + } + + public static Command Create(string executable, params string[] args) + { + return Create(executable, ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args)); + } + + public static Command Create(string executable, IEnumerable args) + { + return Create(executable, ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args)); + } + + public static Command Create(string executable, string args) + { + ResolveExecutablePath(ref executable, ref args); + + return new Command(executable, args); + } + + private static void ResolveExecutablePath(ref string executable, ref string args) + { + foreach (string suffix in Constants.RunnableSuffixes) + { + var fullExecutable = Path.GetFullPath(Path.Combine( + AppContext.BaseDirectory, executable + suffix)); + + if (File.Exists(fullExecutable)) + { + executable = fullExecutable; + + // In priority order we've found the best runnable extension, so break. + break; + } + } + + // On Windows, we want to avoid using "cmd" if possible (it mangles the colors, and a bunch of other things) + // So, do a quick path search to see if we can just directly invoke it + var useCmd = ShouldUseCmd(executable); + + if (useCmd) + { + var comSpec = System.Environment.GetEnvironmentVariable("ComSpec"); + + // cmd doesn't like "foo.exe ", so we need to ensure that if + // args is empty, we just run "foo.exe" + if (!string.IsNullOrEmpty(args)) + { + executable = (executable + " " + args).Replace("\"", "\\\""); + } + args = $"/C \"{executable}\""; + executable = comSpec; + } + } + + private static bool ShouldUseCmd(string executable) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + var extension = Path.GetExtension(executable); + if (!string.IsNullOrEmpty(extension)) + { + return !string.Equals(extension, ".exe", StringComparison.Ordinal); + } + else if (executable.Contains(Path.DirectorySeparatorChar)) + { + // It's a relative path without an extension + if (File.Exists(executable + ".exe")) + { + // It refers to an exe! + return false; + } + } + else + { + // Search the path to see if we can find it + foreach (var path in System.Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator)) + { + var candidate = Path.Combine(path, executable + ".exe"); + if (File.Exists(candidate)) + { + // We found an exe! + return false; + } + } + } + + // It's a non-exe :( + return true; + } + + // Non-windows never uses cmd + return false; + } + + public Command Environment(IDictionary env) + { + foreach(var item in env) + { + _process.StartInfo.Environment[item.Key] = item.Value; + } + return this; + } + + public CommandResult Execute() + { + ThrowIfRunning(); + _running = true; + + if (_process.StartInfo.RedirectStandardOutput) + { + _process.OutputDataReceived += (sender, args) => + { + ProcessData(args.Data, _stdOutCapture, _stdOutForward, _stdOutHandler); + }; + } + + if (_process.StartInfo.RedirectStandardError) + { + _process.ErrorDataReceived += (sender, args) => + { + ProcessData(args.Data, _stdErrCapture, _stdErrForward, _stdErrHandler); + }; + } + + _process.EnableRaisingEvents = true; + + var sw = Stopwatch.StartNew(); + BuildReporter.BeginSection("EXEC", FormatProcessInfo(_process.StartInfo)); + + _process.Start(); + + if (_process.StartInfo.RedirectStandardOutput) + { + _process.BeginOutputReadLine(); + } + + if (_process.StartInfo.RedirectStandardError) + { + _process.BeginErrorReadLine(); + } + + _process.WaitForExit(); + + var exitCode = _process.ExitCode; + + var message = $"{FormatProcessInfo(_process.StartInfo)} exited with {exitCode}"; + if (exitCode == 0) + { + BuildReporter.EndSection("EXEC", message.Green(), success: true); + } + else + { + BuildReporter.EndSection("EXEC", message.Red().Bold(), success: false); + } + + return new CommandResult( + _process.StartInfo, + exitCode, + _stdOutCapture?.GetStringBuilder()?.ToString(), + _stdErrCapture?.GetStringBuilder()?.ToString()); + } + + public Command WorkingDirectory(string projectDirectory) + { + _process.StartInfo.WorkingDirectory = projectDirectory; + return this; + } + + public Command EnvironmentVariable(string name, string value) + { + _process.StartInfo.Environment[name] = value; + return this; + } + + public Command CaptureStdOut() + { + ThrowIfRunning(); + _process.StartInfo.RedirectStandardOutput = true; + _stdOutCapture = new StringWriter(); + return this; + } + + public Command CaptureStdErr() + { + ThrowIfRunning(); + _process.StartInfo.RedirectStandardError = true; + _stdErrCapture = new StringWriter(); + return this; + } + + public Command ForwardStdOut(TextWriter to = null) + { + ThrowIfRunning(); + _process.StartInfo.RedirectStandardOutput = true; + if (to == null) + { + _stdOutForward = Reporter.Output.WriteLine; + } + else + { + _stdOutForward = to.WriteLine; + } + return this; + } + + public Command ForwardStdErr(TextWriter to = null) + { + ThrowIfRunning(); + _process.StartInfo.RedirectStandardError = true; + if (to == null) + { + _stdErrForward = Reporter.Error.WriteLine; + } + else + { + _stdErrForward = to.WriteLine; + } + return this; + } + + public Command OnOutputLine(Action handler) + { + ThrowIfRunning(); + _process.StartInfo.RedirectStandardOutput = true; + if (_stdOutHandler != null) + { + throw new InvalidOperationException("Already handling stdout!"); + } + _stdOutHandler = handler; + return this; + } + + public Command OnErrorLine(Action handler) + { + ThrowIfRunning(); + _process.StartInfo.RedirectStandardError = true; + if (_stdErrHandler != null) + { + throw new InvalidOperationException("Already handling stderr!"); + } + _stdErrHandler = handler; + return this; + } + + private string FormatProcessInfo(ProcessStartInfo info) + { + if (string.IsNullOrWhiteSpace(info.Arguments)) + { + return info.FileName; + } + + return info.FileName + " " + info.Arguments; + } + + private void ThrowIfRunning([CallerMemberName] string memberName = null) + { + if (_running) + { + throw new InvalidOperationException($"Unable to invoke {memberName} after the command has been run"); + } + } + + private void ProcessData(string data, StringWriter capture, Action forward, Action handler) + { + if (data == null) + { + return; + } + + if (capture != null) + { + capture.WriteLine(data); + } + + if (forward != null) + { + forward(data); + } + + if (handler != null) + { + handler(data); + } + } + } +} diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/CommandResult.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/CommandResult.cs new file mode 100644 index 000000000..6630a857b --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/CommandResult.cs @@ -0,0 +1,34 @@ +// 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. + +using System; +using System.Diagnostics; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public struct CommandResult + { + public static readonly CommandResult Empty = new CommandResult(); + + public ProcessStartInfo StartInfo { get; } + public int ExitCode { get; } + public string StdOut { get; } + public string StdErr { get; } + + public CommandResult(ProcessStartInfo startInfo, int exitCode, string stdOut, string stdErr) + { + StartInfo = startInfo; + ExitCode = exitCode; + StdOut = stdOut; + StdErr = stdErr; + } + + public void EnsureSuccessful() + { + if(ExitCode != 0) + { + throw new BuildFailureException($"Command failed with exit code {ExitCode}: {StartInfo.FileName} {StartInfo.Arguments}"); + } + } + } +} \ No newline at end of file diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/Constants.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/Constants.cs new file mode 100644 index 000000000..66bbb9000 --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/Constants.cs @@ -0,0 +1,23 @@ +// 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. + +using System.Runtime.InteropServices; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public static class Constants + { + //public static readonly string ProjectFileName = "project.json"; + public static readonly string ExeSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : string.Empty; + + // Priority order of runnable suffixes to look for and run + public static readonly string[] RunnableSuffixes = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? new string[] { ".exe", ".cmd", ".bat" } + : new string[] { string.Empty }; + + public static readonly string DynamicLibPrefix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "" : "lib"; + + public static readonly string DynamicLibSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".dll" : + RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? ".dylib" : ".so"; + } +} diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/DebugHelper.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/DebugHelper.cs new file mode 100644 index 000000000..988e15f8d --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/DebugHelper.cs @@ -0,0 +1,29 @@ +// 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. + +using System; +using System.Diagnostics; +using System.Linq; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public static class DebugHelper + { + [Conditional("DEBUG")] + public static void HandleDebugSwitch(ref string[] args) + { + if (args.Length > 0 && string.Equals("--debug", args[0], StringComparison.OrdinalIgnoreCase)) + { + args = args.Skip(1).ToArray(); + WaitForDebugger(); + } + } + + private static void WaitForDebugger() + { + Console.WriteLine("Waiting for debugger to attach. Press ENTER to continue"); + Console.WriteLine($"Process ID: {Process.GetCurrentProcess().Id}"); + Console.ReadLine(); + } + } +} diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/Microsoft.DotNet.Cli.Build.Framework.xproj b/scripts/Microsoft.DotNet.Cli.Build.Framework/Microsoft.DotNet.Cli.Build.Framework.xproj new file mode 100644 index 000000000..26f7e55e4 --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/Microsoft.DotNet.Cli.Build.Framework.xproj @@ -0,0 +1,19 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 49beb486-ab5a-4416-91ea-8cd34abb0c9d + Microsoft.DotNet.Cli.Build.Framework + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + + 2.0 + + + \ No newline at end of file diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/Reporter.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/Reporter.cs new file mode 100644 index 000000000..766ddf764 --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/Reporter.cs @@ -0,0 +1,65 @@ +// 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. + +using System; +using System.Runtime.InteropServices; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + // Stupid-simple console manager + internal class Reporter + { + private static readonly Reporter Null = new Reporter(console: null); + private static object _lock = new object(); + + private readonly AnsiConsole _console; + + private Reporter(AnsiConsole console) + { + _console = console; + } + + public static Reporter Output { get; } = Create(AnsiConsole.GetOutput); + public static Reporter Error { get; } = Create(AnsiConsole.GetOutput); + public static Reporter Verbose { get; } = Create(AnsiConsole.GetOutput); + + public static Reporter Create(Func getter) + { + var stripColors = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || + string.Equals(Environment.GetEnvironmentVariable("NO_COLOR"), "1"); + return new Reporter(getter(stripColors)); + } + + public void WriteLine(string message) + { + lock (_lock) + { + _console?.WriteLine(message); + } + } + + public void WriteLine() + { + lock (_lock) + { + _console?.Writer?.WriteLine(); + } + } + + public void Write(string message) + { + lock (_lock) + { + _console?.Writer?.Write(message); + } + } + + public void WriteBanner(string content) + { + string border = new string('*', content.Length + 6); + WriteLine($@"{border} +* {content} * +{border}".Green()); + } + } +} diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/StandardGoals.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/StandardGoals.cs new file mode 100644 index 000000000..c22ac967a --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/StandardGoals.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + public static class StandardGoals + { + public static BuildSetup UseStandardGoals(this BuildSetup self) + { + return self.UseTargets(new[] + { + new BuildTarget("Default", "Standard Goals", new [] { "Prepare", "Compile", "Test", "Publish" }), + new BuildTarget("Prepare", "Standard Goals"), + new BuildTarget("Compile", "Standard Goals"), + new BuildTarget("Test", "Standard Goals"), + new BuildTarget("Publish", "Standard Goals") + }); + } + } +} diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/TargetAttribute.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/TargetAttribute.cs new file mode 100644 index 000000000..6cc6771fc --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/TargetAttribute.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.DotNet.Cli.Build.Framework +{ + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] + public class TargetAttribute : Attribute + { + public string Name { get; set; } + public IEnumerable Dependencies { get; } + + public TargetAttribute() + { + Dependencies = Enumerable.Empty(); + } + + // Attributes can only use constants, so a comma-separated string is better :) + public TargetAttribute(params string[] dependencies) + { + Dependencies = dependencies; + } + } +} \ No newline at end of file diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/project.json b/scripts/Microsoft.DotNet.Cli.Build.Framework/project.json new file mode 100644 index 000000000..dd887545d --- /dev/null +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/project.json @@ -0,0 +1,12 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "NETStandard.Library": "1.0.0-rc2-23811", + "System.Diagnostics.Process": "4.1.0-rc2-23811" + }, + + "frameworks": { + "dnxcore50": { } + } +} diff --git a/scripts/build/build.ps1 b/scripts/build/build.ps1 deleted file mode 100644 index a3a26c8a7..000000000 --- a/scripts/build/build.ps1 +++ /dev/null @@ -1,53 +0,0 @@ -# -# 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", - [switch]$Offline, - [switch]$NoPackage) - -$ErrorActionPreference="Stop" - -. "$PSScriptRoot\..\common\_common.ps1" - -. "$RepoRoot\scripts\build\generate-version.ps1" - -_ "$RepoRoot\scripts\clean\clear-nuget-cache.ps1" - -header "Building dotnet tools version $($env:DOTNET_CLI_VERSION) - $Configuration" -header "Checking Pre-Reqs" - -_ "$RepoRoot\scripts\test\check-prereqs.ps1" - -header "Restoring Tools and Packages" - -if ($Offline){ - info "Skipping Tools and Packages dowlnoad: Offline build" -} -else { - _ "$RepoRoot\scripts\obtain\install-tools.ps1" -} - -_ "$RepoRoot\scripts\build\restore-packages.ps1" - -header "Compiling" -_ "$RepoRoot\scripts\compile\compile.ps1" @("$Configuration") - -header "Setting Stage2 as PATH and DOTNET_TOOLS" -setPathAndHome "$Stage2Dir" - -header "Testing" -_ "$RepoRoot\scripts\test\test.ps1" - -header "Validating Dependencies" -_ "$RepoRoot\scripts\test\validate-dependencies.ps1" - -if ($NoPackage){ - info "Skipping Packaging" - exit 0 -} -else { - _ "$RepoRoot\scripts\package\package.ps1" -} diff --git a/scripts/build/build.sh b/scripts/build/build.sh deleted file mode 100755 index 897c80ee3..000000000 --- a/scripts/build/build.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/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 OFFLINE environment variable to build offline - -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 )" - -source "$DIR/../common/_common.sh" - -source "$REPOROOT/scripts/build/generate-version.sh" - -"$REPOROOT/scripts/clean/clear-nuget-cache.sh" - -header "Building dotnet tools version $DOTNET_CLI_VERSION - $CONFIGURATION" -header "Checking Pre-Reqs" - -$REPOROOT/scripts/test/check-prereqs.sh - -header "Adjusting file descriptors limit, if necessary" -# 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 - info "Increasing file description limit to 1024" - ulimit -n 1024 -fi - -header "Restoring Tools and Packages" - -if [ ! -z "$OFFLINE" ]; then - info "Skipping Tools and Package Download: Offline build" -else - $REPOROOT/scripts/obtain/install-tools.sh -fi - -$REPOROOT/scripts/build/restore-packages.sh - -header "Compiling" -$REPOROOT/scripts/compile/compile.sh - -header "Setting Stage2 as PATH, DOTNET_HOME, and DOTNET_TOOLS" -export DOTNET_HOME=$STAGE2_DIR && export DOTNET_TOOLS=$STAGE2DIR && export PATH=$STAGE2_DIR/bin:$PATH - -header "Testing" -$REPOROOT/scripts/test/test.sh - -header "Validating Dependencies" -$REPOROOT/scripts/test/validate-dependencies.sh diff --git a/scripts/build/build_appdeps.ps1 b/scripts/build/build_appdeps.ps1 deleted file mode 100644 index f2fd8d5bc..000000000 --- a/scripts/build/build_appdeps.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -# -# 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( - [Parameter(Mandatory=$true)][string]$RepoRoot, - [Parameter(Mandatory=$true)][string]$OutputDir) - -$appdepBinDir = "$OutputDir\bin\appdepsdk" - -If (Test-Path $appdepBinDir){ - rmdir -Force -Rec $appdepBinDir -} - -mkdir -Force "$appdepBinDir" - -ls "$env:NUGET_PACKAGES\toolchain.win7-x64.Microsoft.DotNet.AppDep\1.0.5-prerelease-00001\*" | foreach { - copy -Rec $_ "$appdepBinDir" -} diff --git a/scripts/build/build_appdeps.sh b/scripts/build/build_appdeps.sh deleted file mode 100755 index 3c47986bb..000000000 --- a/scripts/build/build_appdeps.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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 )" - -source "$DIR/../common/_common.sh" - -# Always recalculate the RID because the package always uses a specific RID, regardless of OS X version or Linux distro. -if [ "$OSNAME" == "osx" ]; then - RID=osx.10.10-x64 -elif [ "$OSNAME" == "ubuntu" ]; then - RID=ubuntu.14.04-x64 -elif [ "$OSNAME" == "centos" ]; then - RID=centos.7.1-x64 -else - echo "Unknown OS: $OSNAME" 1>&2 - exit 1 -fi - -# Get Absolute Output Dir -pushd $1 -OUTPUT_DIR="$(pwd)" -popd - -## App Deps ## -APPDEP_SDK=$NUGET_PACKAGES/toolchain.$RID.Microsoft.DotNet.AppDep/1.0.5-prerelease-00001/ -mkdir -p $OUTPUT_DIR/appdepsdk -cp -a $APPDEP_SDK/. $OUTPUT_DIR/appdepsdk diff --git a/scripts/build/build_info.sh b/scripts/build/build_info.sh deleted file mode 100755 index 3002f798a..000000000 --- a/scripts/build/build_info.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -UNAME=$(uname) -echo "Platform: $UNAME" - -if [ "$UNAME" = "Linux" ]; then - DISTRO=$(cat /etc/os-release | grep "^ID=" | cut -d = -f 2 | sed s/\"//g) - VERSION=$(cat /etc/os-release | grep "^VERSION_ID=" | cut -d = -f 2 | sed s/\"//g) - echo "Distro: $DISTRO" - echo "Version: $VERSION" - echo "RID: $DISTRO.$VERSION-x64" -else - VERSION=$(sw_vers -productVersion) - echo "OS: Mac OS X $VERSION" - echo "RID: osx.$(echo $VERSION | cut -d . -f 1,2)-x64" -fi diff --git a/scripts/build/fix-mode-flags.sh b/scripts/build/fix-mode-flags.sh deleted file mode 100755 index 955d184cd..000000000 --- a/scripts/build/fix-mode-flags.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/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. -# - -# Managed code doesn't need 'x' -find . -type f -name "*.dll" | xargs chmod 644 -find . -type f -name "*.exe" | xargs chmod 644 - -# Generally, dylibs and sos have 'x' (no idea if it's required ;)) -if [ "$(uname)" == "Darwin" ]; then - find . -type f -name "*.dylib" | xargs chmod 755 -else - find . -type f -name "*.so" | xargs chmod 755 -fi - -# Executables (those without dots) are executable :) -find . -type f ! -name "*.*" | xargs chmod 755 diff --git a/scripts/build/generate-version.ps1 b/scripts/build/generate-version.ps1 deleted file mode 100644 index 28e49bec2..000000000 --- a/scripts/build/generate-version.ps1 +++ /dev/null @@ -1,65 +0,0 @@ -# -# 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. -# - -. "$PSScriptRoot\..\common\_common.ps1" - -# MSI versioning -# Encode the CLI version to fit into the MSI versioning scheme - https://msdn.microsoft.com/en-us/library/windows/desktop/aa370859(v=vs.85).aspx -# MSI versions are 3 part -# major.minor.build -# Size(bits) of each part 8 8 16 -# So we have 32 bits to encode the CLI version -# Starting with most significant bit this how the CLI version is going to be encoded as MSI Version -# CLI major -> 6 bits -# CLI minor -> 6 bits -# CLI patch -> 6 bits -# CLI commitcount -> 14 bits -function GetMSIVersionFromCLIVersion([uint32]$Major, [uint32]$Minor, [uint32]$Patch, [uint32]$CommitCount) -{ - if($Major -ge 0x40) - { - throw [System.NotSupportedException] "Invalid Major version - $Major. Major version must be less than 64." - } - - if($Minor -ge 0x40) - { - throw [System.NotSupportedException] "Invalid Minor version - $Minor. Minor version must be less than 64." - } - - if($Patch -ge 0x40) - { - throw [System.NotSupportedException] "Invalid Patch version - $Patch. Patch version must be less than 64." - } - - if($CommitCount -ge 0x4000) - { - throw [System.NotSupportedException] "Invalid CommitCount version - $CommitCount. CommitCount version must be less than 16384." - } - - $Major = ($Major -shl 26) - $Minor = ($Minor -shl 20) - $Patch = ($Patch -shl 14) - [System.UInt32]$MSIVersionNumber = ($Major -bor $Minor -bor $Patch -bor $CommitCount) - - $MSIMajor = ($MSIVersionNumber -shr 24) -band 0xFF - $MSIMinor = ($MSIVersionNumber -shr 16) -band 0xFF - $MSIBuild = $MSIVersionNumber -band 0xFFFF - $MSIVersion = "$MSIMajor.$MSIMinor.$MSIBuild" - - return $MSIVersion -} - -$env:MajorVersion = 1 -$env:MinorVersion = 0 -$env:PatchVersion = 0 - -$CommitCount = [int32](git rev-list --count HEAD) -$env:CommitCountVersion = ([string]$CommitCount).PadLeft(6, "0") - -# Zero Padded Suffix for use with Nuget -$env:VersionSuffix = "$env:ReleaseSuffix-$env:CommitCountVersion" - -$env:DOTNET_CLI_VERSION = "$env:MajorVersion.$env:MinorVersion.$env:PatchVersion.$env:CommitCountVersion" -$env:DOTNET_MSI_VERSION = GetMSIVersionFromCLIVersion $env:MajorVersion $env:MinorVersion $env:PatchVersion $CommitCount diff --git a/scripts/build/generate-version.sh b/scripts/build/generate-version.sh deleted file mode 100755 index 8d541bc4f..000000000 --- a/scripts/build/generate-version.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/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. -# - -export MAJOR_VERSION=1 -export MINOR_VERSION=0 -export PATCH_VERSION=0 - -export COMMIT_COUNT_VERSION=$(printf "%06d" $(git rev-list --count HEAD)) - -export DOTNET_CLI_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION.$COMMIT_COUNT_VERSION diff --git a/scripts/build/place-binary.cmd b/scripts/build/place-binary.cmd deleted file mode 100644 index 143d4a9eb..000000000 --- a/scripts/build/place-binary.cmd +++ /dev/null @@ -1,24 +0,0 @@ -@echo off - -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. - -set SRC=%1 - -set SRC=%SRC:/=\% - -pushd %~dp0..\.. -set DST=%CD%\artifacts\win7-x64\stage2\bin -popd - -if not exist "%SRC%" goto end -if not exist "%DST%" goto skip - -xcopy /F /Y /I "%SRC%" "%DST%" - -goto end - -:skip -echo The destination "%DST%" does not exist. This script is only designed to update a previous full build! - -:end diff --git a/scripts/build/place-binary.sh b/scripts/build/place-binary.sh deleted file mode 100755 index 533ff2b56..000000000 --- a/scripts/build/place-binary.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/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 )" - -source "$DIR/../common/_common.sh" - -echo "Copy From: $1" -echo " To: $STAGE2_DIR/bin/" - -src=${1//\\//} -dst=$STAGE2_DIR/bin/ - -if [ ! -d "$dst" ]; then - mkdir -p $dst -fi - -# Copy the files, if they exist -if ls $src 1> /dev/null 2>&1; then - cp $src $dst - rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi -fi diff --git a/scripts/build/process-args.sh b/scripts/build/process-args.sh deleted file mode 100755 index 53178bd0d..000000000 --- a/scripts/build/process-args.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/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. -# - -params=("$@") - -for i in "${!params[@]}" -do - lowerI="$(echo ${params[$i]} | awk '{print tolower($0)}')" - case $lowerI in - "release" | "--release") - export CONFIGURATION=Release - ;; - "debug" | "--debug") - export CONFIGURATION=Debug - ;; - "offline" | "--offline") - export OFFLINE=true - ;; - "nopackage" | "--nopackage") - export NOPACKAGE=true - ;; - "--buildindocker-ubuntu") - export BUILD_IN_DOCKER=true - export DOCKER_OS=ubuntu - ;; - "--buildindocker-centos") - export BUILD_IN_DOCKER=true - export DOCKER_OS=centos - ;; - *) - esac -done diff --git a/scripts/build/restore-packages.ps1 b/scripts/build/restore-packages.ps1 deleted file mode 100644 index 9ba972481..000000000 --- a/scripts/build/restore-packages.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -# -# 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. -# - -. $PSScriptRoot\..\common\_common.ps1 - -# Restore packages -# NOTE(anurse): I had to remove --quiet, because NuGet3 is too quiet when that's provided :( -header "Restoring packages" - -$StartPath = $env:PATH -$env:PATH = "$env:DOTNET_INSTALL_DIR\cli\bin;$StartPath" - -& dotnet restore "$RepoRoot\src" --runtime "$Rid" -& dotnet restore "$RepoRoot\tools" --runtime "$Rid" - -$env:PATH=$StartPath diff --git a/scripts/build/restore-packages.sh b/scripts/build/restore-packages.sh deleted file mode 100755 index 935bca61a..000000000 --- a/scripts/build/restore-packages.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/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 )" - -source "$DIR/../common/_common.sh" - -export StartPath=$PATH -export PATH=$DOTNET_INSTALL_DIR/bin:$PATH - -header "Restoring packages" - -dotnet restore "$REPOROOT/src" --runtime "$RID" $DISABLE_PARALLEL -dotnet restore "$REPOROOT/tools" --runtime "$RID" $DISABLE_PARALLEL - -export PATH=$StartPath diff --git a/scripts/ci_build.cmd b/scripts/ci_build.cmd index 54f5f51e3..e30184df7 100644 --- a/scripts/ci_build.cmd +++ b/scripts/ci_build.cmd @@ -4,7 +4,9 @@ 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. set CI_BUILD=1 +set CONFIGURATION=%1 +set VERBOSE=1 -CALL %~dp0..\build.cmd %* +CALL %~dp0..\build.cmd %2 exit /b %errorlevel% diff --git a/scripts/ci_build.sh b/scripts/ci_build.sh index 488e3192a..29e9664e1 100755 --- a/scripts/ci_build.sh +++ b/scripts/ci_build.sh @@ -7,6 +7,7 @@ set -e export CI_BUILD=1 +export NO_COLOR=1 SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink @@ -16,7 +17,36 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli done SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" -source "$SCRIPT_DIR/common/_common.sh" +while [[ $# > 0 ]]; do + lowerI="$(echo $1 | awk '{print tolower($0)}')" + case $lowerI in + "release" | "--release") + export CONFIGURATION=Release + ;; + "debug" | "--debug") + export CONFIGURATION=Debug + ;; + "offline" | "--offline") + export OFFLINE=true + ;; + "nopackage" | "--nopackage") + export NOPACKAGE=true + ;; + "--buildindocker-ubuntu") + export BUILD_IN_DOCKER=1 + export DOCKER_IMAGENAME=ubuntu + ;; + "--buildindocker-centos") + export BUILD_IN_DOCKER=1 + export DOCKER_IMAGENAME=centos + ;; + *) + break + ;; + esac + + shift +done # Tell install scripts to skip pre-req check since the CI has the pre-reqs but not ldconfig it seems # Also, install to a directory under the repo root since we don't have permission to work elsewhere @@ -35,17 +65,15 @@ container_name="" #Jenkins [ ! -z "$BUILD_TAG" ] && container_name="$BUILD_TAG" + #VSO [ ! -z "$BUILD_BUILDID" ] && container_name="$BUILD_BUILDID" export DOTNET_BUILD_CONTAINER_NAME="$container_name" +## CentOS-based CI machines don't have docker, ditto OSX. So only build in docker if we're on Ubuntu +#if [ "$(cat /etc/*-release | grep -cim1 ubuntu)" -eq 1 ]; then + #export BUILD_IN_DOCKER=1 +#fi -if [[ "$OSNAME" == "ubuntu" ]]; then - export PACKAGE_IN_DOCKER="true" - unset BUILD_IN_DOCKER - - $SCRIPT_DIR/../build.sh $@ -else - $SCRIPT_DIR/../build.sh $@ -fi +VERBOSE=1 $SCRIPT_DIR/../build.sh "$@" diff --git a/scripts/common/_clang.sh b/scripts/common/_clang.sh deleted file mode 100644 index f4e442d23..000000000 --- a/scripts/common/_clang.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/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 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 diff --git a/scripts/common/_common.ps1 b/scripts/common/_common.ps1 index 85621ab53..dbc1101ce 100644 --- a/scripts/common/_common.ps1 +++ b/scripts/common/_common.ps1 @@ -5,33 +5,26 @@ . $PSScriptRoot\_utility.ps1 -$Skip_Crossgen = $false -$Rid = "win7-x64" -$Tfm = "dnxcore50" -$RepoRoot = Resolve-Path "$PSScriptRoot\..\.." -$OutputDir = "$RepoRoot\artifacts\$Rid" -$Stage1Dir = "$OutputDir\stage1" -$Stage1CompilationDir = "$OutputDir\stage1compilation" -$Stage2Dir = "$OutputDir\stage2" -$Stage2CompilationDir = "$OutputDir\stage2compilation" -$HostDir = "$OutputDir\corehost" -$PackageDir = "$RepoRoot\artifacts\packages\dnvm" -$TestBinRoot = "$RepoRoot\artifacts\tests" -$TestPackageDir = "$TestBinRoot\packages" +# Copy things from environment variables that were sent by the build scripts +$Rid = $env:Rid +$Tfm = $env:Tfm +$OutputDir = $env:OutputDir +$Stage1Dir = $env:Stage1Dir +$Stage1CompilationDir = $env:Stage1CompilationDir +$Stage2Dir = $env:Stage2Dir +$Stage2CompilationDir = $env:Stage2CompilationDir +$HostDir = $env:HostDir +$PackageDir = $env:PackageDir +$TestBinRoot = $env:TestBinRoot +$TestPackageDir = $env:TestPackageDir -$env:TEST_ROOT = "$OutputDir\tests" -$env:TEST_ARTIFACTS = "$env:TEST_ROOT\artifacts" +$env:TEST_ROOT = "$OutputDir\tests" +$env:TEST_ARTIFACTS = "$env:TEST_ROOT\artifacts" -$env:ReleaseSuffix = "beta" -$env:Channel = "$env:ReleaseSuffix" +$env:Channel = "$env:RELEASE_SUFFIX" # Set reasonable defaults for unset variables setEnvIfDefault "DOTNET_INSTALL_DIR" "$RepoRoot\.dotnet_stage0\win7-x64" setEnvIfDefault "DOTNET_CLI_VERSION" "0.1.0.0" -setEnvIfDefault "SKIP_CROSSGEN" "$Skip_Crossgen" setPathAndHomeIfDefault "$Stage2Dir" setVarIfDefault "Configuration" "Debug" - -# Common Files which depend on above properties -. $PSScriptRoot\_nuget.ps1 -. $PSScriptRoot\_configuration.ps1 \ No newline at end of file diff --git a/scripts/common/_common.sh b/scripts/common/_common.sh index 163bbf797..5f0477930 100644 --- a/scripts/common/_common.sh +++ b/scripts/common/_common.sh @@ -12,23 +12,11 @@ done COMMONDIR="$( cd -P "$( dirname "$COMMONSOURCE" )" && pwd )" source "$COMMONDIR/_prettyprint.sh" -source "$COMMONDIR/_rid.sh" - -# TODO: Replace this with a dotnet generation -export SKIP_CROSSGEN=false -export TFM=dnxcore50 -export REPOROOT=$(cd $COMMONDIR/../.. && pwd) -export OUTPUT_ROOT=$REPOROOT/artifacts/$RID -export STAGE1_DIR=$OUTPUT_ROOT/stage1 -export STAGE2_DIR=$OUTPUT_ROOT/stage2 -export HOST_DIR=$OUTPUT_ROOT/corehost -export TEST_BIN_ROOT="$REPOROOT/artifacts/tests" -export TEST_PACKAGE_DIR="$TEST_BIN_ROOT/packages" +# Other variables are set by the outer build script export TEST_ROOT="$OUTPUT_ROOT/tests" export TEST_ARTIFACTS="$TEST_ROOT/artifacts" -export RELEASE_SUFFIX=beta export CHANNEL=$RELEASE_SUFFIX [ -z "$DOTNET_INSTALL_DIR" ] && export DOTNET_INSTALL_DIR=$REPOROOT/.dotnet_stage0/$RID @@ -36,10 +24,6 @@ export CHANNEL=$RELEASE_SUFFIX [ -z "$DOTNET_HOME" ] && export DOTNET_HOME=$STAGE2_DIR && export PATH=$STAGE2_DIR/bin:$PATH [ -z "$CONFIGURATION" ] && export CONFIGURATION=Debug -# Common Files which depend on above properties -source "$COMMONDIR/_nuget.sh" -source "$COMMONDIR/_configuration.sh" - #TODO this is a workaround for a nuget bug on ubuntu. Remove export DISABLE_PARALLEL="" [[ "$RID" =~ "ubuntu" ]] && export DISABLE_PARALLEL="--disable-parallel" diff --git a/scripts/common/_configuration.ps1 b/scripts/common/_configuration.ps1 deleted file mode 100644 index e019a55c8..000000000 --- a/scripts/common/_configuration.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -# -# 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. -# - -function loadTestProjectList() -{ - return Import-CSV "$RepoRoot\scripts\configuration\testProjects.csv" -Header "ProjectName" -} - -function loadTestScriptList() -{ - return Import-CSV "$RepoRoot\scripts\configuration\testScripts.csv" -Header "ProjectName" -} - -function loadTestPackageList() -{ - return Import-CSV "$RepoRoot\scripts\configuration\testPackageProjects.csv" -Header "ProjectName" -} - -function loadBuildProjectList() -{ - return Import-CSV "$RepoRoot\scripts\configuration\buildProjects.csv" -Header "ProjectName" -} \ No newline at end of file diff --git a/scripts/common/_configuration.sh b/scripts/common/_configuration.sh deleted file mode 100644 index 45d2502a7..000000000 --- a/scripts/common/_configuration.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/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. -# - -loadTestProjectList() -{ - echo $(cat "$REPOROOT/scripts/configuration/testProjects.csv") -} - -loadTestScriptList() -{ - echo $(cat "$REPOROOT/scripts/configuration/testScripts.csv") -} - -loadTestPackageList() -{ - echo $(cat "$REPOROOT/scripts/configuration/testPackageProjects.csv") -} - -loadBuildProjectList() -{ - echo $(cat "$REPOROOT/scripts/configuration/buildProjects.csv") -} \ No newline at end of file diff --git a/scripts/common/_nuget.ps1 b/scripts/common/_nuget.ps1 deleted file mode 100644 index df3428d69..000000000 --- a/scripts/common/_nuget.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -# -# 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. -# - -$env:NUGET_PACKAGES = (Join-Path $env:USERPROFILE ".nuget\packages") -$env:DOTNET_PACKAGES = $env:NUGET_PACKAGES -$env:DNX_PACKAGES = $env:NUGET_PACKAGES -if(!(Test-Path $env:NUGET_PACKAGES)) { - mkdir $env:NUGET_PACKAGES | Out-Null -} - -# default the package cache expiration to 1 week, in hours -setEnvIfDefault "NUGET_PACKAGES_CACHE_TIME_LIMIT" (7 * 24) diff --git a/scripts/common/_nuget.sh b/scripts/common/_nuget.sh deleted file mode 100644 index 81bb9fac5..000000000 --- a/scripts/common/_nuget.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/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. -# - -if [ ! -z "$CI_BUILD" ]; then - # On CI, $HOME is redirected under the repo, which gets deleted after every build. - # So make $NUGET_PACKAGES outside of the repo. - NUGET_PACKAGES=$REPOROOT/../.nuget/packages -else - NUGET_PACKAGES=~/.nuget/packages -fi - -export NUGET_PACKAGES -export DOTNET_PACKAGES=$NUGET_PACKAGES -export DNX_PACKAGES=$NUGET_PACKAGES - -if [ ! -d $NUGET_PACKAGES ]; then - mkdir -p $NUGET_PACKAGES -fi - -if [ -z "$NUGET_PACKAGES_CACHE_TIME_LIMIT" ]; then - # default the package cache expiration to 1 week, in hours - export NUGET_PACKAGES_CACHE_TIME_LIMIT=$(( 7 * 24 )) -fi diff --git a/scripts/common/_rid.sh b/scripts/common/_rid.sh deleted file mode 100644 index 37f3c459e..000000000 --- a/scripts/common/_rid.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/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. -# - -export UNAME=$(uname) - -if [ -z "$RID" ]; then - if [ "$UNAME" == "Darwin" ]; then - export OSNAME=osx - if [ -n "$(sw_vers -productVersion | grep 10.10)" ]; then - export RID=osx.10.10-x64 - elif [ -n "$(sw_vers -productVersion | grep 10.11)" ]; then - export RID=osx.10.11-x64 - else - error "unknown OS X: $(sw_vers -productVersion)" 1>&2 - fi - elif [ "$UNAME" == "Linux" ]; then - # Detect Distro - if [ "$(cat /etc/*-release | grep -cim1 ubuntu)" -eq 1 ]; then - export OSNAME=ubuntu - export RID=ubuntu.14.04-x64 - elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then - export OSNAME=centos - export RID=centos.7-x64 - else - error "unknown Linux Distro" 1>&2 - fi - else - error "unknown OS: $UNAME" 1>&2 - fi -fi - -if [ -z "$RID" ]; then - exit 1 -fi diff --git a/scripts/common/_utility.ps1 b/scripts/common/_utility.ps1 index e331c776a..2e5d68a62 100644 --- a/scripts/common/_utility.ps1 +++ b/scripts/common/_utility.ps1 @@ -73,4 +73,4 @@ function _cmd([string]$command) error "Command Failed: 'cmd /c $command'" Exit 1 } -} \ No newline at end of file +} diff --git a/scripts/compile/compile-corehost.ps1 b/scripts/compile/compile-corehost.ps1 deleted file mode 100644 index ec2f88234..000000000 --- a/scripts/compile/compile-corehost.ps1 +++ /dev/null @@ -1,46 +0,0 @@ -# -# 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. -# - -. $PSScriptRoot\..\common\_common.ps1 - -header "Building corehost" -pushd "$RepoRoot\src\corehost" -try { - if (!(Test-Path "cmake\$Rid")) { - mkdir "cmake\$Rid" | Out-Null - } - cd "cmake\$Rid" - cmake ..\.. -G "Visual Studio 14 2015 Win64" - $pf = $env:ProgramFiles - if (Test-Path "env:\ProgramFiles(x86)") { - $pf = (cat "env:\ProgramFiles(x86)") - } - $BuildConfiguration = $Configuration - if ($Configuration -eq "Release") { - $BuildConfiguration = "RelWithDebInfo" - } - & "$pf\MSBuild\14.0\Bin\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration="$BuildConfiguration" - if (!$?) { - Write-Host "Command failed: $pf\MSBuild\14.0\Bin\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration="$BuildConfiguration" - Exit 1 - } - - if (!(Test-Path $HostDir)) { - mkdir $HostDir | Out-Null - } - cp "$RepoRoot\src\corehost\cmake\$Rid\cli\$BuildConfiguration\corehost.exe" $HostDir - cp "$RepoRoot\src\corehost\cmake\$Rid\cli\dll\$BuildConfiguration\hostpolicy.dll" $HostDir - - if (Test-Path "$RepoRoot\src\corehost\cmake\$Rid\cli\$BuildConfiguration\corehost.pdb") - { - cp "$RepoRoot\src\corehost\cmake\$Rid\cli\$BuildConfiguration\corehost.pdb" $HostDir - } - if (Test-Path "$RepoRoot\src\corehost\cmake\$Rid\cli\dll\$BuildConfiguration\hostpolicy.pdb") - { - cp "$RepoRoot\src\corehost\cmake\$Rid\cli\dll\$BuildConfiguration\hostpolicy.pdb" $HostDir - } -} finally { - popd -} diff --git a/scripts/compile/compile-corehost.sh b/scripts/compile/compile-corehost.sh deleted file mode 100755 index 109e5a655..000000000 --- a/scripts/compile/compile-corehost.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/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. -# - -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 )" - -source "$DIR/../common/_common.sh" -source "$DIR/../common/_clang.sh" - -header "Building corehost" - -pushd "$REPOROOT/src/corehost" 2>&1 >/dev/null -[ -d "cmake/$RID" ] || mkdir -p "cmake/$RID" -cd "cmake/$RID" -cmake ../.. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING=$CONFIGURATION -make - -# Publish to artifacts -[ -d "$HOST_DIR" ] || mkdir -p $HOST_DIR -if [[ "$OSNAME" == "osx" ]]; then - COREHOST_LIBNAME=libhostpolicy.dylib -else - COREHOST_LIBNAME=libhostpolicy.so -fi -cp "$REPOROOT/src/corehost/cmake/$RID/cli/corehost" $HOST_DIR -cp "$REPOROOT/src/corehost/cmake/$RID/cli/dll/${COREHOST_LIBNAME}" $HOST_DIR -popd 2>&1 >/dev/null diff --git a/scripts/compile/compile-stage-1.ps1 b/scripts/compile/compile-stage-1.ps1 deleted file mode 100644 index d682a75a9..000000000 --- a/scripts/compile/compile-stage-1.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -# -# 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. -# - -. $PSScriptRoot\..\common\_common.ps1 - -header "Compiling stage1 dotnet using downloaded stage0 ..." -$StartPath = $env:PATH -$env:PATH = "$env:DOTNET_INSTALL_DIR\cli\bin;$StartPath" - -_ "$RepoRoot\scripts\compile\compile-stage.ps1" @("$Tfm","$Rid","$Configuration","$Stage1Dir","$RepoRoot","$HostDir", "$Stage1CompilationDir") - -$env:PATH=$StartPath \ No newline at end of file diff --git a/scripts/compile/compile-stage-1.sh b/scripts/compile/compile-stage-1.sh deleted file mode 100755 index ce11e4690..000000000 --- a/scripts/compile/compile-stage-1.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/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 )" - -source "$DIR/../common/_common.sh" - -export StartPath=$PATH -export PATH=$DOTNET_INSTALL_DIR/bin:$PATH - -# Build Stage 1 -header "Building stage1 dotnet using downloaded stage0 ..." -OUTPUT_DIR=$STAGE1_DIR $REPOROOT/scripts/compile/compile-stage.sh - -export PATH=$StartPath \ No newline at end of file diff --git a/scripts/compile/compile-stage-2.ps1 b/scripts/compile/compile-stage-2.ps1 deleted file mode 100644 index 874438d4a..000000000 --- a/scripts/compile/compile-stage-2.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -# -# 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. -# - -. $PSScriptRoot\..\common\_common.ps1 - -header "Compiling stage2 dotnet using stage1 ..." -$StartPath = $env:PATH -$env:PATH = "$Stage1Dir\bin;$env:PATH" - -# Compile -_ "$RepoRoot\scripts\compile\compile-stage.ps1" @("$Tfm","$Rid","$Configuration","$Stage2Dir","$RepoRoot","$HostDir", "$Stage2CompilationDir") - - -# Build the projects that we are going to ship as nuget packages -. $REPOROOT\scripts\package\projectsToPack.ps1 - -$ProjectsToPack | ForEach-Object { - dotnet build --build-base-path "$Stage2CompilationDir\forPackaging" --configuration "$Configuration" "$RepoRoot\src\$_" - if (!$?) { - Write-Host Command failed: dotnet build --native-subdirectory --build-base-path "$Stage2CompilationDir\forPackaging" --configuration "$Configuration" "$RepoRoot\src\$_" - exit 1 - } -} - -$env:PATH=$StartPath \ No newline at end of file diff --git a/scripts/compile/compile-stage-2.sh b/scripts/compile/compile-stage-2.sh deleted file mode 100755 index 521d1ae22..000000000 --- a/scripts/compile/compile-stage-2.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/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 )" - -source "$DIR/../common/_common.sh" - -# Use stage1 tools -export StartPath=$PATH -export DOTNET_TOOLS=$STAGE1_DIR -export PATH=$STAGE1_DIR/bin:$PATH - -# Compile Stage 2 -header "Compiling stage2 dotnet using just-built stage1 ..." -OUTPUT_DIR=$STAGE2_DIR $REPOROOT/scripts/compile/compile-stage.sh - -export DOTNET_HOME=$STAGE2_DIR -export DOTNET_TOOLS=$STAGE2_DIR \ No newline at end of file diff --git a/scripts/compile/compile-stage.ps1 b/scripts/compile/compile-stage.ps1 deleted file mode 100644 index a2de5c30d..000000000 --- a/scripts/compile/compile-stage.ps1 +++ /dev/null @@ -1,84 +0,0 @@ -# -# 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( - [Parameter(Mandatory=$true)][string]$Tfm, - [Parameter(Mandatory=$true)][string]$Rid, - [Parameter(Mandatory=$true)][string]$Configuration, - [Parameter(Mandatory=$true)][string]$StageOutputDir, - [Parameter(Mandatory=$true)][string]$RepoRoot, - [Parameter(Mandatory=$true)][string]$HostDir, - [Parameter(Mandatory=$true)][string]$CompilationOutputDir) - -$Projects = loadBuildProjectList - -$BinariesForCoreHost = @( - "csi" - "csc" - "vbc" -) - -$FilesToClean = @( - "README.md" - "Microsoft.DotNet.Runtime.exe" - "Microsoft.DotNet.Runtime.dll" - "Microsoft.DotNet.Runtime.deps" - "Microsoft.DotNet.Runtime.pdb" -) - -$RuntimeOutputDir = "$StageOutputDir\runtime\coreclr" - -# Publish each project -$Projects | ForEach-Object { - dotnet publish --native-subdirectory --framework "$Tfm" --runtime "$Rid" --output "$StageOutputDir\bin" --configuration "$Configuration" "$RepoRoot\src\$($_.ProjectName)" - if (!$?) { - Write-Host Command failed: dotnet publish --native-subdirectory --framework "$Tfm" --runtime "$Rid" --output "$StageOutputDir\bin" --configuration "$Configuration" "$RepoRoot\src\$($_.ProjectName)" - exit 1 - } -} - -# Publish the runtime -dotnet publish --framework "$Tfm" --runtime "$Rid" --output "$RuntimeOutputDir" --configuration "$Configuration" "$RepoRoot\src\Microsoft.DotNet.Runtime" -if (!$?) { - Write-Host Command failed: dotnet publish --framework "$Tfm" --runtime "$Rid" --output "$RuntimeOutputDir" --configuration "$Configuration" "$RepoRoot\src\Microsoft.DotNet.Runtime" - Exit 1 -} - -# Clean up bogus additional files -$FilesToClean | ForEach-Object { - $path = Join-Path $RuntimeOutputDir $_ - if (Test-Path $path) { - del -for $path - } -} - -# Copy the runtime app-local for the tools -cp -rec "$RuntimeOutputDir\*" "$StageOutputDir\bin" -ErrorVariable capturedErrors -ErrorAction SilentlyContinue -$capturedErrors | foreach-object { - if ($_ -notmatch "already exists") { - write-error $_ - Exit 1 - } -} - -# Deploy the CLR host to the output -cp "$HostDir\corehost.exe" "$StageOutputDir\bin" -cp "$HostDir\hostpolicy.dll" "$StageOutputDir\bin" - -# corehostify externally-provided binaries (csc, vbc, etc.) -$BinariesForCoreHost | ForEach-Object { - mv $StageOutputDir\bin\$_.exe $StageOutputDir\bin\$_.dll -Force - cp $StageOutputDir\bin\corehost.exe $StageOutputDir\bin\$_.exe -Force -} - -# Crossgen Roslyn -if (-not (Test-Path "$StageOutputDir\bin\csc.ni.exe")) { - _cmd "$RepoRoot\scripts\crossgen\crossgen_roslyn.cmd ""$StageOutputDir""" -} - -# Copy in AppDeps -header "Acquiring Native App Dependencies" -_ "$RepoRoot\scripts\build\build_appdeps.ps1" @("$RepoRoot", "$StageOutputDir") - diff --git a/scripts/compile/compile-stage.sh b/scripts/compile/compile-stage.sh deleted file mode 100755 index 2f4b8ef9d..000000000 --- a/scripts/compile/compile-stage.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/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 )" - -source "$DIR/../common/_common.sh" - -[ ! -z "$TFM" ] || die "Missing required environment variable TFM" -[ ! -z "$RID" ] || die "Missing required environment variable RID" -[ ! -z "$CONFIGURATION" ] || die "Missing required environment variable CONFIGURATION" -[ ! -z "$OUTPUT_DIR" ] || die "Missing required environment variable OUTPUT_DIR" -[ ! -z "$HOST_DIR" ] || die "Missing required environment variable HOST_DIR" - -PROJECTS=$(loadBuildProjectList) - -BINARIES_FOR_COREHOST=( \ - csi \ - csc \ - vbc \ -) - -FILES_TO_CLEAN=( \ - README.md \ - Microsoft.DotNet.Runtime \ - Microsoft.DotNet.Runtime.dll \ - Microsoft.DotNet.Runtime.deps \ - Microsoft.DotNet.Runtime.pdb \ -) - -RUNTIME_OUTPUT_DIR="$OUTPUT_DIR/runtime/coreclr" - -for project in $PROJECTS -do - echo dotnet publish --native-subdirectory --framework "$TFM" --output "$OUTPUT_DIR/bin" --configuration "$CONFIGURATION" "$REPOROOT/src/$project" - dotnet publish --native-subdirectory --framework "$TFM" --output "$OUTPUT_DIR/bin" --configuration "$CONFIGURATION" "$REPOROOT/src/$project" -done - -# Bring in the runtime -dotnet publish --output "$RUNTIME_OUTPUT_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Runtime" - -# Clean up bogus additional files -for file in ${FILES_TO_CLEAN[@]} -do - [ -e "$RUNTIME_OUTPUT_DIR/$file" ] && rm "$RUNTIME_OUTPUT_DIR/$file" -done - -# Copy the runtime app-local for the tools -cp -R $RUNTIME_OUTPUT_DIR/* $OUTPUT_DIR/bin - -# Deploy CLR host to the output -if [[ "$OSNAME" == "osx" ]]; then - COREHOST_LIBNAME=libhostpolicy.dylib -else - COREHOST_LIBNAME=libhostpolicy.so -fi -cp "$HOST_DIR/corehost" "$OUTPUT_DIR/bin" -cp "$HOST_DIR/${COREHOST_LIBNAME}" "$OUTPUT_DIR/bin" - -# corehostify externally-provided binaries (csc, vbc, etc.) -for binary in ${BINARIES_FOR_COREHOST[@]} -do - cp $OUTPUT_DIR/bin/corehost $OUTPUT_DIR/bin/$binary - mv $OUTPUT_DIR/bin/${binary}.exe $OUTPUT_DIR/bin/${binary}.dll -done - -cd $OUTPUT_DIR - -# Fix up permissions. Sometimes they get dropped with the wrong info -find . -type f | xargs chmod 644 -$REPOROOT/scripts/build/fix-mode-flags.sh - -if [ ! -f "$OUTPUT_DIR/bin/csc.ni.exe" ]; then - $REPOROOT/scripts/crossgen/crossgen_roslyn.sh "$OUTPUT_DIR/bin" -fi - -# Make OUTPUT_DIR Folder Accessible -chmod -R a+r $OUTPUT_DIR - -# No compile native support in centos yet -# https://github.com/dotnet/cli/issues/453 -if [ "$OSNAME" != "centos" ]; then - # Copy in AppDeps - if [ ! -d "$OUTPUT_DIR/bin/appdepsdk" ]; then - header "Acquiring Native App Dependencies" - DOTNET_HOME=$OUTPUT_DIR DOTNET_TOOLS=$OUTPUT_DIR $REPOROOT/scripts/build/build_appdeps.sh "$OUTPUT_DIR/bin" - fi -fi - -# Stamp the output with the commit metadata -COMMIT=$(git rev-parse HEAD) -echo $COMMIT > $OUTPUT_DIR/.version -echo $DOTNET_CLI_VERSION >> $OUTPUT_DIR/.version diff --git a/scripts/compile/compile.ps1 b/scripts/compile/compile.ps1 deleted file mode 100644 index b562c4fab..000000000 --- a/scripts/compile/compile.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -# -# 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") - -$ErrorActionPreference="Stop" - -. $PSScriptRoot\..\common\_common.ps1 - -# Capture PATH for later -$StartPath = $env:PATH -$StartDotNetHome = $env:DOTNET_HOME - -try { - _ "$RepoRoot\scripts\compile\compile-corehost.ps1" - - _ "$RepoRoot\scripts\compile\compile-stage-1.ps1" - - # Issue https://github.com/dotnet/cli/issues/1294 - _ "$RepoRoot\scripts\build\restore-packages.ps1" - - _ "$RepoRoot\scripts\compile\compile-stage-2.ps1" -} finally { - $env:PATH = $StartPath - $env:DOTNET_HOME = $StartDotNetHome -} diff --git a/scripts/compile/compile.sh b/scripts/compile/compile.sh deleted file mode 100755 index 3a1416a30..000000000 --- a/scripts/compile/compile.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/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 )" - -source "$DIR/../common/_common.sh" - -$REPOROOT/scripts/compile/compile-corehost.sh - -$REPOROOT/scripts/compile/compile-stage-1.sh - -# Issue https://github.com/dotnet/cli/issues/1294 -$REPOROOT/scripts/build/restore-packages.sh - -$REPOROOT/scripts/compile/compile-stage-2.sh diff --git a/scripts/configuration/buildProjects.csv b/scripts/configuration/buildProjects.csv deleted file mode 100644 index 3d25d1bdf..000000000 --- a/scripts/configuration/buildProjects.csv +++ /dev/null @@ -1 +0,0 @@ -dotnet diff --git a/scripts/configuration/testPackageProjects.csv b/scripts/configuration/testPackageProjects.csv deleted file mode 100644 index 90069c976..000000000 --- a/scripts/configuration/testPackageProjects.csv +++ /dev/null @@ -1,2 +0,0 @@ -dotnet-hello/v1/dotnet-hello -dotnet-hello/v2/dotnet-hello \ No newline at end of file diff --git a/scripts/configuration/testProjects.csv b/scripts/configuration/testProjects.csv deleted file mode 100644 index 3e70cd4d7..000000000 --- a/scripts/configuration/testProjects.csv +++ /dev/null @@ -1,8 +0,0 @@ -EndToEnd -dotnet-publish.Tests -dotnet-compile.Tests -dotnet-compile.UnitTests -dotnet-build.Tests -Microsoft.DotNet.Cli.Utils.Tests -Microsoft.DotNet.Compiler.Common.Tests -ArgumentForwardingTests \ No newline at end of file diff --git a/scripts/configuration/testScripts.csv b/scripts/configuration/testScripts.csv deleted file mode 100644 index bd42a3352..000000000 --- a/scripts/configuration/testScripts.csv +++ /dev/null @@ -1 +0,0 @@ -package-command-test \ No newline at end of file diff --git a/scripts/crossgen/crossgen_roslyn.cmd b/scripts/crossgen/crossgen_roslyn.cmd deleted file mode 100644 index 06754af91..000000000 --- a/scripts/crossgen/crossgen_roslyn.cmd +++ /dev/null @@ -1,83 +0,0 @@ -REM Turn echo off off so we can echo with echo and the echoing -REM (But seriously, this script has weird hangs and crashes sometimes so we want to know exactly which commands are failing) -REM @echo off - -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. - -if %SKIP_CROSSGEN% EQU 0 goto skip - -echo Crossgenning Roslyn compiler ... - -REM Get absolute path -pushd %1 -set BIN_DIR=%CD%\bin -popd - -REM Replace with a robust method for finding the right crossgen.exe -set CROSSGEN_UTIL=%NUGET_PACKAGES%\runtime.win7-x64.Microsoft.NETCore.Runtime.CoreCLR\1.0.1-rc2-23811\tools\crossgen.exe - -REM Crossgen currently requires itself to be next to mscorlib -copy %CROSSGEN_UTIL% /Y %BIN_DIR% > nul - -pushd %BIN_DIR% - -REM It must also be called mscorlib, not mscorlib.ni -if exist mscorlib.ni.dll ( - copy /Y mscorlib.ni.dll mscorlib.dll > nul -) - -set READYTORUN= - -echo Crossgenning System.Collections.Immutable -crossgen /nologo %READYTORUN% /Platform_Assemblies_Paths %BIN_DIR% System.Collections.Immutable.dll >nul 2>nul -if not %errorlevel% EQU 0 goto fail - -echo Crossgenning System.Reflection.Metadata -crossgen /nologo %READYTORUN% /Platform_Assemblies_Paths %BIN_DIR% System.Reflection.Metadata.dll >nul 2>nul -if not %errorlevel% EQU 0 goto fail - -echo Crossgenning Microsoft.CodeAnalysis -crossgen /nologo %READYTORUN% /Platform_Assemblies_Paths %BIN_DIR% Microsoft.CodeAnalysis.dll >nul 2>nul -if not %errorlevel% EQU 0 goto fail - -echo Crossgenning Microsoft.CodeAnalysis.CSharp -crossgen /nologo %READYTORUN% /Platform_Assemblies_Paths %BIN_DIR% Microsoft.CodeAnalysis.CSharp.dll >nul 2>nul -if not %errorlevel% EQU 0 goto fail - -echo Crossgenning Microsoft.CodeAnalysis.CSharp.Scripting -crossgen /nologo %READYTORUN% /Platform_Assemblies_Paths %BIN_DIR% Microsoft.CodeAnalysis.CSharp.Scripting.dll >nul 2>nul -if not %errorlevel% EQU 0 goto fail - -echo Crossgenning Microsoft.CodeAnalysis.VisualBasic -crossgen /nologo %READYTORUN% /Platform_Assemblies_Paths %BIN_DIR% Microsoft.CodeAnalysis.VisualBasic.dll >nul 2>nul -if not %errorlevel% EQU 0 goto fail - -echo Crossgenning csc -crossgen /nologo %READYTORUN% /Platform_Assemblies_Paths %BIN_DIR% csc.dll >nul 2>nul -if not %errorlevel% EQU 0 goto fail - -echo Crossgenning csi -crossgen /nologo %READYTORUN% /Platform_Assemblies_Paths %BIN_DIR% csi.dll >nul 2>nul -if not %errorlevel% EQU 0 goto fail - -echo Crossgenning vbc -crossgen /nologo %READYTORUN% /Platform_Assemblies_Paths %BIN_DIR% vbc.dll >nul 2>nul -if not %errorlevel% EQU 0 goto fail - -popd - -echo CrossGen Roslyn Finished - -goto end - -:fail -popd -echo Crossgen failed... -exit /B 1 - -:skip -echo Skipping Crossgen -goto end - -:end diff --git a/scripts/crossgen/crossgen_roslyn.sh b/scripts/crossgen/crossgen_roslyn.sh deleted file mode 100755 index dc5562b03..000000000 --- a/scripts/crossgen/crossgen_roslyn.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/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. -# - -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 )" - -source "$DIR/../common/_common.sh" - -if $SKIP_CROSSGEN ; then - echo "Skipping Crossgen" - exit 0 -fi - - -info "Crossgenning Roslyn compiler ..." - -set -e - -BIN_DIR="$( cd $1 && pwd )" - -UNAME=`uname` - -# Always recalculate the RID because the package always uses a specific RID, regardless of OS X version or Linux distro. -if [ "$OSNAME" == "osx" ]; then - RID=osx.10.10-x64 -elif [ "$OSNAME" == "ubuntu" ]; then - RID=ubuntu.14.04-x64 -elif [ "$OSNAME" == "centos" ]; then - RID=rhel.7-x64 -else - echo "Unknown OS: $OSNAME" 1>&2 - exit 1 -fi - -READYTORUN="" - -# Replace with a robust method for finding the right crossgen.exe -CROSSGEN_UTIL=$NUGET_PACKAGES/runtime.$RID.Microsoft.NETCore.Runtime.CoreCLR/1.0.1-rc2-23811/tools/crossgen - -cd $BIN_DIR - -# Crossgen currently requires itself to be next to mscorlib -cp $CROSSGEN_UTIL $BIN_DIR -chmod +x crossgen - -./crossgen -nologo $READYTORUN -platform_assemblies_paths $BIN_DIR mscorlib.dll - -info "Crossgenning System.Collections.Immutable" -./crossgen -nologo $READYTORUN -platform_assemblies_paths $BIN_DIR System.Collections.Immutable.dll - -info "Crossgenning System.Reflection.Metadata" -./crossgen -nologo $READYTORUN -platform_assemblies_paths $BIN_DIR System.Reflection.Metadata.dll - -info "Crossgenning Microsoft.CodeAnalysis" -./crossgen -nologo $READYTORUN -platform_assemblies_paths $BIN_DIR Microsoft.CodeAnalysis.dll - -info "Crossgenning Microsoft.CodeAnalysis.CSharp" -./crossgen -nologo $READYTORUN -platform_assemblies_paths $BIN_DIR Microsoft.CodeAnalysis.CSharp.dll - -info "Crossgenning Microsoft.CodeAnalysis.CSharp.Scripting" -./crossgen -nologo $READYTORUN -platform_assemblies_paths $BIN_DIR Microsoft.CodeAnalysis.CSharp.Scripting.dll - -info "Crossgenning Microsoft.CodeAnalysis.VisualBasic" -./crossgen -nologo $READYTORUN -platform_assemblies_paths $BIN_DIR Microsoft.CodeAnalysis.VisualBasic.dll - -info "Crossgenning csc" -./crossgen -nologo $READYTORUN -platform_assemblies_paths $BIN_DIR csc.dll -[ -e csc.ni.exe ] && [ ! -e csc.ni.dll ] && mv csc.ni.exe csc.ni.dll - -info "Crossgenning csi" -./crossgen -nologo $READYTORUN -platform_assemblies_paths $BIN_DIR csi.dll -[ -e csi.ni.exe ] && [ ! -e csi.ni.dll ] && mv csi.ni.exe csi.ni.dll - -info "Crossgenning vbc" -./crossgen -nologo $READYTORUN -platform_assemblies_paths $BIN_DIR vbc.dll -[ -e vbc.ni.exe ] && [ ! -e vbc.ni.dll ] && mv vbc.ni.exe vbc.ni.dll - -info "CrossGen Roslyn Finished" diff --git a/scripts/docker/dockerbuild.sh b/scripts/docker/dockerbuild.sh deleted file mode 100755 index 6ec676a4b..000000000 --- a/scripts/docker/dockerbuild.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/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 )" - -source "$DIR/../common/_common.sh" - -cd $REPOROOT - -[ -z "$DOTNET_BUILD_CONTAINER_TAG" ] && DOTNET_BUILD_CONTAINER_TAG="dotnetcli-build" -[ -z "$DOTNET_BUILD_CONTAINER_NAME" ] && DOTNET_BUILD_CONTAINER_NAME="dotnetcli-build-container" -[ -z "$DOCKER_HOST_SHARE_DIR" ] && DOCKER_HOST_SHARE_DIR=$(pwd) -[ -z "$DOCKER_OS" ] && DOCKER_OS=$OSNAME -[ -z "$BUILD_COMMAND" ] && BUILD_COMMAND="/opt/code/scripts/build/build.sh" - -# Build the docker container (will be fast if it is already built) -header "Building Docker Container" -docker build --build-arg USER_ID=$(id -u) -t $DOTNET_BUILD_CONTAINER_TAG scripts/docker/$DOCKER_OS - -# Run the build in the container -header "Launching build in Docker Container" -info "Using code from: $DOCKER_HOST_SHARE_DIR" -docker run -t --rm --sig-proxy=true \ - --name $DOTNET_BUILD_CONTAINER_NAME \ - -v $DOCKER_HOST_SHARE_DIR:/opt/code \ - -e DOTNET_CLI_VERSION \ - -e SASTOKEN \ - -e STORAGE_ACCOUNT \ - -e STORAGE_CONTAINER \ - -e CHANNEL \ - -e CONNECTION_STRING \ - -e REPO_ID \ - -e REPO_USER \ - -e REPO_PASS \ - -e REPO_SERVER \ - $DOTNET_BUILD_CONTAINER_TAG \ - bash -c "${BUILD_COMMAND}" diff --git a/scripts/docker/dockerrun.sh b/scripts/docker/dockerrun.sh deleted file mode 100755 index d388d0b1b..000000000 --- a/scripts/docker/dockerrun.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/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. -# - -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 )" - -source "$DIR/../_common.sh" - -cd $REPOROOT - -[ -z "$DOTNET_BUILD_CONTAINER_TAG" ] && DOTNET_BUILD_CONTAINER_TAG="dotnetcli-build" -[ -z "$DOTNET_BUILD_CONTAINER_NAME" ] && DOTNET_BUILD_CONTAINER_NAME="dotnetcli-build-container" -[ -z "$DOCKER_HOST_SHARE_DIR" ] && DOCKER_HOST_SHARE_DIR=$(pwd) - -# Enter the container -docker run -it --rm --sig-proxy=true \ - -v $DOCKER_HOST_SHARE_DIR:/opt/code \ - $DOTNET_BUILD_CONTAINER_TAG diff --git a/scripts/docker/windows_dockerbuild.sh b/scripts/docker/windows_dockerbuild.sh deleted file mode 100755 index 960740dbc..000000000 --- a/scripts/docker/windows_dockerbuild.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/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. -# - -# Prerequisites: -# Git Bash (http://www.git-scm.com/downloads) -# Docker Toolbox (https://www.docker.com/docker-toolbox) -# Ensure Hyper-V is disabled! - -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 )" - -# This function is necessary to bypass POSIX Path Conversion in Git Bash -# http://www.mingw.org/wiki/Posix_path_conversion -_convert_path(){ - local path=$1 - path=$( echo "$path" | sed -r 's/[\/]+/\\/g') - path=${path#\\} - path=//$path - - echo $path -} - -# Bypass Msys path conversion -REPO_ROOT=$(readlink -f $DIR/../..) -REPO_ROOT=$(_convert_path $REPO_ROOT) - -VM_NAME="dotnet" -VM_CODE_DIR="/home/docker/code" - -RESULTS_DIR="$REPO_ROOT/artifacts" - -execute(){ - check_prereqs - - echo "Setting up VM..." - create_or_start_vm - - echo "Copying code from Host to VM" - eval $(docker-machine env --shell bash $VM_NAME) - copy_code_to_vm - - echo "Running Build in Docker Container" - run_build - - echo "Copying Results from VM to Hosts..." - copy_results_from_vm -} - -check_prereqs(){ - if ! which docker; then - echo "Error: Install docker toolbox (https://www.docker.com/docker-toolbox)" - exit 1 - fi - - if ! which docker-machine; then - echo "Error: Install docker toolbox (https://www.docker.com/docker-toolbox)" - exit 1 - fi - -} - -create_or_start_vm(){ - - if [[ $(docker-machine ls | grep $VM_NAME) == "" ]]; then - docker-machine create -d virtualbox $VM_NAME - else - # This fails sometimes - if ! docker-machine start $VM_NAME; then - docker-machine rm -f $VM_NAME - docker-machine create -d virtualbox $VM_NAME - fi - fi - -} - -copy_code_to_vm(){ - docker-machine ssh $VM_NAME "sudo rm -rf $VM_CODE_DIR" - docker-machine scp -r $REPO_ROOT $VM_NAME:$VM_CODE_DIR >> /dev/null 2>&1 -} - - -run_build(){ - # These are env variables for dockerbuild.sh - export DOCKER_HOST_SHARE_DIR="$(_convert_path $VM_CODE_DIR)" - export BUILD_COMMAND="//opt\\code\\build.sh" - - $DIR/../dockerbuild.sh debian -} - -# This will duplicate the entire repo + any side effects from -# the operations in the docker container -copy_results_from_vm(){ - T_RESULTS_DIR=$( echo "$RESULTS_DIR" | sed -r 's/[\\]+/\//g') - T_RESULTS_DIR=${T_RESULTS_DIR#/} - - mkdir $T_RESULTS_DIR - docker-machine ssh $VM_NAME "sudo chmod -R a+rx $VM_CODE_DIR" - docker-machine scp -r $VM_NAME:$VM_CODE_DIR/artifacts $REPO_ROOT >> /dev/null 2>&1 -} - -execute - diff --git a/scripts/test/setup/build-test-prerequisites.sh b/scripts/dockerbuild.sh similarity index 52% rename from scripts/test/setup/build-test-prerequisites.sh rename to scripts/dockerbuild.sh index edced11eb..34351f8b0 100755 --- a/scripts/test/setup/build-test-prerequisites.sh +++ b/scripts/dockerbuild.sh @@ -1,8 +1,4 @@ #!/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 @@ -12,16 +8,6 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli 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 )" -source "$DIR/../../common/_common.sh" - -mkdir -p "$TEST_PACKAGE_DIR" - -PROJECTS=$(loadTestPackageList) - -for project in $PROJECTS -do - dotnet pack "$REPOROOT/TestAssets/TestPackages/$project" --output "$TEST_PACKAGE_DIR" -done +BUILD_COMMAND=/opt/code/scripts/run-build.sh $DIR/dockerrun.sh --non-interactive "$@" diff --git a/scripts/dockerrun.sh b/scripts/dockerrun.sh new file mode 100755 index 000000000..f56f04d24 --- /dev/null +++ b/scripts/dockerrun.sh @@ -0,0 +1,102 @@ +#!/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 )" + +cd "$DIR/.." + +INTERACTIVE="-i" + +while [[ $# > 0 ]]; do + key=$1 + + case $key in + --non-interactive) + INTERACTIVE= + ;; + -i|--image) + DOCKER_IMAGENAME=$2 + shift + ;; + -d|--dockerfile) + DOCKERFILE=$2 + shift + ;; + -h|-?|--help) + echo "Usage: $0 [-d|--dockerfile ] [-i|--image ] " + echo "" + echo "Options:" + echo " The path to the Dockerfile to use to create the build container" + echo " The name of an existing Dockerfile folder under scripts/docker to use as the Dockerfile" + echo " The command to run once inside the container (/opt/code is mapped to the repo root; defaults to nothing, which runs the default shell)" + exit 0 + ;; + *) + break # the first non-switch we get ends parsing + ;; + esac + + shift +done + +if [ -z "$DOCKERFILE" ]; then + if [ -z "$DOCKER_IMAGENAME" ]; then + if [ "$(uname)" == "Darwin" ]; then + echo "Defaulting to 'ubuntu' image for Darwin" + export DOCKERFILE=scripts/docker/ubuntu + elif [ "$(cat /etc/*-release | grep -cim1 ubuntu)" -eq 1 ]; then + echo "Detected current OS as Ubuntu, using 'ubuntu' image" + export DOCKERFILE=scripts/docker/ubuntu + elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then + echo "Detected current OS as CentOS, using 'centos' image" + export DOCKERFILE=scripts/docker/centos + else + echo "Unknown Linux Distro. Using 'ubuntu' image" + export DOCKERFILE=scripts/docker/ubuntu + fi + else + echo "Using requested image: $DOCKER_IMAGENAME" + export DOCKERFILE="scripts/docker/$DOCKER_IMAGENAME" + fi +fi + +[ -z "$DOTNET_BUILD_CONTAINER_TAG" ] && DOTNET_BUILD_CONTAINER_TAG="dotnetcli-build" +[ -z "$DOTNET_BUILD_CONTAINER_NAME" ] && DOTNET_BUILD_CONTAINER_NAME="dotnetcli-build-container" +[ -z "$DOCKER_HOST_SHARE_DIR" ] && DOCKER_HOST_SHARE_DIR=$(pwd) + +# Build the docker container (will be fast if it is already built) +echo "Building Docker Container using Dockerfile: $DOCKERFILE" +docker build --build-arg USER_ID=$(id -u) -t $DOTNET_BUILD_CONTAINER_TAG $DOCKERFILE + +# Run the build in the container +echo "Launching build in Docker Container" +echo "Running command: $BUILD_COMMAND" +echo "Using code from: $DOCKER_HOST_SHARE_DIR" +[ -z "$INTERACTIVE" ] || echo "Running Interactive" + +docker run $INTERACTIVE -t --rm --sig-proxy=true \ + --name $DOTNET_BUILD_CONTAINER_NAME \ + -v $DOCKER_HOST_SHARE_DIR:/opt/code \ + -e SASTOKEN \ + -e STORAGE_ACCOUNT \ + -e STORAGE_CONTAINER \ + -e CHANNEL \ + -e CONNECTION_STRING \ + -e REPO_ID \ + -e REPO_USER \ + -e REPO_PASS \ + -e REPO_SERVER \ + -e DOTNET_BUILD_SKIP_CROSSGEN \ + $DOTNET_BUILD_CONTAINER_TAG \ + $BUILD_COMMAND "$@" diff --git a/scripts/dotnet-cli-build/CompileTargets.cs b/scripts/dotnet-cli-build/CompileTargets.cs new file mode 100644 index 000000000..5185fa361 --- /dev/null +++ b/scripts/dotnet-cli-build/CompileTargets.cs @@ -0,0 +1,401 @@ +using Microsoft.DotNet.Cli.Build.Framework; +using Microsoft.Extensions.PlatformAbstractions; +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; + +using static Microsoft.DotNet.Cli.Build.FS; +using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; + +namespace Microsoft.DotNet.Cli.Build +{ + public class CompileTargets + { + public static readonly string CoreCLRVersion = "1.0.1-rc2-23811"; + public static readonly string AppDepSdkVersion = "1.0.5-prerelease-00001"; + + public static readonly List AssembliesToCrossGen = GetAssembliesToCrossGen(); + + public static readonly string[] BinariesForCoreHost = new[] + { + "csi", + "csc", + "vbc" + }; + + public static readonly string[] ProjectsToPublish = new[] + { + "dotnet" + }; + + public static readonly string[] FilesToClean = new[] + { + "README.md", + "Microsoft.DotNet.Runtime.exe", + "Microsoft.DotNet.Runtime.dll", + "Microsoft.DotNet.Runtime.deps", + "Microsoft.DotNet.Runtime.pdb" + }; + + public static readonly string[] ProjectsToPack = new[] + { + "Microsoft.DotNet.Cli.Utils", + "Microsoft.DotNet.ProjectModel", + "Microsoft.DotNet.ProjectModel.Loader", + "Microsoft.DotNet.ProjectModel.Workspaces", + "Microsoft.Extensions.DependencyModel", + "Microsoft.Extensions.Testing.Abstractions" + }; + + [Target(nameof(PrepareTargets.Init), nameof(CompileCoreHost), nameof(CompileStage1), nameof(CompileStage2))] + public static BuildTargetResult Compile(BuildTargetContext c) + { + return c.Success(); + } + + [Target] + public static BuildTargetResult CompileCoreHost(BuildTargetContext c) + { + // Generate build files + var cmakeOut = Path.Combine(Dirs.Corehost, "cmake"); + + Rmdir(cmakeOut); + Mkdirp(cmakeOut); + + var configuration = (string)c.BuildContext["Configuration"]; + + // Run the build + 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. + ExecIn(cmakeOut, "cmake", + Path.Combine(c.BuildContext.BuildDirectory, "src", "corehost"), + "-G", + "Visual Studio 14 2015 Win64"); + + 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", "Debug", "corehost.exe"), Path.Combine(Dirs.Corehost, "corehost.exe"), overwrite: true); + File.Copy(Path.Combine(cmakeOut, "cli", "Debug", "corehost.pdb"), Path.Combine(Dirs.Corehost, "corehost.pdb"), overwrite: true); + File.Copy(Path.Combine(cmakeOut, "cli", "dll", "Debug", "hostpolicy.dll"), Path.Combine(Dirs.Corehost, "hostpolicy.dll"), overwrite: true); + File.Copy(Path.Combine(cmakeOut, "cli", "dll", "Debug", "hostpolicy.pdb"), Path.Combine(Dirs.Corehost, "hostpolicy.pdb"), overwrite: true); + } + else + { + ExecIn(cmakeOut, Path.Combine(c.BuildContext.BuildDirectory, "src", "corehost", "build.sh")); + + // Copy the output out + File.Copy(Path.Combine(cmakeOut, "cli", "corehost"), Path.Combine(Dirs.Corehost, "corehost"), overwrite: true); + File.Copy(Path.Combine(cmakeOut, "cli", "dll", $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), Path.Combine(Dirs.Corehost, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), overwrite: true); + } + + return c.Success(); + } + + [Target] + public static BuildTargetResult CompileStage1(BuildTargetContext c) + { + CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); + CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "test")); + return CompileStage(c, + dotnet: DotNetCli.Stage0, + outputDir: Dirs.Stage1); + } + + [Target] + public static BuildTargetResult CompileStage2(BuildTargetContext c) + { + var configuration = (string)c.BuildContext["Configuration"]; + + CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); + CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "test")); + var result = CompileStage(c, + dotnet: DotNetCli.Stage1, + outputDir: Dirs.Stage2); + if (!result.Success) + { + return result; + } + + // Build projects that are packed in NuGet packages, but only on Windows + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + var packagingOutputDir = Path.Combine(Dirs.Stage2Compilation, "forPackaging"); + Mkdirp(packagingOutputDir); + foreach(var project in ProjectsToPack) + { + // Just build them, we'll pack later + DotNetCli.Stage1.Build( + "--build-base-path", + packagingOutputDir, + "--configuration", + configuration, + Path.Combine(c.BuildContext.BuildDirectory, "src", project)) + .Execute() + .EnsureSuccessful(); + } + } + + return c.Success(); + } + + private static BuildTargetResult CompileStage(BuildTargetContext c, DotNetCli dotnet, string outputDir) + { + Rmdir(outputDir); + + dotnet.SetDotNetHome(); + + var configuration = (string)c.BuildContext["Configuration"]; + var binDir = Path.Combine(outputDir, "bin"); + var runtimeOutputDir = Path.Combine(outputDir, "runtime", "coreclr"); + + Mkdirp(binDir); + Mkdirp(runtimeOutputDir); + + foreach (var project in ProjectsToPublish) + { + dotnet.Publish( + "--native-subdirectory", + "--output", + binDir, + "--configuration", + configuration, + Path.Combine(c.BuildContext.BuildDirectory, "src", project)) + .Execute() + .EnsureSuccessful(); + } + + // Publish the runtime + dotnet.Publish( + "--output", + runtimeOutputDir, + "--configuration", + configuration, + Path.Combine(c.BuildContext.BuildDirectory, "src", "Microsoft.DotNet.Runtime")) + .Execute() + .EnsureSuccessful(); + + // Clean bogus files + foreach (var fileToClean in FilesToClean) + { + var pathToClean = Path.Combine(runtimeOutputDir, fileToClean); + if (File.Exists(pathToClean)) + { + File.Delete(pathToClean); + } + } + + FixModeFlags(outputDir); + + // Copy the whole runtime local to the tools + CopyRecursive(runtimeOutputDir, binDir); + + // Copy corehost + File.Copy(Path.Combine(Dirs.Corehost, $"corehost{Constants.ExeSuffix}"), Path.Combine(binDir, $"corehost{Constants.ExeSuffix}"), overwrite: true); + File.Copy(Path.Combine(Dirs.Corehost, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), Path.Combine(binDir, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), overwrite: true); + + // Corehostify binaries + foreach(var binaryToCorehostify in BinariesForCoreHost) + { + try + { + // Yes, it is .exe even on Linux. This is the managed exe we're working with + File.Copy(Path.Combine(binDir, $"{binaryToCorehostify}.exe"), Path.Combine(binDir, $"{binaryToCorehostify}.dll")); + File.Delete(Path.Combine(binDir, $"{binaryToCorehostify}.exe")); + File.Copy(Path.Combine(binDir, $"corehost{Constants.ExeSuffix}"), Path.Combine(binDir, binaryToCorehostify + Constants.ExeSuffix)); + } + catch(Exception ex) + { + return c.Failed($"Failed to corehostify '{binaryToCorehostify}': {ex.ToString()}"); + } + } + + // Crossgen Roslyn + var result = Crossgen(c, binDir); + if (!result.Success) + { + return result; + } + + // Copy AppDeps + result = CopyAppDeps(c, binDir); + if(!result.Success) + { + return result; + } + + // Generate .version file + var version = ((BuildVersion)c.BuildContext["BuildVersion"]).SimpleVersion; + var content = $@"{version}{Environment.NewLine}{c.BuildContext["CommitHash"]}{Environment.NewLine}"; + File.WriteAllText(Path.Combine(outputDir, ".version"), content); + + return c.Success(); + } + + private static BuildTargetResult CopyAppDeps(BuildTargetContext c, string outputDir) + { + var appDepOutputDir = Path.Combine(outputDir, "appdepsdk"); + Rmdir(appDepOutputDir); + Mkdirp(appDepOutputDir); + + // Find toolchain package + string packageId; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + packageId = "toolchain.win7-x64.Microsoft.DotNet.AppDep"; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + var osname = PlatformServices.Default.Runtime.OperatingSystem; + if (string.Equals(osname, "ubuntu", StringComparison.OrdinalIgnoreCase)) + { + packageId = "toolchain.ubuntu.14.04-x64.Microsoft.DotNet.AppDep"; + } + else if (string.Equals(osname, "centos", StringComparison.OrdinalIgnoreCase)) + { + c.Warn("Native compilation is not yet working on CentOS"); + return c.Success(); + } + else + { + return c.Failed($"Unknown Linux Distro: {osname}"); + } + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + packageId = "toolchain.osx.10.10-x64.Microsoft.DotNet.AppDep"; + } + else + { + return c.Failed("Unsupported OS Platform"); + } + + var appDepPath = Path.Combine( + Dirs.NuGetPackages, + packageId, + AppDepSdkVersion); + CopyRecursive(appDepPath, appDepOutputDir, overwrite: true); + + return c.Success(); + } + + private static BuildTargetResult Crossgen(BuildTargetContext c, string outputDir) + { + // Check if we need to skip crossgen + if (string.Equals(Environment.GetEnvironmentVariable("DOTNET_BUILD_SKIP_CROSSGEN"), "1")) + { + c.Warn("Skipping crossgen because DOTNET_BUILD_SKIP_CROSSGEN is set"); + return c.Success(); + } + + // Find crossgen + string packageId; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + packageId = "runtime.win7-x64.Microsoft.NETCore.Runtime.CoreCLR"; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + var osname = PlatformServices.Default.Runtime.OperatingSystem; + if (string.Equals(osname, "ubuntu", StringComparison.OrdinalIgnoreCase)) + { + packageId = "runtime.ubuntu.14.04-x64.Microsoft.NETCore.Runtime.CoreCLR"; + } + else if (string.Equals(osname, "centos", StringComparison.OrdinalIgnoreCase)) + { + // CentOS runtime is in the runtime.rhel.7-x64... package. + packageId = "runtime.rhel.7-x64.Microsoft.NETCore.Runtime.CoreCLR"; + } + else + { + return c.Failed($"Unknown Linux Distro: {osname}"); + } + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + packageId = "runtime.osx.10.10-x64.Microsoft.NETCore.Runtime.CoreCLR"; + } + else + { + return c.Failed("Unsupported OS Platform"); + } + + var crossGenExePath = Path.Combine( + Dirs.NuGetPackages, + packageId, + CoreCLRVersion, + "tools", + $"crossgen{Constants.ExeSuffix}"); + + // We have to copy crossgen next to mscorlib + var crossgen = Path.Combine(outputDir, $"crossgen{Constants.ExeSuffix}"); + File.Copy(crossGenExePath, crossgen, overwrite: true); + Chmod(crossgen, "a+x"); + + // And if we have mscorlib.ni.dll, we need to rename it to mscorlib.dll + if (File.Exists(Path.Combine(outputDir, "mscorlib.ni.dll"))) + { + File.Copy(Path.Combine(outputDir, "mscorlib.ni.dll"), Path.Combine(outputDir, "mscorlib.dll"), overwrite: true); + } + + foreach (var assemblyToCrossgen in AssembliesToCrossGen) + { + c.Info($"Crossgenning {assemblyToCrossgen}"); + ExecIn(outputDir, crossgen, "-nologo", "-platform_assemblies_paths", outputDir, assemblyToCrossgen); + } + + c.Info("Crossgen complete"); + + // Check if csc/vbc.ni.exe exists, and overwrite the dll with it just in case + if (File.Exists(Path.Combine(outputDir, "csc.ni.exe")) && !File.Exists(Path.Combine(outputDir, "csc.ni.dll"))) + { + File.Move(Path.Combine(outputDir, "csc.ni.exe"), Path.Combine(outputDir, "csc.ni.dll")); + } + + if (File.Exists(Path.Combine(outputDir, "vbc.ni.exe")) && !File.Exists(Path.Combine(outputDir, "vbc.ni.dll"))) + { + File.Move(Path.Combine(outputDir, "vbc.ni.exe"), Path.Combine(outputDir, "vbc.ni.dll")); + } + + return c.Success(); + } + + private static List GetAssembliesToCrossGen() + { + var list = new List + { + "System.Collections.Immutable.dll", + "System.Reflection.Metadata.dll", + "Microsoft.CodeAnalysis.dll", + "Microsoft.CodeAnalysis.CSharp.dll", + "Microsoft.CodeAnalysis.VisualBasic.dll", + "csc.dll", + "vbc.dll" + }; + + // mscorlib is already crossgenned on Windows + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + // mscorlib has to be crossgenned first + list.Insert(0, "mscorlib.dll"); + } + + return list; + } + } +} diff --git a/scripts/dotnet-cli-build/PrepareTargets.cs b/scripts/dotnet-cli-build/PrepareTargets.cs new file mode 100644 index 000000000..abd94ba68 --- /dev/null +++ b/scripts/dotnet-cli-build/PrepareTargets.cs @@ -0,0 +1,219 @@ +using Microsoft.DotNet.Cli.Build.Framework; +using Microsoft.Extensions.PlatformAbstractions; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Runtime.InteropServices; + +using static Microsoft.DotNet.Cli.Build.FS; +using static Microsoft.DotNet.Cli.Build.Utils; +using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; + +namespace Microsoft.DotNet.Cli.Build +{ + public class PrepareTargets + { + [Target(nameof(Init), nameof(RestorePackages))] + public static BuildTargetResult Prepare(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))] + public static BuildTargetResult Init(BuildTargetContext c) + { + var runtimeInfo = PlatformServices.Default.Runtime; + + var configEnv = Environment.GetEnvironmentVariable("CONFIGURATION"); + + if(string.IsNullOrEmpty(configEnv)) + { + configEnv = "Debug"; + } + c.BuildContext["Configuration"] = configEnv; + + c.Info($"Building {c.BuildContext["Configuration"]} to: {Dirs.Output}"); + c.Info("Build Environment:"); + c.Info($" Operating System: {runtimeInfo.OperatingSystem} {runtimeInfo.OperatingSystemVersion}"); + c.Info($" Platform: {runtimeInfo.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 branchInfo = ReadBranchInfo(c, Path.Combine(c.BuildContext.BuildDirectory, "branchinfo.txt")); + var buildVersion = new BuildVersion() + { + Major = int.Parse(branchInfo["MAJOR_VERSION"]), + Minor = int.Parse(branchInfo["MINOR_VERSION"]), + Patch = int.Parse(branchInfo["PATCH_VERSION"]), + ReleaseSuffix = branchInfo["RELEASE_SUFFIX"], + CommitCount = commitCount + }; + c.BuildContext["BuildVersion"] = buildVersion; + c.BuildContext["CommitHash"] = commitHash; + + c.Info($"Building Version: {buildVersion.SimpleVersion} (NuGet Packages: {buildVersion.NuGetVersion})"); + 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 + var version = File.ReadAllLines(Path.Combine(stage0, "..", ".version")); + c.Info($"Using Stage 0 Version: {version[1]}"); + + return c.Success(); + } + + [Target] + public static BuildTargetResult CheckPrereqs(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(); + } + + [Target] + public static BuildTargetResult CheckPackageCache(BuildTargetContext c) + { + var ciBuild = string.Equals(Environment.GetEnvironmentVariable("CI_BUILD"), "1", StringComparison.Ordinal); + + if (ciBuild) + { + // On CI, HOME is redirected under the repo, which gets deleted after every build. + // So make NUGET_PACKAGES outside of the repo. + var nugetPackages = Path.GetFullPath(Path.Combine(c.BuildContext.BuildDirectory, "..", ".nuget", "packages")); + Environment.SetEnvironmentVariable("NUGET_PACKAGES", nugetPackages); + Dirs.NuGetPackages = nugetPackages; + } + + // Set the package cache location in NUGET_PACKAGES just to be safe + if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("NUGET_PACKAGES"))) + { + Environment.SetEnvironmentVariable("NUGET_PACKAGES", Dirs.NuGetPackages); + } + + CleanNuGetTempCache(); + + // Determine cache expiration time + var cacheExpiration = 7 * 24; // cache expiration in hours + var cacheExpirationStr = Environment.GetEnvironmentVariable("NUGET_PACKAGES_CACHE_TIME_LIMIT"); + if (!string.IsNullOrEmpty(cacheExpirationStr)) + { + cacheExpiration = int.Parse(cacheExpirationStr); + } + + if (ciBuild) + { + var cacheTimeFile = Path.Combine(Dirs.NuGetPackages, "packageCacheTime.txt"); + + DateTime? cacheTime = null; + try + { + // Read the cache file + if(File.Exists(cacheTimeFile)) + { + var content = File.ReadAllText(cacheTimeFile); + if(!string.IsNullOrEmpty(content)) + { + cacheTime = DateTime.ParseExact("O", content, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); + } + } + } + catch(Exception ex) + { + c.Warn($"Error reading NuGet cache time file, leaving the cache alone"); + c.Warn($"Error Detail: {ex.ToString()}"); + } + + if(cacheTime == null || (cacheTime.Value.AddHours(cacheExpiration) < DateTime.UtcNow)) + { + // Cache has expired or the status is unknown, clear it and write the file + c.Info("Clearing NuGet cache"); + Rmdir(Dirs.NuGetPackages); + Mkdirp(Dirs.NuGetPackages); + File.WriteAllText(cacheTimeFile, DateTime.UtcNow.ToString("O")); + } + } + + return c.Success(); + } + + [Target(nameof(CheckPackageCache))] + public static BuildTargetResult RestorePackages(BuildTargetContext c) + { + var dotnet = DotNetCli.Stage0; + + dotnet.Restore().WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "src")).Execute().EnsureSuccessful(); + dotnet.Restore().WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "tools")).Execute().EnsureSuccessful(); + + return c.Success(); + } + + private static IDictionary ReadBranchInfo(BuildTargetContext c, string path) + { + var lines = File.ReadAllLines(path); + var dict = new Dictionary(); + c.Verbose("Branch Info:"); + foreach(var line in lines) + { + if(!line.Trim().StartsWith("#") && !string.IsNullOrWhiteSpace(line)) + { + var splat = line.Split(new[] { '=' }, 2); + dict[splat[0]] = splat[1]; + c.Verbose($" {splat[0]} = {splat[1]}"); + } + } + return dict; + } + } +} diff --git a/scripts/dotnet-cli-build/Program.cs b/scripts/dotnet-cli-build/Program.cs new file mode 100755 index 000000000..bc2661b2c --- /dev/null +++ b/scripts/dotnet-cli-build/Program.cs @@ -0,0 +1,12 @@ +using Microsoft.DotNet.Cli.Build.Framework; + +namespace Microsoft.DotNet.Cli.Build +{ + public class Program + { + public static int Main(string[] args) => BuildSetup.Create(".NET Core CLI") + .UseStandardGoals() + .UseAllTargetsFromAssembly() + .Run(args); + } +} diff --git a/scripts/dotnet-cli-build/TestTargets.cs b/scripts/dotnet-cli-build/TestTargets.cs new file mode 100644 index 000000000..6937781f8 --- /dev/null +++ b/scripts/dotnet-cli-build/TestTargets.cs @@ -0,0 +1,241 @@ +using Microsoft.DotNet.Cli.Build.Framework; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; + +using static Microsoft.DotNet.Cli.Build.FS; +using static Microsoft.DotNet.Cli.Build.Utils; +using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; + +namespace Microsoft.DotNet.Cli.Build +{ + public class TestTargets + { + public static readonly string[] TestPackageProjects = new[] + { + "dotnet-hello/v1/dotnet-hello", + "dotnet-hello/v2/dotnet-hello" + }; + + public static readonly string[] TestProjects = new[] + { + "EndToEnd", + "dotnet-publish.Tests", + "dotnet-compile.Tests", + "dotnet-compile.UnitTests", + "dotnet-build.Tests", + "Microsoft.DotNet.Cli.Utils.Tests", + "Microsoft.DotNet.Compiler.Common.Tests", + "ArgumentForwardingTests" + }; + + [Target(nameof(PrepareTargets.Init), nameof(SetupTests), nameof(RestoreTests), nameof(BuildTests), nameof(RunTests), nameof(ValidateDependencies))] + public static BuildTargetResult Test(BuildTargetContext c) => c.Success(); + + [Target(nameof(RestoreTestPrerequisites), nameof(BuildTestPrerequisites))] + public static BuildTargetResult SetupTests(BuildTargetContext c) => c.Success(); + + [Target] + public static BuildTargetResult RestoreTestPrerequisites(BuildTargetContext c) + { + CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); + CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "test")); + + CleanNuGetTempCache(); + + var dotnet = DotNetCli.Stage2; + dotnet.Restore().WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets")).Execute().EnsureSuccessful(); + + // The 'testapp' directory contains intentionally-unresolved dependencies, so don't check for success. Also, suppress the output + dotnet.Restore().WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "testapp")).CaptureStdErr().CaptureStdOut().Execute(); + + return c.Success(); + } + + [Target] + public static BuildTargetResult BuildTestPrerequisites(BuildTargetContext c) + { + var dotnet = DotNetCli.Stage2; + + Rmdir(Dirs.TestPackages); + Mkdirp(Dirs.TestPackages); + + foreach (var relativePath in TestPackageProjects) + { + var fullPath = Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestPackages", relativePath.Replace('/', Path.DirectorySeparatorChar)); + c.Info("Packing: {fullPath}"); + dotnet.Pack("--output", Dirs.TestPackages) + .WorkingDirectory(fullPath) + .Execute() + .EnsureSuccessful(); + } + + return c.Success(); + } + + [Target] + public static BuildTargetResult RestoreTests(BuildTargetContext c) + { + CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); + CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "test")); + + CleanNuGetTempCache(); + DotNetCli.Stage2.Restore("--fallbacksource", Dirs.TestPackages) + .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "test")) + .Execute() + .EnsureSuccessful(); + return c.Success(); + } + + [Target] + public static BuildTargetResult BuildTests(BuildTargetContext c) + { + var dotnet = DotNetCli.Stage2; + foreach (var testProject in TestProjects) + { + c.Info("Building tests: {project}"); + dotnet.Build() + .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "test", testProject)) + .Execute() + .EnsureSuccessful(); + } + return c.Success(); + } + + [Target(nameof(RunXUnitTests), nameof(RunPackageCommandTests))] + public static BuildTargetResult RunTests(BuildTargetContext c) => c.Success(); + + [Target] + public static BuildTargetResult RunXUnitTests(BuildTargetContext c) + { + // Need to load up the VS Vars + var dotnet = DotNetCli.Stage2; + var vsvars = LoadVsVars(); + + // Copy the test projects + var testProjectsDir = Path.Combine(Dirs.TestOutput, "TestProjects"); + Rmdir(testProjectsDir); + Mkdirp(testProjectsDir); + CopyRecursive(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects"), testProjectsDir); + + // Run the tests and set the VS vars in the environment when running them + var failingTests = new List(); + foreach (var project in TestProjects) + { + c.Info("Running tests in: {project}"); + var result = dotnet.Test("-xml", $"{project}-testResults.xml", "-notrait", "category=failing") + .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "test", project)) + .Environment(vsvars) + .EnvironmentVariable("PATH", $"{DotNetCli.Stage2.BinPath}{Path.PathSeparator}{Environment.GetEnvironmentVariable("PATH")}") + .Execute(); + if (result.ExitCode != 0) + { + failingTests.Add(project); + } + } + + if (failingTests.Any()) + { + foreach (var project in failingTests) + { + c.Error($"{project} failed"); + } + return c.Failed("Tests failed!"); + } + + return c.Success(); + } + + [Target] + public static BuildTargetResult RunPackageCommandTests(BuildTargetContext c) + { + var dotnet = DotNetCli.Stage2; + var consumers = Path.Combine(c.BuildContext.BuildDirectory, "test", "PackagedCommands", "Consumers"); + + // Compile the consumer apps + foreach(var dir in Directory.EnumerateDirectories(consumers)) + { + dotnet.Build().WorkingDirectory(dir).Execute().EnsureSuccessful(); + } + + // Test the apps + foreach(var dir in Directory.EnumerateDirectories(consumers)) + { + var result = dotnet.Exec("hello").WorkingDirectory(dir).CaptureStdOut().CaptureStdErr().Execute(); + result.EnsureSuccessful(); + if(!string.Equals("Hello", result.StdOut.Trim(), StringComparison.Ordinal)) + { + var testName = Path.GetFileName(dir); + c.Error($"Packaged Commands Test '{testName}' failed"); + c.Error($" Expected 'Hello', but got: '{result.StdOut.Trim()}'"); + return c.Failed($"Packaged Commands Test failed '{testName}'"); + } + } + + return c.Success(); + } + + [Target] + public static BuildTargetResult ValidateDependencies(BuildTargetContext c) + { + var configuration = (string)c.BuildContext["Configuration"]; + var dotnet = DotNetCli.Stage2; + + c.Info("Publishing MultiProjectValidator"); + dotnet.Publish("--output", Path.Combine(Dirs.Output, "tools"), "--configuration", configuration) + .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "tools", "MultiProjectValidator")) + .Execute() + .EnsureSuccessful(); + + var validator = Path.Combine(Dirs.Output, "tools", $"pjvalidate{Constants.ExeSuffix}"); + + Cmd(validator, Path.Combine(c.BuildContext.BuildDirectory, "src")) + .Execute(); + + return c.Success(); + } + + private static Dictionary LoadVsVars() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return new Dictionary(); + } + + var vsvarsPath = Path.GetFullPath(Path.Combine(Environment.GetEnvironmentVariable("VS140COMNTOOLS"), "..", "..", "VC")); + + // Write a temp batch file because that seems to be the easiest way to do this (argument parsing is hard) + var temp = Path.Combine(Path.GetTempPath(), $"{Path.GetRandomFileName()}.cmd"); + File.WriteAllText(temp, $@"@echo off +cd {vsvarsPath} +call vcvarsall.bat x64 +set"); + + CommandResult result; + try + { + result = Cmd(Environment.GetEnvironmentVariable("COMSPEC"), "/c", temp) + .WorkingDirectory(vsvarsPath) + .CaptureStdOut() + .Execute(); + } + finally + { + if (File.Exists(temp)) + { + File.Delete(temp); + } + } + result.EnsureSuccessful(); + var vars = new Dictionary(); + foreach (var line in result.StdOut.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) + { + var splat = line.Split(new[] { '=' }, 2); + vars[splat[0]] = splat[1]; + } + return vars; + } + } +} diff --git a/scripts/dotnet-cli-build/Utils/BuildVersion.cs b/scripts/dotnet-cli-build/Utils/BuildVersion.cs new file mode 100644 index 000000000..c03b48bd3 --- /dev/null +++ b/scripts/dotnet-cli-build/Utils/BuildVersion.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.DotNet.Cli.Build +{ + public class BuildVersion + { + public int Major { get; set; } + public int Minor { get; set; } + public int Patch { get; set; } + public int CommitCount { get; set; } + public string CommitCountString => CommitCount.ToString("000000"); + public string ReleaseSuffix { get; set; } + + public string SimpleVersion => $"{Major}.{Minor}.{Patch}.{CommitCount}"; + public string VersionSuffix => $"{ReleaseSuffix}-{CommitCount}"; + public string NuGetVersion => $"{Major}.{Minor}.{Patch}-{VersionSuffix}"; + + public string GenerateMsiVersion() + { + // MSI versioning + // Encode the CLI version to fit into the MSI versioning scheme - https://msdn.microsoft.com/en-us/library/windows/desktop/aa370859(v=vs.85).aspx + // MSI versions are 3 part + // major.minor.build + // Size(bits) of each part 8 8 16 + // So we have 32 bits to encode the CLI version + // Starting with most significant bit this how the CLI version is going to be encoded as MSI Version + // CLI major -> 6 bits + // CLI minor -> 6 bits + // CLI patch -> 6 bits + // CLI commitcount -> 14 bits + + var major = Major << 26; + var minor = Minor << 20; + var patch = Patch << 14; + var msiVersionNumber = major | minor | patch | CommitCount; + + var msiMajor = (msiVersionNumber >> 24) & 0xFF; + var msiMinor = (msiVersionNumber >> 16) & 0xFF; + var msiBuild = msiVersionNumber & 0xFFFF; + + return $"{msiMajor}.{msiMinor}.{msiBuild}"; + } + } +} diff --git a/scripts/dotnet-cli-build/Utils/Dirs.cs b/scripts/dotnet-cli-build/Utils/Dirs.cs new file mode 100644 index 000000000..c90b63406 --- /dev/null +++ b/scripts/dotnet-cli-build/Utils/Dirs.cs @@ -0,0 +1,38 @@ +using Microsoft.Extensions.PlatformAbstractions; +using System; +using System.IO; +using System.Runtime.InteropServices; + +namespace Microsoft.DotNet.Cli.Build +{ + public static class Dirs + { + public static readonly string Output = Path.Combine( + Directory.GetCurrentDirectory(), + "artifacts", + PlatformServices.Default.Runtime.GetRuntimeIdentifier()); + public static readonly string Packages = Path.Combine(Output, "packages"); + public static readonly string Stage1 = Path.Combine(Output, "stage1"); + public static readonly string Stage1Compilation = Path.Combine(Output, "stage1compilation"); + public static readonly string Stage2 = Path.Combine(Output, "stage2"); + public static readonly string Stage2Compilation = Path.Combine(Output, "stage2compilation"); + public static readonly string Corehost = Path.Combine(Output, "corehost"); + public static readonly string TestOutput = Path.Combine(Output, "tests"); + public static readonly string TestPackages = Path.Combine(TestOutput, "packages"); + + public static readonly string OSXReferenceAssembliesPath = "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks"; + public static readonly string UsrLocalReferenceAssembliesPath = "/usr/local/lib/mono/xbuild-frameworks"; + public static readonly string UsrReferenceAssembliesPath = "/usr/lib/mono/xbuild-frameworks"; + + public static string NuGetPackages = Environment.GetEnvironmentVariable("NUGET_PACKAGES") ?? GetNuGetPackagesDir(); + + private static string GetNuGetPackagesDir() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), ".nuget", "packages"); + } + return Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".nuget", "packages"); + } + } +} diff --git a/scripts/dotnet-cli-build/Utils/DotNetCli.cs b/scripts/dotnet-cli-build/Utils/DotNetCli.cs new file mode 100644 index 000000000..51e194504 --- /dev/null +++ b/scripts/dotnet-cli-build/Utils/DotNetCli.cs @@ -0,0 +1,51 @@ +using System.IO; +using System.Linq; +using System; +using System.Runtime.InteropServices; +using Microsoft.DotNet.Cli.Build.Framework; +using Microsoft.Extensions.PlatformAbstractions; + +namespace Microsoft.DotNet.Cli.Build +{ + internal class DotNetCli + { + public static readonly DotNetCli Stage0 = new DotNetCli(GetStage0Path()); + public static readonly DotNetCli Stage1 = new DotNetCli(Path.Combine(Dirs.Stage1, "bin")); + public static readonly DotNetCli Stage2 = new DotNetCli(Path.Combine(Dirs.Stage2, "bin")); + + public string BinPath { get; } + + public DotNetCli(string binPath) + { + BinPath = binPath; + } + + public void SetDotNetHome() + { + Environment.SetEnvironmentVariable("DOTNET_HOME", Path.GetDirectoryName(BinPath)); + } + + public Command Exec(string command, params string[] args) + { + return Command.Create(Path.Combine(BinPath, $"dotnet{Constants.ExeSuffix}"), Enumerable.Concat(new[] { command }, args)); + } + + public Command Restore(params string[] args) => Exec("restore", args); + public Command Build(params string[] args) => Exec("build", args); + public Command Pack(params string[] args) => Exec("pack", args); + public Command Test(params string[] args) => Exec("test", args); + public Command Publish(params string[] args) => Exec("publish", args); + + private static string GetStage0Path() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return Path.Combine(Directory.GetCurrentDirectory(), ".dotnet_stage0", PlatformServices.Default.Runtime.OperatingSystemPlatform.ToString(), "cli", "bin"); + } + else + { + return Path.Combine(Directory.GetCurrentDirectory(), ".dotnet_stage0", PlatformServices.Default.Runtime.OperatingSystemPlatform.ToString(), "share", "dotnet", "cli", "bin"); + } + } + } +} diff --git a/scripts/dotnet-cli-build/Utils/FS.cs b/scripts/dotnet-cli-build/Utils/FS.cs new file mode 100644 index 000000000..b336d46f2 --- /dev/null +++ b/scripts/dotnet-cli-build/Utils/FS.cs @@ -0,0 +1,114 @@ +using System.IO; +using System.Runtime.InteropServices; +using System; + +using Microsoft.DotNet.Cli.Build.Framework; + +using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers; + +namespace Microsoft.DotNet.Cli.Build +{ + public static class FS + { + public static void Mkdirp(string dir) + { + if (!Directory.Exists(dir)) + { + Directory.CreateDirectory(dir); + } + } + + public static void Rm(string file) + { + if(File.Exists(file)) + { + File.Delete(file); + } + } + + public static void Rmdir(string dir) + { + if(Directory.Exists(dir)) + { + Directory.Delete(dir, recursive: true); + } + } + + public static void Chmod(string file, string mode, bool recursive = false) + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (recursive) + { + Command.Create("chmod", "-R", mode, file).Execute().EnsureSuccessful(); + } + else + { + Command.Create("chmod", mode, file).Execute().EnsureSuccessful(); + } + } + } + + public static void ChmodAll(string searchDir, string pattern, string mode) + { + Exec("find", searchDir, "-type", "f", "-name", pattern, "-exec", "chmod", mode, "{}", ";"); + } + + public static void FixModeFlags(string dir) + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + // Managed code doesn't need 'x' + ChmodAll(dir, "*.dll", "644"); + ChmodAll(dir, "*.exe", "644"); + + // Generally, dylibs and sos have 'x' (no idea if it's required ;)) + // (No need to condition this on OS since there shouldn't be any dylibs on Linux, + // but even if they are we may as well set their mode flags :)) + ChmodAll(dir, "*.dylib", "755"); + ChmodAll(dir, "*.so", "755"); + + // Executables (those without dots) are executable :) + Exec("find", dir, "-type", "f", "!", "-name", "*.*", "-exec", "chmod", "755", "{}", ";"); + } + } + + public static void CopyRecursive(string sourceDirectory, string destinationDirectory, bool overwrite = false) + { + Mkdirp(destinationDirectory); + + foreach(var dir in Directory.EnumerateDirectories(sourceDirectory)) + { + CopyRecursive(dir, Path.Combine(destinationDirectory, Path.GetFileName(dir)), overwrite); + } + + foreach(var file in Directory.EnumerateFiles(sourceDirectory)) + { + var dest = Path.Combine(destinationDirectory, Path.GetFileName(file)); + if (!File.Exists(dest) || overwrite) + { + // We say overwrite true, because we only get here if the file didn't exist (thus it doesn't matter) or we + // wanted to overwrite :) + File.Copy(file, dest, overwrite: true); + } + } + } + + public static void CleanBinObj(BuildTargetContext c, string dir) + { + dir = dir ?? c.BuildContext.BuildDirectory; + foreach(var candidate in Directory.EnumerateDirectories(dir)) + { + if (string.Equals(Path.GetFileName(candidate), "bin") || + string.Equals(Path.GetFileName(candidate), "obj")) + { + Directory.Delete(candidate, recursive: true); + } + else + { + CleanBinObj(c, candidate); + } + } + } + } +} diff --git a/scripts/dotnet-cli-build/Utils/Utils.cs b/scripts/dotnet-cli-build/Utils/Utils.cs new file mode 100644 index 000000000..edbee23d1 --- /dev/null +++ b/scripts/dotnet-cli-build/Utils/Utils.cs @@ -0,0 +1,38 @@ +using System; +using System.IO; +using System.Runtime.InteropServices; + +namespace Microsoft.DotNet.Cli.Build +{ + public static class Utils + { + public static void CleanNuGetTempCache() + { + // Clean NuGet Temp Cache on Linux (seeing some issues on Linux) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && Directory.Exists("/tmp/NuGet")) + { + Directory.Delete("/tmp/NuGet", recursive: true); + } + } + + public static string GetOSName() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return "win"; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + return "osx"; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + throw new NotImplementedException(); + } + else + { + throw new PlatformNotSupportedException(); + } + } + } +} diff --git a/scripts/dotnet-cli-build/dotnet-cli-build.xproj b/scripts/dotnet-cli-build/dotnet-cli-build.xproj new file mode 100644 index 000000000..fadd44933 --- /dev/null +++ b/scripts/dotnet-cli-build/dotnet-cli-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\$(MSBuildProjectName)\ + + + 2.0 + + + \ No newline at end of file diff --git a/scripts/dotnet-cli-build/project.json b/scripts/dotnet-cli-build/project.json new file mode 100755 index 000000000..326ce33b3 --- /dev/null +++ b/scripts/dotnet-cli-build/project.json @@ -0,0 +1,18 @@ +{ + "version": "1.0.0-*", + "description": "Build scripts for dotnet-cli", + "compilationOptions": { + "emitEntryPoint": true + }, + + "dependencies": { + "NETStandard.Library": "1.0.0-rc2-23811", + "System.IO.Compression.ZipFile": "4.0.1-rc2-23811", + "Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16537", + "Microsoft.DotNet.Cli.Build.Framework": "1.0.0-*" + }, + + "frameworks": { + "dnxcore50": { } + } +} diff --git a/scripts/global.json b/scripts/global.json new file mode 100644 index 000000000..22936715c --- /dev/null +++ b/scripts/global.json @@ -0,0 +1,3 @@ +{ + "projects": [ "." ] +} diff --git a/scripts/obtain/install-tools.ps1 b/scripts/obtain/install-tools.ps1 deleted file mode 100644 index 89ae69dfe..000000000 --- a/scripts/obtain/install-tools.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -# -# 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. -# - -. $PSScriptRoot\..\common\_common.ps1 - -# Use a repo-local install directory (but not the artifacts directory because that gets cleaned a lot -if (!(Test-Path $env:DOTNET_INSTALL_DIR)) -{ - mkdir $env:DOTNET_INSTALL_DIR | Out-Null -} - -# Install a stage 0 -header "Installing dotnet stage 0" -_ "$RepoRoot\scripts\obtain\install.ps1" @("$env:Channel") diff --git a/scripts/obtain/install-tools.sh b/scripts/obtain/install-tools.sh deleted file mode 100755 index b3be18f94..000000000 --- a/scripts/obtain/install-tools.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/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 )" - -source "$DIR/../common/_common.sh" - -# Use a repo-local install directory (but not the artifacts directory because that gets cleaned a lot -[ -d $DOTNET_INSTALL_DIR ] || mkdir -p $DOTNET_INSTALL_DIR - -# Ensure the latest stage0 is installed -header "Installing dotnet stage 0" -$REPOROOT/scripts/obtain/install.sh diff --git a/scripts/package/package-dnvm.sh b/scripts/package/package-dnvm.sh index 412161753..47d8fe396 100755 --- a/scripts/package/package-dnvm.sh +++ b/scripts/package/package-dnvm.sh @@ -33,6 +33,6 @@ header "Packaging $PACKAGE_SHORT_NAME" # We need both "*" and ".version" to ensure we pick up that file tar -czf $PACKAGE_NAME * .version -info "Packaged stage2 to $PACKAGE_NAME" +info "Packaged stage2 from '$STAGE2_DIR' to '$PACKAGE_NAME'" $REPOROOT/scripts/publish/publish.sh $PACKAGE_NAME diff --git a/scripts/package/package.ps1 b/scripts/package/package.ps1 index 577a17380..cfb3c13d8 100644 --- a/scripts/package/package.ps1 +++ b/scripts/package/package.ps1 @@ -4,7 +4,8 @@ # . "$PSScriptRoot\..\common\_common.ps1" -. "$RepoRoot\scripts\build\generate-version.ps1" + +$RepoRoot = Convert-Path "$PSScriptRoot\..\.." header "Generating zip package" _ "$RepoRoot\scripts\package\package-zip.ps1" diff --git a/scripts/package/package.sh b/scripts/package/package.sh index dea779842..a412a04f7 100755 --- a/scripts/package/package.sh +++ b/scripts/package/package.sh @@ -12,8 +12,9 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +export REPOROOT="$(cd -P "$DIR/../.." && pwd)" + source "$DIR/../common/_common.sh" -source "$REPOROOT/scripts/build/generate-version.sh" if [ -z "$DOTNET_CLI_VERSION" ]; then TIMESTAMP=$(date "+%Y%m%d%H%M%S") @@ -33,5 +34,5 @@ header "Generating version badge" sed "s/ver_number/$DOTNET_CLI_VERSION/g" $VERSION_BADGE > $BADGE_DESTINATION header "Publishing version badge" -$REPOROOT/scripts/publish/publish.sh $BADGE_DESTINATION +$DIR/../publish/publish.sh $BADGE_DESTINATION diff --git a/scripts/run-build.ps1 b/scripts/run-build.ps1 new file mode 100644 index 000000000..9b9453722 --- /dev/null +++ b/scripts/run-build.ps1 @@ -0,0 +1,55 @@ +# +# 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") + +$env:CONFIGURATION = $Configuration; + +# Load Branch Info +cat "$PSScriptRoot\..\branchinfo.txt" | ForEach-Object { + if(!$_.StartsWith("#") -and ![String]::IsNullOrWhiteSpace($_)) { + $splat = $_.Split([char[]]@("="), 2) + Set-Content "env:\$($splat[0])" -Value $splat[1] + } +} + +$env:CHANNEL=$env:RELEASE_SUFFIX + +# 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" +} + +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 beta channel" +& "$PSScriptRoot\obtain\install.ps1" -Channel $env:CHANNEL + +# Put the stage0 on the path +$env:PATH = "$env:DOTNET_INSTALL_DIR\cli\bin;$env:PATH" + +# Restore the build scripts +Write-Host "Restoring Build Script projects..." +pushd $PSScriptRoot +dotnet restore +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 dnxcore50 +if($LASTEXITCODE -ne 0) { throw "Failed to compile build scripts" } + +# Run the builder +Write-Host "Invoking Build Scripts..." +$env:DOTNET_HOME="$env:DOTNET_INSTALL_DIR\cli" +& "$PSScriptRoot\dotnet-cli-build\bin\dotnet-cli-build.exe" @args +if($LASTEXITCODE -ne 0) { throw "Build failed" } diff --git a/scripts/run-build.sh b/scripts/run-build.sh new file mode 100755 index 000000000..c5a7f3542 --- /dev/null +++ b/scripts/run-build.sh @@ -0,0 +1,80 @@ +#!/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 )" + +# 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 < "$DIR/../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 + +# Ensure the latest stage0 is installed +$DIR/obtain/install.sh --channel $RELEASE_SUFFIX + +# Put stage 0 on the PATH (for this shell only) +PATH="$DOTNET_INSTALL_DIR/bin:$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 +) + +# Build the builder +echo "Compiling Build Scripts..." +dotnet publish "$DIR/dotnet-cli-build" -o "$DIR/dotnet-cli-build/bin" --framework dnxcore50 + +# Run the builder +echo "Invoking Build Scripts..." + +if [ -f "$DIR/dotnet-cli-build/bin/dotnet-cli-build" ]; then + DOTNET_HOME="$DOTNET_INSTALL_DIR/share/dotnet/cli" $DIR/dotnet-cli-build/bin/dotnet-cli-build "$@" + exit $? +else + # We're on an older CLI. This is temporary while Ubuntu and CentOS VSO builds are stalled. + DOTNET_HOME="$DOTNET_INSTALL_DIR/share/dotnet/cli" $DIR/dotnet-cli-build/bin/Debug/dnxcore50/dotnet-cli-build "$@" + exit $? +fi diff --git a/scripts/test/build-tests.ps1 b/scripts/test/build-tests.ps1 deleted file mode 100644 index 140e75ab6..000000000 --- a/scripts/test/build-tests.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -# -# 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. -# - -. "$PSScriptRoot\..\common\_common.ps1" - -# Publish each test project -loadTestProjectList | foreach { - #we should use publish to an output path, we will once issue #1183 has been fixed and we can point dotnet test do a dll. - #we need to add back tfm, rid and configuration, but dotnet test need to be made aware of those as well. Tracked at issue #1237. - dotnet build "$RepoRoot\test\$($_.ProjectName)" - if (!$?) { - Write-Host Command failed: dotnet build "$RepoRoot\test\$($_.ProjectName)" - exit 1 - } -} diff --git a/scripts/test/build-tests.sh b/scripts/test/build-tests.sh deleted file mode 100755 index d12d6d4c9..000000000 --- a/scripts/test/build-tests.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/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 )" - -source "$DIR/../common/_common.sh" - -PROJECTS=$(loadTestProjectList) - -for project in $PROJECTS -do - #we should use publish to an output path, we will once issue #1183 has been fixed and we can point dotnet test do a dll. - dotnet build "$REPOROOT/test/$project" -done - diff --git a/scripts/test/check-prereqs.ps1 b/scripts/test/check-prereqs.ps1 deleted file mode 100644 index 21a65b988..000000000 --- a/scripts/test/check-prereqs.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -# -# 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. -# - -if (!(Get-Command -ErrorAction SilentlyContinue cmake)) { - throw @" -cmake is required to build the native host 'corehost' -Download it from https://www.cmake.org -"@ -} \ No newline at end of file diff --git a/scripts/test/check-prereqs.sh b/scripts/test/check-prereqs.sh deleted file mode 100755 index 8640ffb03..000000000 --- a/scripts/test/check-prereqs.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/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. -# - -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 )" - -source "$DIR/../common/_common.sh" - -if ! type -p cmake >/dev/null; then - error "cmake is required to build the native host 'corehost'" - error "OS X w/Homebrew: 'brew install cmake'" - error "Ubuntu: 'sudo apt-get install cmake'" - exit 1 -fi diff --git a/scripts/test/package-command-test.ps1 b/scripts/test/package-command-test.ps1 deleted file mode 100644 index 476a171c9..000000000 --- a/scripts/test/package-command-test.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -# -# 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. -# - -. "$PSScriptRoot\..\common\_common.ps1" - -#compile apps -dir "$RepoRoot\test\PackagedCommands\Consumers" | where {$_.PsIsContainer} | where {$_.Name.Contains("Direct")} | -foreach { - pushd "$RepoRoot\test\PackagedCommands\Consumers\$_" - dotnet build - popd -} - -#run test -dir "$RepoRoot\test\PackagedCommands\Consumers" | where {$_.PsIsContainer} | where {$_.Name.Contains("AppWith")} | -foreach { - $testName = "test\PackagedCommands\Consumers\$_" - pushd "$RepoRoot\$testName" - $outputArray = dotnet hello | Out-String - $output = [string]::Join('\n', $outputArray).Trim("`r", "`n") - - if ($output -ne "hello") { - error "Test Failed: $testName\dotnet hello" - error " printed $output" - Exit 1 - } - - info "Test passed: $testName" - popd -} - -Exit 0 diff --git a/scripts/test/package-command-test.sh b/scripts/test/package-command-test.sh deleted file mode 100755 index 6baf6eb59..000000000 --- a/scripts/test/package-command-test.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/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 )" - -source "$DIR/../common/_common.sh" - -#compile tests with direct dependencies -for test in $(ls -l "$REPOROOT/test/PackagedCommands/Consumers" | grep ^d | awk '{print $9}' | grep "Direct") -do - pushd "$REPOROOT/test/PackagedCommands/Consumers/$test" - dotnet build - popd -done - -#run test -for test in $(ls -l "$REPOROOT/test/PackagedCommands/Consumers" | grep ^d | awk '{print $9}' | grep "AppWith") -do - testName="test/PackagedCommands/Consumers/$test" - - pushd "$REPOROOT/$testName" - - output=$(dotnet hello) - - - if [ "$output" == "Hello" ] ; - then - echo "Test Passed: $testName" - else - error "Test Failed: $testName/dotnet hello" - error " printed $output" - exit 1 - fi - - popd -done diff --git a/scripts/test/restore-tests.ps1 b/scripts/test/restore-tests.ps1 deleted file mode 100644 index 48d1dd5e7..000000000 --- a/scripts/test/restore-tests.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -# -# 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. -# - -. $PSScriptRoot\..\common\_common.ps1 - -info "Restoring Test Projects" - -# Restore packages -& dotnet restore "$RepoRoot\test" -f "$TestPackageDir" diff --git a/scripts/test/run-tests.ps1 b/scripts/test/run-tests.ps1 deleted file mode 100644 index 31dcc70cb..000000000 --- a/scripts/test/run-tests.ps1 +++ /dev/null @@ -1,67 +0,0 @@ -# -# 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. -# - -. "$PSScriptRoot\..\common\_common.ps1" - -$TestBinRoot = "$RepoRoot\artifacts\tests" - -$TestProjects = loadTestProjectList -$TestScripts = loadTestScriptList - -$failCount = 0 -$failingTests = @() - -## Temporary Workaround for Native Compilation -## Need x64 Native Tools Dev Prompt Env Vars -## Tracked Here: https://github.com/dotnet/cli/issues/301 -pushd "$env:VS140COMNTOOLS\..\..\VC" -cmd /c "vcvarsall.bat x64&set" | -foreach { - if ($_ -match "=") { - $v = $_.split("=", 2); set-item -force -literalpath "ENV:\$($v[0])" -value "$($v[1])" - } -} -popd - -# copy TestProjects to $TestBinRoot -mkdir -Force "$TestBinRoot\TestProjects" -cp -rec -Force "$RepoRoot\TestAssets\TestProjects\*" "$TestBinRoot\TestProjects" - -# Run each test project -$TestProjects | foreach { - # This is a workaroudn for issue #1184, where dotnet test needs to be executed from the folder containing the project.json. - pushd "$RepoRoot\test\$($_.ProjectName)" - dotnet test -xml "$TestBinRoot\$($_.ProjectName)-testResults.xml" -notrait category=failing - popd - - $exitCode = $LastExitCode - if ($exitCode -ne 0) { - $failingTests += "$($_.ProjectName)" - } - - $failCount += $exitCode -} - -$TestScripts | foreach { - $scriptName = "$($_.ProjectName).ps1" - - & "$RepoRoot\scripts\test\$scriptName" - $exitCode = $LastExitCode - if ($exitCode -ne 0) { - $failingTests += "$scriptName" - $failCount += 1 - } -} - -if ($failCount -ne 0) { - Write-Host -ForegroundColor Red "The following tests failed." - $failingTests | foreach { - Write-Host -ForegroundColor Red "$_.dll failed. Logs in '$TestBinRoot\$_-testResults.xml'" - } -} else { - Write-Host -ForegroundColor Green "All the tests passed!" -} - -Exit $failCount diff --git a/scripts/test/run-tests.sh b/scripts/test/run-tests.sh deleted file mode 100755 index fdf089426..000000000 --- a/scripts/test/run-tests.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/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 )" - -source "$DIR/../common/_common.sh" - -TestProjects=$(loadTestProjectList) -TestScripts=$(loadTestScriptList) - -failedTests=() -failCount=0 - -# Copy TestProjects to $TEST_BIN_ROOT -mkdir -p "$TEST_BIN_ROOT/TestProjects" -cp -a $REPOROOT/TestAssets/TestProjects/* $TEST_BIN_ROOT/TestProjects - -pushd "$TEST_BIN_ROOT" -set +e - -for project in $TestProjects -do - # This is a workaroudn for issue #1184, where dotnet test needs to be executed from the folder containing the project.json. - pushd "$REPOROOT/test/$project" - dotnet test -xml "$TEST_BIN_ROOT/${project}-testResults.xml" -notrait category=failing - popd - - exitCode=$? - failCount+=$exitCode - if [ $exitCode -ne 0 ]; then - failedTests+=("${project}.dll") - fi -done - -popd - -for script in $TestScripts -do - scriptName=${script}.sh - - "$REPOROOT/scripts/test/${scriptName}" - exitCode=$? - if [ $exitCode -ne 0 ]; then - failedTests+=("$scriptName") - failCount+=1 - fi -done - -for test in ${failedTests[@]} -do - error "$test failed. Logs in '$TEST_BIN_ROOT/${test}-testResults.xml'" -done - -set -e - -exit $failCount diff --git a/scripts/test/setup/build-test-prerequisites.ps1 b/scripts/test/setup/build-test-prerequisites.ps1 deleted file mode 100644 index 1873a08c7..000000000 --- a/scripts/test/setup/build-test-prerequisites.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -# -# 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. -# - -. "$PSScriptRoot\..\..\common\_common.ps1" - -mkdir -Force $TestPackageDir - -loadTestPackageList | foreach { - dotnet pack "$RepoRoot\TestAssets\TestPackages\$($_.ProjectName)" --output "$TestPackageDir" - - if (!$?) { - error "Command failed: dotnet pack" - Exit 1 - } -} diff --git a/scripts/test/setup/restore-test-prerequisites.ps1 b/scripts/test/setup/restore-test-prerequisites.ps1 deleted file mode 100644 index 6bfb8242f..000000000 --- a/scripts/test/setup/restore-test-prerequisites.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -# -# 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. -# - -". $PSScriptRoot\..\..\common\_common.ps1" - -header "Restoring TestAssets" -& dotnet restore "$RepoRoot\TestAssets" --quiet --runtime "$Rid" - -$oldErrorAction=$ErrorActionPreference -$ErrorActionPreference="SilentlyContinue" -& dotnet restore "$RepoRoot\testapp" "$Rid" 2>&1 | Out-Null -$ErrorActionPreference=$oldErrorAction diff --git a/scripts/test/setup/restore-test-prerequisites.sh b/scripts/test/setup/restore-test-prerequisites.sh deleted file mode 100755 index 1ade59817..000000000 --- a/scripts/test/setup/restore-test-prerequisites.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/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 )" - -source "$DIR/../../common/_common.sh" - -header "Restoring TestAssets" -dotnet restore "$REPOROOT/TestAssets" --runtime $RID --quiet $DISABLE_PARALLEL - -set +e -dotnet restore "$REPOROOT/testapp" --runtime $RID $DISABLE_PARALLEL >/dev/null 2>&1 -set -e \ No newline at end of file diff --git a/scripts/test/setup/setup-tests.ps1 b/scripts/test/setup/setup-tests.ps1 deleted file mode 100644 index 816c3950c..000000000 --- a/scripts/test/setup/setup-tests.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -# -# 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. -# - -. "$PSScriptRoot\..\..\common\_common.ps1" - -header "Test Setup: Restoring Prerequisites" -_ "$RepoRoot\scripts\test\setup\restore-test-prerequisites.ps1" - -header "Test Setup: Building Prerequisites" -_ "$RepoRoot\scripts\test\setup\build-test-prerequisites.ps1" \ No newline at end of file diff --git a/scripts/test/setup/setup-tests.sh b/scripts/test/setup/setup-tests.sh deleted file mode 100755 index d8ad16d6d..000000000 --- a/scripts/test/setup/setup-tests.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/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 )" - -source "$DIR/../../common/_common.sh" - -header "Test Setup: Restoring Prerequisites" -"$REPOROOT/scripts/test/setup/restore-test-prerequisites.sh" - -header "Test Setup: Building Prerequisites" -"$REPOROOT/scripts/test/setup/build-test-prerequisites.sh" \ No newline at end of file diff --git a/scripts/test/test.ps1 b/scripts/test/test.ps1 deleted file mode 100644 index d586fb74e..000000000 --- a/scripts/test/test.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -# -# 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. -# - -. "$PSScriptRoot\..\common\_common.ps1" - -header "Setting up Tests" -_ "$RepoRoot\scripts\test\setup\setup-tests.ps1" - -header "Restoring test projects" -_ "$RepoRoot\scripts\test\restore-tests.ps1" - -header "Building test projects" -_ "$RepoRoot\scripts\test\build-tests.ps1" - -header "Running Tests" -_ "$RepoRoot\scripts\test\run-tests.ps1" \ No newline at end of file diff --git a/scripts/test/test.sh b/scripts/test/test.sh deleted file mode 100755 index f05fe115a..000000000 --- a/scripts/test/test.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/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 )" - -source "$DIR/../common/_common.sh" - -header "Setting up Tests" -"$REPOROOT/scripts/test/setup/setup-tests.sh" - -header "Restoring test projects" -"$REPOROOT/scripts/test/restore-tests.sh" - -header "Building test projects" -"$REPOROOT/scripts/test/build-tests.sh" - -header "Running Tests" -"$REPOROOT/scripts/test/run-tests.sh" \ No newline at end of file diff --git a/scripts/test/validate-dependencies.ps1 b/scripts/test/validate-dependencies.ps1 deleted file mode 100644 index e47e55c1a..000000000 --- a/scripts/test/validate-dependencies.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -# -# 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. -# - -. "$PSScriptRoot\..\common\_common.ps1" - -# Run Validation for Project.json dependencies -dotnet publish $RepoRoot\tools\MultiProjectValidator -o $Stage2Dir\..\tools -c "$Configuration" - -$pjvalidatePath = "$Stage2Dir\..\tools\$Configuration\$Tfm" -if (! (Test-Path $pjvalidatePath)) { - $pjvalidatePath = "$Stage2Dir\..\tools" -} - -& "$pjvalidatePath\pjvalidate" "$RepoRoot\src" -# TODO For release builds, this should be uncommented and fail. -# if (!$?) { -# Write-Host "Project Validation Failed" -# Exit 1 -# } \ No newline at end of file diff --git a/scripts/test/validate-dependencies.sh b/scripts/test/validate-dependencies.sh deleted file mode 100755 index a9e476097..000000000 --- a/scripts/test/validate-dependencies.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/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 )" - -. "$DIR/../common/_common.sh" - -# Run Validation for Project.json dependencies -dotnet publish "$REPOROOT/tools/MultiProjectValidator" -o "$STAGE2_DIR/../tools" -c "$CONFIGURATION" -#TODO for release builds this should fail -set +e -PJ_VALIDATE_PATH="$STAGE2_DIR/../tools/$CONFIGURATION/$TFM" -if [ ! -d "$PJ_VALIDATE_PATH" ] -then - PJ_VALIDATE_PATH="$STAGE2_DIR/../tools" -fi - -"$PJ_VALIDATE_PATH/pjvalidate" "$REPOROOT/src" -set -e diff --git a/src/Microsoft.DotNet.Cli.Utils/StreamForwarder.cs b/src/Microsoft.DotNet.Cli.Utils/StreamForwarder.cs index 87caf6a56..a2cbc32af 100644 --- a/src/Microsoft.DotNet.Cli.Utils/StreamForwarder.cs +++ b/src/Microsoft.DotNet.Cli.Utils/StreamForwarder.cs @@ -129,4 +129,4 @@ namespace Microsoft.DotNet.Cli.Utils } } } -} \ No newline at end of file +} diff --git a/scripts/test/restore-tests.sh b/src/corehost/build.sh similarity index 56% rename from scripts/test/restore-tests.sh rename to src/corehost/build.sh index a39c795fd..339838348 100755 --- a/scripts/test/restore-tests.sh +++ b/src/corehost/build.sh @@ -1,8 +1,8 @@ #!/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. -# + +# Why is this a separate script? Why not just invoke 'cmake' and 'make' in the C# build scripts themselves? +# I really don't know, but it doesn't work when I do that. Something about SIGCHLD not getting from clang to cmake or something. +# -anurse set -e @@ -14,8 +14,6 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" -source "$DIR/../common/_common.sh" - -header "Restoring Test Packages" - -dotnet restore "$REPOROOT/test" --runtime $RID -f "$TEST_PACKAGE_DIR" $DISABLE_PARALLEL +echo "Building Corehost from $DIR to $(pwd)" +cmake "$DIR" -G "Unix Makefiles" +make diff --git a/src/dotnet/commands/dotnet-restore/NuGet3.cs b/src/dotnet/commands/dotnet-restore/NuGet3.cs index 1458040e3..58f74a6b8 100644 --- a/src/dotnet/commands/dotnet-restore/NuGet3.cs +++ b/src/dotnet/commands/dotnet-restore/NuGet3.cs @@ -21,8 +21,8 @@ namespace Microsoft.DotNet.Tools.Restore var result = Run(Enumerable.Concat( prefixArgs, args)) - .ForwardStdErr() .ForwardStdOut() + .ForwardStdErr() .Execute(); return result.ExitCode; diff --git a/test/EndToEnd/EndToEndTest.cs b/test/EndToEnd/EndToEndTest.cs index 25450216a..bd93d730c 100644 --- a/test/EndToEnd/EndToEndTest.cs +++ b/test/EndToEnd/EndToEndTest.cs @@ -16,7 +16,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd private static readonly string s_expectedOutput = "Hello World!" + Environment.NewLine; private static readonly string s_testdirName = "e2etestroot"; private static readonly string s_outputdirName = "test space/bin"; - + private static string RestoredTestProjectDirectory { get; set; } private string Rid { get; set; } @@ -33,7 +33,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd { Console.WriteLine("Dummy Entrypoint."); } - + public EndToEndTest() { TestInstanceSetup(); @@ -192,7 +192,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd { Directory.Delete(RestoredTestProjectDirectory, true); } - catch(Exception e) {} + catch(Exception) {} Directory.CreateDirectory(RestoredTestProjectDirectory); @@ -231,4 +231,4 @@ namespace Microsoft.DotNet.Tests.EndToEnd File.SetLastWriteTimeUtc(csFile, DateTime.UtcNow); } } -} \ No newline at end of file +}