From 57fcdf9a0b44081e1c77a572f1e606e26b5c0ace Mon Sep 17 00:00:00 2001 From: miterosan Date: Fri, 15 Feb 2019 23:47:22 +0100 Subject: [PATCH 1/4] Improve the buildscript --- .gitignore | 5 +++-- .vscode/launch.json | 14 ++++++++++++++ build.ps1 | 13 ++++++++----- build.cake => build/build.cake | 20 +++++++------------- {tools => build}/cakebuild.csproj | 0 5 files changed, 32 insertions(+), 20 deletions(-) rename build.cake => build/build.cake (77%) rename {tools => build}/cakebuild.csproj (100%) diff --git a/.gitignore b/.gitignore index f95a04e517..6186cb870d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,9 @@ *.userprefs ### Cake ### -tools/* -!tools/cakebuild.csproj +tools/** +build/tools/** + # Build results bin/[Dd]ebug/ diff --git a/.vscode/launch.json b/.vscode/launch.json index 10c6f02314..c3306c2db7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -68,6 +68,20 @@ } }, "console": "internalConsole" + }, + { + "name": "Cake: Debug Script", + "type": "coreclr", + "request": "launch", + "program": "${workspaceRoot}/build/tools/Cake.CoreCLR/0.30.0/Cake.dll", + "args": [ + "${workspaceRoot}/build/build.cake", + "--debug", + "--verbosity=diagnostic" + ], + "cwd": "${workspaceRoot}/build", + "stopAtEntry": true, + "externalConsole": false } ] } diff --git a/build.ps1 b/build.ps1 index 9968673c90..c6a0bf6d4a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -41,27 +41,28 @@ Param( [switch]$ShowDescription, [Alias("WhatIf", "Noop")] [switch]$DryRun, - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] + [Parameter(Position = 0, Mandatory = $false, ValueFromRemainingArguments = $true)] [string[]]$ScriptArgs ) Write-Host "Preparing to run build script..." # Determine the script root for resolving other paths. -if(!$PSScriptRoot){ +if(!$PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } # Resolve the paths for resources used for debugging. -$TOOLS_DIR = Join-Path $PSScriptRoot "tools" -$CAKE_CSPROJ = Join-Path $TOOLS_DIR "cakebuild.csproj" +$BUILD_DIR = Join-Path $PSScriptRoot "build" +$TOOLS_DIR = Join-Path $BUILD_DIR "tools" +$CAKE_CSPROJ = Join-Path $BUILD_DIR "cakebuild.csproj" # Install the required tools locally. Write-Host "Restoring cake tools..." Invoke-Expression "dotnet restore `"$CAKE_CSPROJ`" --packages `"$TOOLS_DIR`"" | Out-Null # Find the Cake executable -$CAKE_EXECUTABLE = (Get-ChildItem -Path ./tools/cake.coreclr/ -Filter Cake.dll -Recurse).FullName +$CAKE_EXECUTABLE = (Get-ChildItem -Path "$TOOLS_DIR/cake.coreclr/" -Filter Cake.dll -Recurse).FullName # Build Cake arguments $cakeArguments = @("$Script"); @@ -75,5 +76,7 @@ $cakeArguments += $ScriptArgs # Start Cake Write-Host "Running build script..." +Push-Location -Path $BUILD_DIR Invoke-Expression "dotnet `"$CAKE_EXECUTABLE`" $cakeArguments" +Pop-Location exit $LASTEXITCODE diff --git a/build.cake b/build/build.cake similarity index 77% rename from build.cake rename to build/build.cake index bc7dfafb8c..411adea7dd 100644 --- a/build.cake +++ b/build/build.cake @@ -1,6 +1,7 @@ #addin "nuget:?package=CodeFileSanity&version=0.0.21" #addin "nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2018.2.2" #tool "nuget:?package=NVika.MSBuild&version=1.0.1" +var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); /////////////////////////////////////////////////////////////////////////////// // ARGUMENTS @@ -9,30 +10,25 @@ var target = Argument("target", "Build"); var configuration = Argument("configuration", "Release"); -var osuSolution = new FilePath("./osu.sln"); +var rootDirectory = new DirectoryPath(".."); +var desktopProject = rootDirectory.CombineWithFilePath("osu.Desktop/osu.Desktop.csproj"); +var solution = rootDirectory.CombineWithFilePath("osu.sln"); /////////////////////////////////////////////////////////////////////////////// // TASKS /////////////////////////////////////////////////////////////////////////////// -Task("Restore") - .Does(() => { - DotNetCoreRestore(osuSolution.FullPath); - }); - Task("Compile") - .IsDependentOn("Restore") .Does(() => { - DotNetCoreBuild(osuSolution.FullPath, new DotNetCoreBuildSettings { + DotNetCoreBuild(solution.FullPath, new DotNetCoreBuildSettings { Configuration = configuration, - NoRestore = true, }); }); Task("Test") .IsDependentOn("Compile") .Does(() => { - var testAssemblies = GetFiles("**/*.Tests/bin/**/*.Tests.dll"); + var testAssemblies = GetFiles(rootDirectory + "/**/*.Tests/bin/**/*.Tests.dll"); DotNetCoreVSTest(testAssemblies, new DotNetCoreVSTestSettings { Logger = AppVeyor.IsRunningOnAppVeyor ? "Appveyor" : $"trx", @@ -46,9 +42,7 @@ Task("InspectCode") .WithCriteria(IsRunningOnWindows()) .IsDependentOn("Compile") .Does(() => { - var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); - - InspectCode(osuSolution, new InspectCodeSettings { + InspectCode(solution, new InspectCodeSettings { CachesHome = "inspectcode", OutputFile = "inspectcodereport.xml", }); diff --git a/tools/cakebuild.csproj b/build/cakebuild.csproj similarity index 100% rename from tools/cakebuild.csproj rename to build/cakebuild.csproj From ed67b580fa3bef31005fdb946e0e9a4ffc4e7845 Mon Sep 17 00:00:00 2001 From: miterosan Date: Sat, 16 Feb 2019 00:02:08 +0100 Subject: [PATCH 2/4] Also apply the changes to build.sh --- build.sh | 1 + build/build.cake | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index caf1702f41..d2b88c65ae 100755 --- a/build.sh +++ b/build.sh @@ -6,6 +6,7 @@ echo "Preparing to run build script..." +cd build SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) TOOLS_DIR=$SCRIPT_DIR/tools CAKE_BINARY_PATH=$TOOLS_DIR/"cake.coreclr" diff --git a/build/build.cake b/build/build.cake index 411adea7dd..f27f443ee9 100644 --- a/build/build.cake +++ b/build/build.cake @@ -53,7 +53,7 @@ Task("InspectCode") Task("CodeFileSanity") .Does(() => { ValidateCodeSanity(new ValidateCodeSanitySettings { - RootDirectory = ".", + RootDirectory = rootDirectory.FullPath, IsAppveyorBuild = AppVeyor.IsRunningOnAppVeyor }); }); From c09346080f492714f850aac2f004553e24c76d27 Mon Sep 17 00:00:00 2001 From: miterosan Date: Sat, 16 Feb 2019 14:51:20 +0100 Subject: [PATCH 3/4] Remove the unused desktop project variable --- build/build.cake | 1 - 1 file changed, 1 deletion(-) diff --git a/build/build.cake b/build/build.cake index f27f443ee9..81deeb3bc7 100644 --- a/build/build.cake +++ b/build/build.cake @@ -11,7 +11,6 @@ var target = Argument("target", "Build"); var configuration = Argument("configuration", "Release"); var rootDirectory = new DirectoryPath(".."); -var desktopProject = rootDirectory.CombineWithFilePath("osu.Desktop/osu.Desktop.csproj"); var solution = rootDirectory.CombineWithFilePath("osu.sln"); /////////////////////////////////////////////////////////////////////////////// From 97086342324789b333dcc01b5cad5bd4c170ce48 Mon Sep 17 00:00:00 2001 From: miterosan Date: Sun, 17 Feb 2019 13:57:14 +0100 Subject: [PATCH 4/4] Correct the path to the cakebuild.csproj. --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index d2b88c65ae..8f1ef5b455 100755 --- a/build.sh +++ b/build.sh @@ -12,7 +12,7 @@ TOOLS_DIR=$SCRIPT_DIR/tools CAKE_BINARY_PATH=$TOOLS_DIR/"cake.coreclr" SCRIPT="build.cake" -CAKE_CSPROJ=$TOOLS_DIR/"cakebuild.csproj" +CAKE_CSPROJ=$SCRIPT_DIR/"cakebuild.csproj" # Parse arguments. CAKE_ARGUMENTS=()