From ca00797b48e9ecdfd5d2e2227e34b53c0c9691b1 Mon Sep 17 00:00:00 2001 From: JasonTaylorDev Date: Thu, 28 Nov 2024 12:19:34 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Update=20cake=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CleanArchitecture.nuspec | 2 +- build.cake | 55 ++++++++++++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/CleanArchitecture.nuspec b/CleanArchitecture.nuspec index bfe5e0538..e7e83dda9 100644 --- a/CleanArchitecture.nuspec +++ b/CleanArchitecture.nuspec @@ -32,7 +32,7 @@ - + diff --git a/build.cake b/build.cake index 37c148ee4..5a0e8dc42 100644 --- a/build.cake +++ b/build.cake @@ -1,7 +1,17 @@ +// #if (!UseApiOnly) +#addin nuget:?package=Cake.Npm&version=4.0.0 +// #endif + var target = Argument("target", "Default"); var configuration = Argument("configuration", "Release"); var webPath = "./src/Web"; +// #if (!UseApiOnly) +var clientAppPath = "./src/Web/ClientApp"; var webUrl = "https://localhost:44447/"; +// #else +var webUrl = "https://localhost:5001/"; +// #endif + IProcess webProcess = null; Task("Build") @@ -10,14 +20,21 @@ Task("Build") DotNetBuild("./CleanArchitecture.sln", new DotNetBuildSettings { Configuration = configuration }); +// #if (!UseApiOnly) + if (DirectoryExists(clientAppPath)) { + Information("Installing client app dependencies..."); + NpmInstall(settings => settings.WorkingDirectory = clientAppPath); + Information("Building client app..."); + NpmRunScript("build", settings => settings.WorkingDirectory = clientAppPath); + } +// #endif }); -Task("StartWeb") - .IsDependentOn("Build") +Task("Run") .Does(() => { Information("Starting web project..."); var processSettings = new ProcessSettings { - Arguments = $"run --project {webPath} --configuration {configuration}", + Arguments = $"run --project {webPath} --configuration {configuration} --no-build --no-restore", RedirectStandardOutput = true, RedirectStandardError = true }; @@ -55,30 +72,40 @@ Task("StartWeb") Task("Test") .ContinueOnError() - .IsDependentOn("StartWeb") .Does(() => { Information("Testing project..."); - DotNetTest("./CleanArchitecture.sln", new DotNetTestSettings { + + var testSettings = new DotNetTestSettings { Configuration = configuration, NoBuild = true - }); + }; + +// #if (!UseApiOnly) + if (target == "Basic") { + testSettings.Filter = "FullyQualifiedName!~AcceptanceTests"; + } +// #endif + + DotNetTest("./CleanArchitecture.sln", testSettings); }); -Task("StopWeb") - .IsDependentOn("Test") - .Does(() => { +Teardown(context => +{ if (webProcess != null) { Information("Stopping web project..."); webProcess.Kill(); webProcess.WaitForExit(); Information("Web project stopped."); } - }); +}); Task("Default") .IsDependentOn("Build") - .IsDependentOn("StartWeb") - .IsDependentOn("Test") - .IsDependentOn("StopWeb"); + .IsDependentOn("Run") + .IsDependentOn("Test"); + +Task("Basic") + .IsDependentOn("Build") + .IsDependentOn("Test"); -RunTarget(target); \ No newline at end of file +RunTarget(target);