Skip to content

Commit

Permalink
👷 Update cake build
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontaylordev committed Nov 28, 2024
1 parent d1bfdca commit ca00797
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CleanArchitecture.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<files>
<file src=".template.config\icon.png" />
<file src="README.md" />
<file src=".\**" target="content" exclude="**\node_modules\**;**\tools\**;**\bin\**;**\obj\**;.\.vs\**;.\.vscode\**;**\ClientApp\dist\**;**\wwwroot\dist\**;content\Directory.Build.*;.\.git\**;.\.github\workflows\package.yml;.\.github\workflows\codeql.yml;.\.github\workflows\build.yml;.\.github\ISSUE_TEMPLATE\**;.\.github\icon.png;.\.github\FUNDING.md;.\CODE_OF_CONDUCT.md;.\LICENSE;.\README.md;.\CleanArchitecture.nuspec;.\src\Web\app.db;.\build.cake;" />
<file src=".\**" target="content" exclude="**\node_modules\**;**\tools\**;**\bin\**;**\obj\**;.\.vs\**;.\.vscode\**;**\ClientApp\dist\**;**\wwwroot\dist\**;content\Directory.Build.*;.\.git\**;.\.github\workflows\package.yml;.\.github\workflows\codeql.yml;.\.github\workflows\build.yml;.\.github\ISSUE_TEMPLATE\**;.\.github\icon.png;.\.github\FUNDING.md;.\CODE_OF_CONDUCT.md;.\LICENSE;.\README.md;.\CleanArchitecture.nuspec;.\src\Web\app.db;" />
</files>

</package>
55 changes: 41 additions & 14 deletions build.cake
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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
};
Expand Down Expand Up @@ -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);
RunTarget(target);

0 comments on commit ca00797

Please sign in to comment.